Hey guys;
Just working through these tutorials again after some time away, thought it would be good to rebuild the projects again before moving on.
I was trying to watch then code (&peek); rather than code along this time which helps me learn but also helps me break things...
Having a weird issue with the snek game, I ended up building a constructor for the Location.cpp as I wasn't following exactly along with Chili's vid, but it looks like because of this I'm getting a body segment of the snake put at either the default (0,0) position for Loc or wherever I construct it too...
It's not a massive setback or anything just a curiosity, I'm having a hard time debugging it!
repo link:
https://github.com/SamuelLouisCampbell/ ... ng_Two.git
Trying the Snek game again, small issue.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Trying the Snek game again, small issue.
Your bug is here:
Code: Select all
void Snake::Draw(Board& brd)
{
for (int i = 0; i < segNo; i++)
{
segments[i].Draw(brd);
}
}
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Trying the Snek game again, small issue.
Some things that helped me realize where it was:
1. Moving over the affected block ( 2, 2 ) didn't cause a game over, so it is just a visual glitch.
2. Stepping through the update portion of the code, the head moved and no other segments were updated since I hadn't eaten a goal yet.
1. Moving over the affected block ( 2, 2 ) didn't cause a game over, so it is just a visual glitch.
2. Stepping through the update portion of the code, the head moved and no other segments were updated since I hadn't eaten a goal yet.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Trying the Snek game again, small issue.
Thanks once again albinopapa!
It was an issue with pre vs post incrementing, I think I can get my head around that.
Be back soon with many more questions no doubt, thanks for your time
It was an issue with pre vs post incrementing, I think I can get my head around that.
Be back soon with many more questions no doubt, thanks for your time
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Trying the Snek game again, small issue.
Lol, well I'm surprised that worked for you, because what I was actually pointing out was
for (int i = 0; i < segNo; i++)
probably should have been
for (int i = 0; i < segIndex; i++)
segNo is a constant 200 and you only want to iterate through the segments that are spawned.
for (int i = 0; i < segNo; i++)
probably should have been
for (int i = 0; i < segIndex; i++)
segNo is a constant 200 and you only want to iterate through the segments that are spawned.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Trying the Snek game again, small issue.
Whoops, no, you were right. I was changing two things before testing. Bad form!