Help me by playing with my Snake!

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
YoMomIsANiceLady
Posts: 33
Joined: February 2nd, 2017, 8:20 am

Help me by playing with my Snake!

Post by YoMomIsANiceLady » February 27th, 2017, 8:35 am

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!

Basically what I would like you to do is
Step 1: Play my game!
- Git: https://github.com/BenjaminKorady/Class ... -1997-.git
- or you can just download the .exe: https://drive.google.com/open?id=0B-IrF ... UhwMkhxa3M

Step 2: Play some more!

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).

CODE:
Spoiler:

Code: Select all

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

Snake with segment spacing fill:
http://i.imgur.com/FEP30q6.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č

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Help me by playing with my Snake!

Post by chili » February 28th, 2017, 1:00 pm

Lol, could not reproduce.

Just call it an easter egg ;)
Chili

User avatar
YoMomIsANiceLady
Posts: 33
Joined: February 2nd, 2017, 8:20 am

Re: Help me by playing with my Snake!

Post by YoMomIsANiceLady » March 2nd, 2017, 7:40 am

Image
"Life is like death, but completely different"
- Ivan Gašparovič

User avatar
BurakCanik
Posts: 250
Joined: February 8th, 2014, 9:16 pm
Location: Istanbul, Turkey

Re: Help me by playing with my Snake!

Post by BurakCanik » March 3rd, 2017, 3:10 pm

That is one kinky thread title.
If real is what you can feel, smell, taste and see, then 'real' is simply electrical signals interpreted by your brain" - Morpheus

User avatar
BurakCanik
Posts: 250
Joined: February 8th, 2014, 9:16 pm
Location: Istanbul, Turkey

Re: Help me by playing with my Snake!

Post by BurakCanik » March 3rd, 2017, 3:46 pm

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

Post Reply