|
|
Author |
Thread |
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 02-03-2005 22:08
This month's theme is JavaScript ZOO.
yes, you read correctly. You can make some static/animated animals, a single kind or a real zoo, and you're free to let the visitors nurse or feed them if you want. I just want to see some animals this month.
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>
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.
Waf!!
|
kudos
Nervous Wreck (II) InmateFrom: Insane since: Dec 2004
|
posted 02-04-2005 15:38
wow..cool suggestion! A lot of ideas come to my mind!
|
GRUMBLE
Paranoid (IV) Mad ScientistFrom: Omicron Persei 8 Insane since: Oct 2000
|
posted 02-05-2005 13:56
cool topic.
im on to this!
|
TwoD
Nervous Wreck (II) InmateFrom: Sweden Insane since: Aug 2004
|
posted 02-05-2005 21:10
Interesting topic.
Would anyone mind if I re-entered the Fish AI I won with a while ago? I'd modify it for this theme of course.
I'll also try to avoid the 0*isNaN()s I had to put in to sqeeze it to 20 lines in FireFox.
/TwoD
|
Zyler
Obsessive-Compulsive (I) InmateFrom: Your imagination Insane since: Feb 2005
|
posted 02-08-2005 10:34
Ok I've never done much JS or entered one of these comp's but I was thinking of joining this one, just one question.
Does the 'animal' have to be interactive?
"Your imagination is the limit, unless of course, you have a limited mind" - Andy Esser, 2005
|
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 02-08-2005 12:45
TwoD: Well if your entry is not too similar to your previous Fish AI, it should be ok, otherwise it'd fall in the "no recycle" rule we see in the Monthly Sig Contests.
Zyler: No, it/they don't need to be interactive or animated. Of course if they are it certainly is more interesting and challenging to code.
|
TwoD
Nervous Wreck (II) InmateFrom: Sweden Insane since: Aug 2004
|
posted 02-09-2005 18:34
Poi: I was thinkin I would use the basics of it to create individual flocks of animals which would hunt eachother if you don't feed them etc. Not sure yet though...
/TwoD
|
BillyRayPreachersSon
Bipolar (III) InmateFrom: London Insane since: Jul 2004
|
posted 02-10-2005 05:30
A zoo was a tough call, given the 20-line limit, so I thought I'd limit the species to fish, and make an aquarium.
You can change the number of fish by modifying the value in line 10. I've used values between 1 and 75... anything over that and the tank gets far too crowded (someone call the RSPCA!
The fish are random each refresh (so random position, direction, and type). There are 8 different types of fish in total... but this could easily be increased just by adding more images, and changing the value in line 1 from 7 to (numImages-1).
It works in IE, Firefox, NN 7, and Opera 7... and probably Safari as well (although this has not been tested).
http://www.soterm.com/dan/aquarium.html
Very relaxing
Enjoy!
Dan
(Edited by BillyRayPreachersSon on 02-10-2005 05:30)
|
BillyRayPreachersSon
Bipolar (III) InmateFrom: London Insane since: Jul 2004
|
posted 02-10-2005 17:26
OK - I've modified it to have the animation as a prototyped method of the Fish object - slightly better programming practice
The fish now have a 0.5% chance of changing direction, and speding up / slowing down, so it doesn't look as cheesy as it did with fish just bouncing off the edges
Dan
|
TwoD
Nervous Wreck (II) InmateFrom: Sweden Insane since: Aug 2004
|
posted 02-11-2005 16:24
Nice aquarium BRPS!
It gave me a few ideas on how to improve performance of the Fish AI.
I just found out that I might not be able to make an entry this time either. Me and my classmates will be leaving for Belgium in 2 weeks and there are a lot of things to take care of before that. I'll make my best though!
/TwoD
|
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 02-11-2005 16:27
BillyRayPreachersSon: my mum has that aquarium screensaver on her computer
TwoD: quote: there are a lot of things to take care of before that
One of them being to make a 20 liner
|
BillyRayPreachersSon
Bipolar (III) InmateFrom: London Insane since: Jul 2004
|
posted 02-12-2005 10:47
quote: poi said:
BillyRayPreachersSon: my mum has that aquarium screensaver on her computer
Yeah - I searched around on Google's image search for aquarium and fish pics, and some guy had done a screengrab of the control panel for the screensaver showing all the fish. So I grabbed them, and spent a few hours cutting around them for the transparency.
BTW - I checked out your web page - good to meet another Atari fan, even if I was staunchly 8-bit (turbo charged 800XL with 256Kb RAM (woo!) and all the kit. I just couldn't be bothered downgrading to the ST
|
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 02-23-2005 23:10
*bump*
Ok, I'll try to make a script too. After all, this is me who asked to get the ZOO in town.
BillyRayPreachersSon: Among the 8bits Atari I've only had a 2600 for ~1 year But the demos on Atari XL blows me away. I'd really like to learn to code for these machines, but at the moment I'm into assembly 68000.
|
BabyJeffy
Obsessive-Compulsive (I) InmateFrom: London, England Insane since: Feb 2005
|
posted 02-25-2005 23:10
I took a slightly different approach to BRPS and went for a night time themed zoo. I've managed to get everything into 20 lines of code without too much fiddling too! The final page has been tested to work properly on:
- MacOSX - IE 5.2, Safari 1.2.4, Firefox 1
- Windows - IE 6, Firefox 1, Netscape 7
I couldn't get it to work on Opera... it doesn't throw an (obvious) error... it just doesn't work.
Maximise you browser window for best results:
- http://www.soterm.com/jeff/zoo.html
Enjoy,
Jeff
|
GRUMBLE
Paranoid (IV) Mad ScientistFrom: Omicron Persei 8 Insane since: Oct 2000
|
posted 03-01-2005 19:59
good stuff so far!
as for me, i promised an entry and its a halfway done tamagotchi, but since i still need a large number of graphics (animation frames) and there is a lack of motivation and time i wont participate. sorry.
again, i like the others so far. good choice of topic too!
so poi, whos the winner?
--
www.embege.com
|
wrayal
Bipolar (III) InmateFrom: Cranleigh, Surrey, England Insane since: May 2003
|
posted 03-01-2005 22:13
Oh, shit!!!
my thinking went something along the lines of "oh, it was the 28th of the month yesterdat it's the 29th today". God damn I'm stupid; sorry. I was going to make a moorhuhn clone. :/
oh well, there's always next month. and the next, and so on
Wrayal
My Website (finally! And yes, it uses frames and is evil, but, well, take a look, it's not as evil as you might think )
|
BillyRayPreachersSon
Bipolar (III) InmateFrom: London Insane since: Jul 2004
|
posted 03-01-2005 22:38
So next month's challenge could be a calendar reminder service then?
|
Iron Wallaby
Paranoid (IV) InmateFrom: USA Insane since: May 2004
|
posted 03-01-2005 23:20
Whoa... it's March.
o__o
I'll participate in 20 liners as soon as I can get around to building that stupid time machine...
---
"Consider a simple room with only four walls, a ceiling and a floor. Can you see it in your mind?s eye? You better not be able to; I haven?t specified a light source yet." - Paul Nettle
|
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 03-01-2005 23:53
|
wrayal
Bipolar (III) InmateFrom: Cranleigh, Surrey, England Insane since: May 2003
|
posted 03-02-2005 12:00
Congrtats to Baby Jeffy, and yes, welcome!!
Honestly, one day I will learn to read the date
Wrayal
My Website (finally! And yes, it uses frames and is evil, but, well, take a look, it's not as evil as you might think )
|
BabyJeffy
Obsessive-Compulsive (I) InmateFrom: London, England Insane since: Feb 2005
|
posted 03-02-2005 12:09
quote: poi said:
As he is a new comer and has posted nothing else but his script, we shouldn't exclude the possibility that he won't give a sign of life.
Oh ye have little faith I used to have an account here but it either expired or I just plain forgot my login - either way I'm all hooked back up now it looks like.
Thanks for the words of encouragement everyone... and I'll get thinking and try to come up with something worthwhile in the next day or so.
Cheers,
Jeff
|
poi
Paranoid (IV) InmateFrom: France Insane since: Jun 2002
|
posted 03-03-2005 11:53
As you can see we've sharpened our "new comers hooking methods". Shock therapy is still damn efficient too.
Do you remember your previous login here ?
(Edited by poi on 03-03-2005 12:01)
|
BabyJeffy
Obsessive-Compulsive (I) InmateFrom: London, England Insane since: Feb 2005
|
posted 03-04-2005 12:56
No idea poi... I'm not stressed about it... I don't think I even posted more than a few times regardless.
Jeff
|