Hey there guys. So I created the Classic Snake Game and I have one tiiiiiny problem that I'd like to get resolved. It's a small graphical glitch that happens sometimes and I have no idea why or when it happens. Happens only very rarely on snake change direction and stays there until direction is changed again. It happens so rarely that I couldn't even manage to take a screenshot of it. If I do, I'll post it here!
Step 3: Let me know if you see anything unusual!
The issue that I found is that sometimes 3 random pixels appear next to the snake's head when they shouldn't. The issue could possibly be in Snake.cpp file, in the Snake::Segment::draw() method (Line 260).
const int pixelSpacing = 1;
// Draws the 3x3 large pixel segment
for (int i = 0; i < Board::CELL_SIZE; ++i) {
for (int j = 0; j < Board::CELL_SIZE; ++j) {
brd.drawPixel({loc.x+i, loc.y+j}, pixelSpacing);
}
}
// Draws the spacing between the segments
if (next.exists) {
for (int j = 0; j < Board::CELL_SIZE; ++j) {
// next segment is to the right
if(next.loc.x - loc.x == Board::CELL_INC_OFFSET)
brd.drawPixel({ loc.x + Board::CELL_SIZE, loc.y + j }, pixelSpacing);
// next segment is to the left
else if(next.loc.x - loc.x == - Board::CELL_INC_OFFSET)
brd.drawPixel({ loc.x - Board::CELL_LARGE_PIXEL_OFFSET, loc.y + j }, pixelSpacing);
// next segment is below
if (next.loc.y - loc.y == Board::CELL_INC_OFFSET)
brd.drawPixel({ loc.x + j, loc.y + Board::CELL_SIZE }, pixelSpacing);
// next segment is above
else if (next.loc.y - loc.y == - Board::CELL_INC_OFFSET)
brd.drawPixel({ loc.x + j, loc.y - Board::CELL_LARGE_PIXEL_OFFSET }, pixelSpacing);
}
}
To understand what I mean by the spacing between the segments:
Snake without segment spacing fill: http://i.imgur.com/NoEEl4J.png
Seems like the 3 spacing pixels sometimes appear where they shouldn't. This happens REALLY rarely and it hasn't happened to me in a week (I thought i had resolved the issue) but then appeared again yesterday. So I dunno!
Besides you can also share your best scores! (My highest is 306! Ba-guette on my level)
"Life is like death, but completely different"
- Ivan Gašparovič
Snake's speed is giving me cancer! I didn't have much time so I couldn't play for long, will give it a go again later.
By the way, maybe you've tried it already but if you are suspecting that segment spacing fill is the cause of said bug here, I suggest drawing those filling pixels in a different (and eye catching) color. Makes it easier to spot/debug it.
If real is what you can feel, smell, taste and see, then 'real' is simply electrical signals interpreted by your brain" - Morpheus