0
what can I do for making a snake game??
8 odpowiedzi
+ 3
study more c++ first though. you will need to understand classes, arrays and pointers as a bare minimum before you jump into SDL.
+ 3
lazyfoo.net has tutorials on its usage. but serious.. wait till you learn more c++ you'll do much better that way
+ 2
I hope you are familiar with lists, a list can hold undefined number of data. I will not recommend to write a snake game in c++ as beginner, I had a hard time writing one in Python and pygame.
Anyways, If you want to write on in c++, use vector -
#include <vector>
struct Point
{
int x;
int y;
};
vector<Point> snakeBody;
Now, let's start with the snakes size as 4, I.e. the snake will be 4 pixels long in the starting, assuming window resolution as 640x480 Then we can write -
for(int i = 238; i<=242; i++) {
Point point;
point.x = 320;
point.y = i;
snakeBody.push_bash(point);
}
now, you can easily update the vector by looping through the Point structs and changing the x and y valus, you can delete the last Point in the vector by using
PS: will complete this post soon...
+ 1
start with SDL, for the snake's body, store the x and y coordinates in a list and whenever It is time to draw the snake, iterate through the list and draw the snake pixel by pixel, as the snake advances, add the new x and y coordinates in front of the list and delete the last x and y coordinate.
+ 1
SDL MEANS??
0
I'm not getting your point sir....
I have to make snake game ..give me a logic for that
0
how can I use it??? is it a software or compiler??