Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Snake - game - arrays - pretty fun
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
rhomer




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
guruguru




PostPosted: Sun May 30, 2004 2:14 pm   Post subject: (No 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.
Tony




PostPosted: Sun May 30, 2004 3:10 pm   Post subject: (No 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rhomer




PostPosted: Sun May 30, 2004 3:57 pm   Post subject: (No subject)

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


Again i moved it below
Tony




PostPosted: Sun May 30, 2004 7:37 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
guruguru




PostPosted: Sun May 30, 2004 9:08 pm   Post subject: (No 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...
rhomer




PostPosted: Sun May 30, 2004 10:04 pm   Post subject: (No subject)

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

Again I moved it below
Tony




PostPosted: Sun May 30, 2004 10:40 pm   Post subject: (No 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
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
rhomer




PostPosted: Mon May 31, 2004 9:16 am   Post subject: (No subject)

Ok I have fixed it up a bit...now 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.

below
beard0




PostPosted: Tue Jun 01, 2004 10:36 am   Post subject: (No 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.
rhomer




PostPosted: Tue Jun 01, 2004 10:42 am   Post subject: (No subject)

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




PostPosted: Thu Jun 03, 2004 6:10 pm   Post subject: (No subject)

I got this error on line 71:

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




PostPosted: Wed Jun 09, 2004 10:04 pm   Post subject: (No subject)

you guyz are all talking about the snake coding, but i dont see any. so how did you guyz play it??
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: