[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
Brads Electronic Projects Forum • Set pixel in the world, not on the screen. - Page 3
Page 3 of 3

Re: Set pixel in the world, not on the screen.

Posted: Wed Nov 25, 2015 5:58 pm
by ZephaniahNoah
Ok. My game is almost done. But I wanted to talk about my method a little bit. Basically you have your pixel's coordinates, lets call them PixelX and PixelY, and you use setPixel to set it. But the coordinates need to keep updating based on the ScreenXOffset & ScreenYOffset. So we do this:

Code: Select all

digiPixel.setPixel(-ScreenXOffset+PixelX,-ScreenYOffset+PixelY,PixelColor);
Now, the screen offset variables are negative because of how the screen moves. If I were to leave them positive they would automatically move in the same direction as the player. (See below. Player=red Pixel=white)
Image
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)
Image
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)
Image
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.)
Image
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)
To remove the string of pixels I use the same concept, but for the X axis. Like this:

Code: Select all

if (ScreenXOffset > PixelX-8)
Because only one pixel in the string can be seen at a time none of the other pixels will be visable once setPixel is activated, hence killing the string. The number eight is used because the screen is eight pixels wide. The reason for this is... well I don't remember exactly. But it works! ;D I hope I explained myself in an understandable way. If you know what causes these glitches I would love to know!

Re: Set pixel in the world, not on the screen.

Posted: Wed Dec 02, 2015 7:16 pm
by brad
Sorry for the late reply and for the great write up and graphics!

Without looking into it into too much detail, I have had a similar problem with my super pixel bros game a couple of years ago. And it also seems that we both came up with the same solution to the problem - just make sure you draw that pixel when you know that it is in your visible screen area :)

Re: Set pixel in the world, not on the screen.

Posted: Thu Jan 07, 2016 5:08 am
by ZephaniahNoah
I am really sorry about this. We recently moved and there are a lot of crazy things going on. Don't expect the game anytime soon. :( sorry...

Re: Set pixel in the world, not on the screen.

Posted: Thu Jan 07, 2016 6:40 am
by brad
No problem. We all get very busy now and again!

Re: Set pixel in the world, not on the screen.

Posted: Sun Mar 20, 2016 6:26 am
by ZephaniahNoah
Just a little update... I'm still very busy, but I think I might be able to work on this again soon. Maybe not soon. But I will one day! I haven't forgotten!

Re: Set pixel in the world, not on the screen.

Posted: Sun Mar 20, 2016 11:54 am
by brad
No problem at all, I have projects that I started in 2013 that still aren't finished!

Re: Set pixel in the world, not on the screen.

Posted: Sun Jul 10, 2016 5:41 am
by ZephaniahNoah
Life's crazy. I still don't know when I can get back to this. :C

Re: Set pixel in the world, not on the screen.

Posted: Mon Jul 11, 2016 8:08 pm
by brad
It's okay, We'll still be year for years to come :)

Re: Set pixel in the world, not on the screen.

Posted: Mon Dec 19, 2016 2:03 pm
by ZephaniahNoah
Good news and bad news. First, I am able to finally continue work on this project and many others! Second, the bad news is that I am unable to access anything on my SSD. (But my HDD is fine lol. How is that possible.) So all I have is the file I uploaded to this thread. I'll have to redesign the map. Unless there is a way to convert that PROGMEM stuff back to png?

Re: Set pixel in the world, not on the screen.

Posted: Wed Dec 21, 2016 8:52 pm
by brad
Sorry for the late reply and welcome back :)

I am sure you could come up with some sort of macro that would scan through the progmem data and paint a picture for you to then save as a PNG, however making that work could very well take longer than remaking the map.

Re: Set pixel in the world, not on the screen.

Posted: Wed Jan 04, 2017 11:55 am
by ZephaniahNoah
Okey dokey then. I think I'll just redraw the map.
EDIT: I found a more recent backup of the program on a hard drive. I'll still have to re-draw the map though.

Re: Set pixel in the world, not on the screen.

Posted: Thu Jan 05, 2017 8:48 pm
by brad
I guess this is where backups come in handy :)