Snake Game problem's

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Snake Game problem's

Post by Jinx93 on Thu Oct 20, 2011 5:37 pm
([msg=62480]see Snake Game problem's[/msg])

Hey, I’m new to hack this site... And was wondering if anyone could help me? For my computing Class we were asked to code using Windows forms, the old Nokia Snake game, so far I have managed to get the snake to draw I can move it around the screen I’ve also got the ‘treasure’ to appear and when ‘eaten’ reappear on a different part of the screen, but I’ve came across two problems 1) if the snake goes outside of the boundaries how do I get it to appear on the opposite side? 2) How do I get the snake to grow...? If anyone has any suggestions I would love to hear them since I’ve been slamming my head on the desk for the past two days…

Cheers Jinx
Jinx93
New User
New User
 
Posts: 2
Joined: Thu Oct 20, 2011 5:21 pm
Blog: View Blog (0)


Re: Snake Game problem's

Post by hellow533 on Thu Oct 20, 2011 5:53 pm
([msg=62481]see Re: Snake Game problem's[/msg])

Set a value to the treasure, and when the snake eats the treasure, have the value of his length increase by the value of the treasure, say 1 for instance.

Also, make the boundaries kill the snake if it hits them, that's how it worked right?
“True hacking is like skydiving, you want to make sure you have arms, because nobody’s going to be there to pull the chute for you.”
User avatar
hellow533
Poster
Poster
 
Posts: 486
Joined: Thu Jan 29, 2009 3:27 pm
Blog: View Blog (0)


Re: Snake Game problem's

Post by Jinx93 on Thu Oct 20, 2011 5:58 pm
([msg=62482]see Re: Snake Game problem's[/msg])

hellow533 wrote:Set a value to the treasure, and when the snake eats the treasure, have the value of his length increase by the value of the treasure, say 1 for instance.

Also, make the boundaries kill the snake if it hits them, that's how it worked right?


ive tried the increase length, but when it came to redrawing it when moving the head went that direction and the body kept going :S
not ther versian that i was going for but.. it will work! :) cheers!
Jinx93
New User
New User
 
Posts: 2
Joined: Thu Oct 20, 2011 5:21 pm
Blog: View Blog (0)


Re: Snake Game problem's

Post by whizz_kidd on Thu Oct 20, 2011 8:53 pm
([msg=62484]see Re: Snake Game problem's[/msg])

I'm pretty sure the way you can do that is just to move the head without moving the tail for one or more turns. BAM! Length has increased by however many turns you skipped in this way.
whizz_kidd
New User
New User
 
Posts: 7
Joined: Thu Jun 23, 2011 1:36 am
Blog: View Blog (0)


Re: Snake Game problem's

Post by Muskelmann098 on Fri Nov 04, 2011 1:17 pm
([msg=62774]see Re: Snake Game problem's[/msg])

How about using an array to contain each segment of the snake. You could then add an element to the array when the food has been eaten.
Muskelmann098
Experienced User
Experienced User
 
Posts: 78
Joined: Mon Feb 02, 2009 9:39 am
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests