That said, I've been stuck for countless hours trying to implement a feature that at first seemed simple enough. My goal was to make the snake grow more than a single segment at a time when eating. I got it working by naively just changing the Grow() function to increase nSegments by 3. This worked on the surface, except for the fact that while new segments are being added, a single segment is also drawn slightly outside of the top left corner of the board. I think the problem lies in the way Snake::MoveBy() is implemented and the fact that the new segments don't get assigned valid locs before they are drawn, but i can't for the life of me come up with a working solution. I've been banging my head against this for 3 days now trying all sorts of wacky things and bumbling around with the debugger but I'm still completely stumped. Any guidance would be greatly appreciated.
Also as a sort of bonus bug, if anyone has the time, in Board::DrawBorder() i needed to add 1 to
width in this line:
Code: Select all
const int right = left + (borderPadding + borderWidth) * 2 + (width + 1) * dimension;
Anyways, sorry this got a bit long winded, and thank you in advance to any kind souls who might offer up some of their time and knowledge. And to chili, your tutorials are honestly the best learning tool I've found and your presentation style makes them even better. Please keep em comin!
My git repo for snek.
https://github.com/FatteusHornblow/Snek ... HomeWork17