Computer Science Canada

Snake - game - arrays - pretty fun

Author:  rhomer [ Sun May 30, 2004 1:14 pm ]
Post subject:  Snake - game - arrays - pretty fun

Hey this is my snake game... if anyone has any pointers feel free to submit them. I couldn't figure out how to make it so the snake keeps moving when no keys are pressed.

I moved the code down below

Author:  guruguru [ Sun May 30, 2004 2:14 pm ]
Post subject: 

Instead of having the buttons make you move, you should have the snkaes x or y value increase at the bottom of the loop. The keys would then change the direction of movement. Say the up arrow is pressed, movement is now up, so y is increased at the bottom of the loop. If the left arrow is presses, direction is left, and x increases at the bottom of the loop. Hope that helps.

Author:  Tony [ Sun May 30, 2004 3:10 pm ]
Post subject: 

what guruguru was trying to say is that you keep track of the last key pressed and if there're no keys pressed at the moment, you just continue to go in the direction the snake was moving last.

It's an interesting consept how snake retracts into itself when it stands still then stretches back as you start to move again. This would allow for a more complex gameplay but there should be some score tradeoff for standinf still too much.

the game is a bit buggy though. The snake seems to just die after I stop moving when it gets large enough. Also when I chose to "play again" it brings me back to the death screen.

but this game has quite a bit of potential at the moment. Try to compleat it and submit to [FP] contest by the end of school year.

Author:  rhomer [ Sun May 30, 2004 3:57 pm ]
Post subject: 

Ok....I took both of your suggestions and updated it and now it works better...Take a look:

Again i moved it below

Author:  Tony [ Sun May 30, 2004 7:37 pm ]
Post subject: 

nice, it's much better now

one more thing to implement - disallow moving backwards cuz that's a certain death move. So check that the input is not the oposite of the moving direction

Author:  guruguru [ Sun May 30, 2004 9:08 pm ]
Post subject: 

Wow that's pretty dang good now. Add in some powerups or walls or something cool like dat.

Tony: It does die when you go backwards!? Except when you are a single piece...

Author:  rhomer [ Sun May 30, 2004 10:04 pm ]
Post subject: 

Ok i have added in the option to have two players....

Again I moved it below

Author:  Tony [ Sun May 30, 2004 10:40 pm ]
Post subject: 

nice, though you can still kill yourself by going backwards.

and in 2 player you dont seem to be able to die by going though another snake (if you do, it would be kinda like thorn)

also - could you edit your posts and attach the code as a .t file? posts are getting kinda lengthy

Author:  rhomer [ Mon May 31, 2004 9:16 am ]
Post subject: 

Ok I have fixed it up a you will die if you go backwords, but not if your less then 3 pices

I have also made it so you will die if you run into the other person.

I have made it so you can choose how many squares you will start off with.


Author:  beard0 [ Tue Jun 01, 2004 10:36 am ]
Post subject: 

Nice game!
I was thinking of making a snake game a while back, but I didn't really know where to start. I'll be sure to take a close look at your code - the program is quite impressive.

Author:  rhomer [ Tue Jun 01, 2004 10:42 am ]
Post subject: 

Thanks...and i forgot to post my new version on this page. Here it is!...

Author:  SuperGenius [ Thu Jun 03, 2004 6:10 pm ]
Post subject: 

I got this error on line 71:

Cannot allocate item. Out of id numbers(max 1000)

Author:  anupalsingh [ Wed Jun 09, 2004 10:04 pm ]
Post subject: 

you guyz are all talking about the snake coding, but i dont see any. so how did you guyz play it??