Snake Game - NEED HELP
Author |
Message |
shab257
|
Posted: Thu May 01, 2008 8:05 am Post subject: Snake Game - NEED HELP |
|
|
I need help, I need a snake game for grade 10 computer science class. Please Help.
It needs to have 3 levels, use the arrows keys to move, snake gets bigger with every apple, apples to be coloured and using graphics and animation.
Please and Thank you. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Expirant
|
Posted: Thu May 01, 2008 9:00 am Post subject: Re: Snake Game - NEED HELP |
|
|
Well, to do this well you will need some knowledge of arrays, if statements, and loops (among other things). If you don't understand these, there are very well written tutorials on this very website( ) to guide you. Here is a pseudo-example of what I would do.
code: |
var Apples : array 1 .. 20 /* So we have twenty apples on screen. I would make these a record with x and y as fields to represent the apple's coordinate on screen */
var SnakeX, SnakeY, SnakeSize : int /* If the screen is a coordinate plane (QI) then the snake can be represented at point (x,y) and can be a circle/box whatever that is SnakeSize big */
loop
if Player presses up arrow then
SnakeY increases by one (move the snake towards the top of the screen)
elsif Player presses down arrow then
SnakeY decreases by one
elsif Player presses left arrow then
SnakeX decreases by one (move the snake towards the left side of the screen)
elsif Player presses right arrow then
SnakeX increases by one
end if
/*Now that the snake has moved, go through the list of apples and check if the snake has collided with any of them. Again, see the collision tutorial if you don't know how to do this. If the snake has collided with an apple, increase the snake's size variable by an arbitrary amount, then regenerate the apple somewhere else*/
for i : 1 .. upper (Apples)
if collision then
regenerate apple somewhere else
SnakeSize += 1
end if
end for
DrawSnake
DrawApples
end loop
|
Again, this is not actual code. This is supposed to give you an idea where to start. Look up the appropriate tutorials, read through them and understand them, and this should be a piece of cake.
Good luck,
Expirant |
|
|
|
|
![](images/spacer.gif) |
shab257
|
Posted: Thu May 01, 2008 2:24 pm Post subject: RE:Snake Game - NEED HELP |
|
|
ty very much |
|
|
|
|
![](images/spacer.gif) |
|
|