0

what can I do for making a snake game??

2nd Feb 2017, 12:11 PM
Shûbhãm ßìsht
Shûbhãm ßìsht - avatar
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.
2nd Feb 2017, 12:17 PM
jay
jay - avatar
2nd Feb 2017, 8:59 PM
jay
jay - avatar
+ 3
lazyfoo.net has tutorials on its usage. but serious.. wait till you learn more c++ you'll do much better that way
3rd Feb 2017, 12:50 AM
jay
jay - avatar
+ 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...
2nd Feb 2017, 1:03 PM
Thomas Sudeep Benardo
+ 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.
2nd Feb 2017, 12:15 PM
Thomas Sudeep Benardo
+ 1
SDL MEANS??
2nd Feb 2017, 2:48 PM
Shûbhãm ßìsht
Shûbhãm ßìsht - avatar
0
I'm not getting your point sir.... I have to make snake game ..give me a logic for that
2nd Feb 2017, 12:37 PM
Shûbhãm ßìsht
Shûbhãm ßìsht - avatar
0
how can I use it??? is it a software or compiler??
3rd Feb 2017, 12:41 AM
Shûbhãm ßìsht
Shûbhãm ßìsht - avatar