i need help for a snake game

Hi

i need help to develop a snake game for my scool project. i am copltely lost and dont know what to do. can one of you guys and girls help me pls?

Yes I can help.
I’m assuming you want the most bare bones version. Simple empty grid with a moving snake and a food pellet…

Can you create classes, use arrays, and compare values etc? Like how much do you know already?

first of all thank you for answering so quickly. and yes indeed i’m looking to make the most basic version possible. i have some basic programming knowledge (vb.net). the problem i’m facing is based on how to make the game more like the original. i have a working version but without borders and with major problems like the fact that it’s impossible to lose (i don’t know how to program that the snake “dies” when it touches its tail).

gotcha… Ok, so lets start with creating a death-state…

Create a variable called snake_alive or alive or whatever…
Look in your update code, where you get input for the snake, and update its position… Put all that code inside if (snake_alive == true)
{
right here…
}

This will stop the game from happening if the snake is dead… You can create a suicide button to kill the snake to test this code, you just toggle the snake_alive variable, and the snake-update-loop stops/starts… and then maybe create a button that resets the snake to start position and set the alive to true…

Once you have that, you can respawn and die, and we will setup other things to kill you.

yes indeed it seems logical. do you want me to give you access to my code? in my courses we use some strange packages

sorry I just did not get notification :slight_smile:

If you have a working version, but just need borders, just use an if statement to check the x and y coordinates of the head of the snake to see if they are outside the play area… If so, kill snake.

Like if x <= 0 kill snake; if x >=32 kill snake; and the same for y.
…Assuming you are using a grid…

If you are storing your snake body in an array, or list, you can just check the head position against each one using a foreach loop…

like pseudo code:
foreach (vector2 part_pos in snakeBody)
{
if (head_pos == part_pos)
{
kill_snek();
break;
}
}