Page 1 of 1

Snek Game

Posted: August 27th, 2017, 3:13 pm
by sheriff40
I have done the snek game upto the tutorial 14a. I tried debugging the code but couldn't get any solution. When i run the program, the screen just goes white. The snek game is not fully complete, but it's upto the point where you can actually move the snake and make it grow. here's the repository:
https://github.com/Sheriff40/GitSnek
thank you!! :D

Re: Snek Game

Posted: September 4th, 2017, 12:59 am
by jamesmfox
Welcome to PlanetChili. And to programming

I took a look at your code.
I am new to programming too so ya know still might not work :D
But i found a couple error in your typography

Code: Select all

// Snake.cpp
//In your Snake::Segment::InitHead()
Color c = HeadColor;

// Should be
c = HeadColor;

// And in your Snake::Draw()
for ( int i = 0; i < MaxSegments; i++)

// When you first draw your snake you dont have all of the segments location and color set up
// Should be
for (int i = 0; i < nsegments; i++)
One more

Code: Select all

//Location.h
//Location::Add()
//You are just setting the x and y to val.x and val.y
x = val.x;
y = val.y;

// Should be
x += val.x;
y += val.y;

Re: Snek Game

Posted: September 5th, 2017, 1:33 am
by chili
Seems like you had a few problems there. Thanks to james for sussing that stuff out!

Try these fixes first and see if that solves your shit. Otherwise update your repo and we'll take another look. Good job posting github btw, that's how you get help.