From: Cranleigh, Surrey, England Insane since: May 2003
posted 01-03-2008 17:52
This month's theme is: Dynamics.
I know we've had similar competitions in the past, but we're all still getting our throwing arms back in and this allows for some variety. So this is dynamics in the loosest requirable sense.
quote:
A code monkey said once:
As usual, the main rule is to make your script in 20 lines of (effective) code.
Comas shouldn't be used to execute several instructions on the same line
See the code sample below to illustrate the basic rules :
code:
<script type="text/javascript">
/* */ document.body.onclick = function()
/* */ {
/* 01 */ val = prompt( 'enter a number' );
/* 02 */ for( i=0; i<10; i++ )
/* */ {
/* 03 */ alert( stupidFunction( val, i ) )
/* */ }
/* */ }
/* */ function stupidFunction( a, b )
/* */ {
/* 04 */ return a>b?a:b; // I said it was a stupid function
/* */ }
</script>
e]
The document.body.onclick = function() does not count as a line as it's not some effective code and the function call could be put in the BODY tag ( or anyother HTML tag ).
The declaration of the stupidFunction() does not count either for the same reasons.
The coma in the line /* 03 */ is ok, since it simply separates the parameters of a function.
Please branch out as much as you wish from the topic! (within reason...)
Examples of possible entries :
A pool game
Particles in the wind
An aerofoil simulator
A radoll?
Pinball
....
Best of luck to all! Can't wait to see what you might come up with
[edit] Oh God...had an extra stupid moment. That should be, of course, "JANUARY 08" in the title, but it won't let me edit it. Also, that spurious "e]" shouldn't be there - I think this is a bug! [/edit]
From: Cranleigh, Surrey, England Insane since: May 2003
posted 01-04-2008 14:48
Yay! Another competitor ^_^ I wonder if there are any around who only frequent the general forum but used to participate back in the day? Also, I was a fan of restricting to 20 lines - adds to the challenge. But maybe if the winner each month wants to set the line limit in addition to the topic for the following month?
From: Cranleigh, Surrey, England Insane since: May 2003
posted 01-05-2008 14:43
IW: Very impressive Like the idea, the script...even love the design Also, it most certainly comes under dynamics, don't worry ^_^ It'll be interesting to see what you can do RE speed too :P
BTW guys, I know this isn't the normal topic of conversation on this board, but as we're considering diminutive code....I think you guys might be able to give some other coders a kicking here: http://sla.ckers.org/forum/read.php?2,18790,18790 Only got a week though, so be quick!
Using canvas, with a couple drawImage() using an image that looks like a cone with a round bottom for the joints, it just should be super fast and look even better. You could probably even make it swing in the wind and add an image of foliage for good measure.
not very dynamic, nothing special either but this is the best i could come up with right now ...
edit: bah ... disregard this entry ... i'll come up with something better
From: Cranleigh, Surrey, England Insane since: May 2003
posted 01-07-2008 23:44
Arthurio: Don't put yourself down; I think it's quite funky ^_^ Though that said, the more entries the better. Just one thing, if you find yourself running out of lines, consider the '?' operator, it could cut the 4 lines concerning the origin of the explosion down to 2 (easily) or 1 (with a little cheeky fiddling :P)
But don't worry, people won't bite your head off if you post a 25 liner. Are you sure you need to catch the exception anyway ? can't you check if b is valid or provide a default value.
Speaking of line count, I'm looking into chained function calls à la jQuery. How do you guys feel about them ?
What's with getting all feely?-)
I'd say 5, because
>> line E is the just calling the anonymous function declared in B
The line of code is "just calling an anonymous function" - just calling, I don't care it's anonymous,
it is a "call" so the line has an action of it's own. I'd therefore count it as valid.
Oh, and jquery seems as nice as widely spread, and surprise! It's not
really compatible with many browsers out there. Go figure..
I am not saying you do : I am just witnessing that many large companies use a js lib that does not care much about backwards compatibility.
So I mark that down as "let's focus on forward compatibility" for myself.
Excellent Arthurio, you're getting the hang of it : it's a GAME - so, much like relationships, it's not about winning and losing,
it's about experience and growth - a social activity for a Mad Scientists society ,)
Although I like your second entry, on this laptop, which is reaching the end of it's lifecycle (~5 years), it's sluggish - certainly
because of the alpha blending recommended by p01 : makes for a sweet motion blur, but my machine cannot stand it.
(And of course, remember that a challenge is a great gift in such settings)
Thanks but ... awww ... you're so full of yourself
quote: argo navis said:
you're getting the hang of it : it's a GAME - so, much like relationships, it's not about winning and losing,it's about experience and growth - a social activity for a Mad Scientists society
...
(And of course, remember that a challenge is a great gift in such settings)
It's my love for programming that I'm trying to express and js is something new and exciting to me especially as an art form. This is why I've posted 3 entries. No need to tell me that it's a game. I've long taken part and enjoyed the various forms of semi-competitive entertainment here at asylum.
You're a smart guy but don't try to act as if you were the only one
Please don't take offense. (...ahh ... why does this always sound so hypocritical
AND...
I am the initiator of this contest historically - the guy who brought it up first AND resurrected it - simply : I don't hold it as a duty
or a title, but talks like this (quote from you ten posts above) :
quote:
not very dynamic, nothing special either but this is the best i could come up with right now ...
edit: bah ... disregard this entry ... i'll come up with something better
Sound very much like the middle of puberty.
quote:
Please don't take offense. (...ahh ... why does this always sound so hypocritical
Sound very much like the next stage of puberty when you can't take constructive criticism as constructive, and feel like
the most powerful being on earth and having to prove your worth.
Reality check : you're not, and I don't claim to be myself, but instead of sounding whiney and bitching at me right there and then,
you could take and use the advice - then you'd prove your worth without sounding like a dumb ass.
I recommend do in the future as far as I am concerned - and don't worry, I will refrain from giving you pearls
if all you can do with them is wave your shineys back at me.
(aw, why do comments like this sound so BLUNTLY HONEST).
No prob, poi, to me it's "over" - but it's important to set boundaries early on also in relationships,
I don't like giving positive feedback (can someone point out something negative in my above comment?)
and receiving such an arrogant response publicly, period - I will NOT deal with it on these terms.
If any comment not directed towards javascript code is to be posted, feel free to mail it instead, argo.navis, yahoo email.
argo navis: wow what a reaction. Sorry I offended you but I really couldn't see any constructive criticism in the sentences that I quoted. Other than that you said that my 2. entry was sluggish. Yeah, I know. I think we much missed our intended tones of our initial posts as it so often happens on the internet. I hope you can forgive me one day.
poi: It gets progressively worse I tested it with 20x20 and 30x30 and I didn't get very good results but I'll give it a few more tries. The 2 main problems that I can think of are that many of the 'pixels' are wasted and recalculated even though they remain black and the 2. problem is the extensive use of Math.atan and Math.sin for calculating the color values and the shape of the flame.
Arthurio: you sure it's the calculation itself ? In my experience the bottleneck is usually the rendering engine. If you don't mind dropping IE compatibility, you could generate a BMP image using a data: URI*. I tested a fire effect using the one-zillion-DIV technique versus the BMP data: URI . The later was almost 20x faster.
Do not lend me intentions or distort them - you called me "full of yourself", don't try that again out of a humorous comment which yours was NOT,
and you have not adressed my question directly "by the way".
Reminder, the question was : can you see anything negative in the above comment?
What exactly?
It's not a matter of forgiveness or anger - I have experience in the field, you can benefit from it or keep petting yourself over
small circles that bounce around sluggishly, this depends entirely on HOW you choose to welcome advice.
So, now that you've displayed passive agressivity towards me, and keep twisting my words, care to answer my question and make a point?
Because that is the line between a self proclaimed "smart guy" and a man, fwiw.
I AM here for that and you are not adressing my question either.
I refuse being called names, and since the kid did that publicly, I am forced to adress his arrogance publicly.
>> I hope you can forgive me one day.
If you do make a clear apology, OR you demonstrate I started off insutling you, yes.
argo navis: I apologize for improperly apologizing for reacting to a post of yours that was insulting to me. I have hard time putting this into English but I couldn't let you off with a post that in ways (imo falsely) implied my inferior understanding of this particular form of entertainment and of things that in no way concern the thread nor my entries. I've read your post a few more times now and I see now that although your post seemed insulting to me It was obviously not in your heart to mean harm and this is why I'm apologizing for my harsh reaction.
Peace out : I do sound cocky and arrogant and full of myself (because my smile and my heart do not show up on the web - just the words),
you're not wrong about the fact I can come across as disturbingly pompous (it never is my intent though), but what I really mean is :
"you're GOOD and we all KNOW since we have seen your interest for javascript
many times now with good to great results- I remeber some fractal explorer for example,
and I remember it off the top of my head. This is worthy of me trying to help you GET BETTER as much as I CAN."
This doesn't imply I am better than you at any given point - I may be more experienced but that's it.
I do not feel I am better than any of my human fellows - I feel human beings are amazing.
It's all cleared to me, really, but it still is a good chance for you, now that you found yourself enjoying the contest,
to really shine - you DO have all it takes, this never was a question to me.
So cheers, happiness, and let's all enjoy what comes next.