Idea about Snakes game

I want to make snakes game using structures and 2D array , I am confused how to use Structures in this game . I want idea about this . Please help me , I will be grateful .

Regards ,
Ahmad
you can create a structure for food , and special food.
so normal food would give +1 point ... and special food would give +5 or +10 points ...

1
2
3
4
5
struct food
{
int points = 1 ; /*this will be how many points you will get by eating the food*/
int x , y; /*the coords of the food , where they are gonna appear on the map*/
}

1
2
3
4
5
struct specialFood
{
int points = 5 ;
int x, y ;
}

1
2
3
4
5
6
7
8
struct Snake
{
int length ; //the length of the snake
int x, y ; //the coords on the map
int score ; //the score
int speed ; //the speed of the snake
int lives ;//lives left
}


hope this helps
do you know about structs? if you do not really know about structs how are you going to make a game? there are simpler games that are not live action which you can create without a GUI, which involves knowing how to do generally use.

if you do know about all that then i would suggest classes, because you can have all your variables and functions in them and throw them all into header file.
Yes I know about structures , I have not studied classes yet , but the thing which is confusing is that how to move snake , I mean if snake is going towards right and user press up button then in this case how we will control movement of the Snake and secondly how can I move the pixels of screen as in case of Snakes game , I want pixels to move . Another method is to do increase or decrease Rows and Column of 2D array and use system ("cls"); but in this case screen will start blinking which will not look good , so how can we move pixels ?
I guess we have to use gotoxy ?

you are not at classes and you want to make a live action game. once you learn classes doing this will be a lot easier. but if you are not even there you will not be able to actually do this.
Last edited on
Topic archived. No new replies allowed.