Skip to main content
gamedev.net
🔒 Locked

Javascript can be fun! Part Trois...

Started by Coward 30 replies 2.3k views
Original Post
Coward
Coward
Writing simple games in &#106avascript has always been a fetish of mine. The last one I actualy decided to tell you guys about was my tetris clone. Anyway, to make a long story short: I was bored today. So I decided to sit down and write a Snake Clone in &#106avascript. It's something I've done before but I lost the files from my last time. I'm not that fond of the result as of this time - my last version had up to four players and levels. But in this &#111;ne the graphics are more than just squares. (My paint skills rules!) Suggest a feature, report a bug and comment all you want: <a href="http://www.humblesiden.dk/kasper/snake.html">Clicky</a>
Don't Temp Fate..
Extrarius
Extrarius
I open the page to get a frame and some buttons. I click start and a flowery thing appears and 99% of the time it then says 'Game Over'. The other 1% of the time it displays some snake segments (and once ina while a head) and nothing happens[ie it doesn't move, arrow keys etc don't have any effect].
??
Hrmm, I guess it moves too fast, but it never displays the snake at all until several seconds after I've died (by which time I was clicking start again).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
baddogj
baddogj
Its not bad, but i thinkk you should give the player a bit of time after pressing start so that they can reach the keys before crashing into the wall. I had a bit of trouble and kept dying.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/
Coward
Coward
Quote:
Original post by Extrarius
I open the page to get a frame and some buttons. I click start and a flowery thing appears and 99% of the time it then says 'Game Over'. The other 1% of the time it displays some snake segments (and once ina while a head) and nothing happens[ie it doesn't move, arrow keys etc don't have any effect].
??

Weird. Are you on a very slow connection? (Maybe the pictures didn't load before you started?) And what browser?

Uh, and if it's too fast, you should choose a lower skill level [wink]
Don't Temp Fate..
Extrarius
Extrarius
I'm using IE on a 3Mb connection, so the pictures shouldn't be taking any time at all to load (unless they're 1600*1200*32 bit color bitmaps shrunk down using size attribs or something like that)
Setting on a lower skill (1-3) makes it playable, but it really looks bad because the images take forever to show up and then they update very slowly so for ex it looks like there are 2 head segments 99% of the time, and often there will be a disconnected tail segment that is 2-3 'tiles' behind the snake that moves as part of the snake (like there are 2-3 invisible segments or something)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
benryves
benryves
Quote:
Original post by Coward
Uh, and if it's too fast, you should choose a lower skill level [wink]


I had to view source to see that the skill level was actually a text box! Make that more obvious...
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
Coward
Coward
Thanks for the comments - keep em comming.

Slowed it down and made a 1 second delay before starting..
Don't Temp Fate..
baddogj
baddogj
Quote:
Original post by benryves
Fast, but very cool [wink]
Still, I have to repost my own JS skillz...


Thats really cool. id never be able to do something like that.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/
Extrarius
Extrarius
It seems like every time an image changes, the images is redownloaded (which takes a small fraction of a sec from overhead). In your tetris game, as soon as I click start, IE starts downloading 300+ items, and it seems to constantly be downloading while snake is going
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
baddogj
baddogj
I don't know why but there have been quite a lot of instances where i would get game over befor the snake even starts moving.
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="88" height="70" id="H2lvl" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="http://www.ironhive.com/CFCs/H2lvl.swf?gamertag=jBaddog" /> <param name="quality" value="high" /> <param name="wmode" value="transparent"> <embed src="http://www.ironhive.com/CFCs/
Coward
Coward
Quote:
Original post by Extrarius
It seems like every time an image changes, the images is redownloaded (which takes a small fraction of a sec from overhead). In your tetris game, as soon as I click start, IE starts downloading 300+ items, and it seems to constantly be downloading while snake is going

That's extremely weird, what version of IE are you using?
Don't Temp Fate..
Extrarius
Extrarius
I'm using the latest version of IE on WinXP Pro w/ SP2

Edit: Fix it. Had to change "Check for newer versions of stored pages" from "Every visit to the page" to "Automatically". Not sure why, because its never caused problems with anything else. It'd be great if you could find a way around that because the auto setting doesn't work very well IME.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Coward
Coward
Ok, I deleted my cache and tried playing it in IE, and I saw some minor problems that looks what your describing. So I added image preloading. Is it better now?
Don't Temp Fate..
Extrarius
Extrarius
It is fixed, but only when I set to auto as I said (I tested setting it back to see if it was preloading that fixed it and it was not).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
choffstein
choffstein
Bug!
When you get your snake equal length to itself, so that it looks like this:

hoooootooooo


Where "h" is the head and "t" is the tail, and you press "down," you die. However, you shouldn't die, because by the time your head gets there, your tail should have moved into the next spot, right? :)


Very nice though!
Coward
Coward
Quote:
Original post by Extrarius
It is fixed, but only when I set to auto as I said (I tested setting it back to see if it was preloading that fixed it and it was not).

Ok, it now actualy uses the preloaded images when it updates an image. Try one last time, if it doens't work now, I don't know how to make it work.. [sad]
Don't Temp Fate..
Extrarius
Extrarius
Nope, it didn't fix the problem =-/
Oh well, still a very nice game =-) Would be neat if you could make it like the QB version that has levels and lives and such too =-)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.