Code: Select all
digiPixel.setPixel(-ScreenXOffset+PixelX,-ScreenYOffset+PixelY,PixelColor);
But the world isn't supposed to move with the player. It should scroll left when we walk right, and up when we go down, etcetera. (See below. Player=red Pixel=white)
So in this case we want the variables to be negative. But there's a couple of glitches that happen using this method.
1st, when I move off the screen to the left, right, or down, the pixel moves off the screen as expected. But when I move the player up the pixel sticks to the bottom of the screen. (See below. Player=red Pixel=white)
2nd, on the left it creates a string of pixels. Each with seven (7) spaces between them. Because of this, only one of the pixels in the string can be seen at a time. (See below. Player not present. Pixel specified.)
This is what I used to test the player's Y position so that it will only set the pixel when the player is in that area, hence stopping the sticking.
Code: Select all
if (ScreenYOffset-PixelY < 1)
Code: Select all
if (ScreenXOffset > PixelX-8)