Set pixel in the world, not on the screen.

Post here to discuss all things DigiPixel related.

Moderators: Chuckt, Garth, bitfogav

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Wed Nov 25, 2015 5:58 pm

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!
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Wed Dec 02, 2015 7:16 pm

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

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Thu Jan 07, 2016 5:08 am

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...
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Thu Jan 07, 2016 6:40 am

No problem. We all get very busy now and again!

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Sun Mar 20, 2016 6:26 am

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!
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Sun Mar 20, 2016 11:54 am

No problem at all, I have projects that I started in 2013 that still aren't finished!

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Sun Jul 10, 2016 5:41 am

Life's crazy. I still don't know when I can get back to this. :C
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Mon Jul 11, 2016 8:08 pm

It's okay, We'll still be year for years to come :)

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Mon Dec 19, 2016 2:03 pm

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?
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Wed Dec 21, 2016 8:52 pm

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.

User avatar
ZephaniahNoah
semi-newbie
semi-newbie
Posts: 24
Joined: Wed Dec 31, 2014 7:17 am
Location: Milky Way, Earth
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by ZephaniahNoah » Wed Jan 04, 2017 11:55 am

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.
DigiPixel is AWESOME! Image

User avatar
brad
Site Admin
Site Admin
Posts: 2578
Joined: Fri Mar 26, 2010 10:30 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

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

Post by brad » Thu Jan 05, 2017 8:48 pm

I guess this is where backups come in handy :)

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 3 guests