Hi guys. I am beginner at developing and currently learning c#. I was asked for developing a console based snake game by my knowlage of c#. So i have to develop the game by using classes( not structs etc) arrays methods..

I can use any ideas on that matter.

3 Years
Discussion Span
Last Post by hasan bahadır

First setup an array. 20x20 is a good size, but you can go bigger.
Create a set of snake object. Give the snakes locations on the array.
Give the snakes each initial directions. It might help if they were all set on a different side of a wall, and have them move inward away from the wall.

In your main loop
Check for user input.
Adjust player snake's direction.
Process a simple decision making function for the computer snakes:
Something in my way? Check which way is clear, and move in that direction.
Going to crash anyway? OK, snake dies.
Player snake dead? Game over.
Advance each living snake one space.
Clear the screen.
Draw the grid on the screen.
Put in small pause to make the game play-able. You'll be dead in milliseconds otherwise.


Okay, i got a new problem. I can draw the snake and move it with arrow keys. But i cant figure out the constant moving part. Any thoughts?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.