Re: Mode 3 Scrolling Game Engine Demo (WIP)
Posted: Sat Jan 14, 2023 8:06 am
I think it's the little details that matter.
While the unicorn is alive, I want it to be drawn on top of all the other sprites, so for instance the fart spray gets drawn on top of the enemies when attacking them, and well it's the main character so it is important for it to be seen. However when it dies, I want all of the other sprites to be drawn on top of the unicorn, so if it gets killed by a falling spike, the spike is not completely hidden, and instead it looks like the unicorn is being stabbed by the spike. (Or maybe I want killer butterflies to munch on its corpse.)
To keep the unicorn drawn on top of the rest of the sprites, I made sure to use the highest numbered sprites, and then I assigned sprites to the active enemies starting at sprite 0, and ending before the dedicated unicorn sprites.
Getting those to swap places at runtime, and work correctly was a bit tricky to pull off, and I wanted to verify that there weren't any glitches during that transition. It turned out there was a glitch where the unicorn was drawn twice on top of each other, once upside down and again right side up for a single frame (because I forgot to turn off the old sprites during the switchover) but I couldn't actually see it while playing the game because it happened only for a single frame.
Unfortunately single-stepping in cuzebox doesn't always advance by a single video frame, so the best way I found to truly see anything frame by frame at 60fps is to tell cuzebox to record a video and then convert it to a series of PNG files and then step through those with an image viewer program, because that allows you to go back and forward in time easily.
After fixing my glitch, you can now see the transition for the Z-order swap happens at the exact instant the unicorn dies. (Again, the hitbox for enemies is a bit smaller than the actual object to make things feel more fair, which is why the unicorn doesn't die until the spike is well into it.)
The above animated GIF created by recording the inputs in cuzebox, then playing the input recording back while telling cuzebox to record a video, then running the following commands to convert the video recording to a series of PNG files (takes up a lot of space!) and then making an animated gif of the frames I wanted, and then cropping that animated gif:
While the unicorn is alive, I want it to be drawn on top of all the other sprites, so for instance the fart spray gets drawn on top of the enemies when attacking them, and well it's the main character so it is important for it to be seen. However when it dies, I want all of the other sprites to be drawn on top of the unicorn, so if it gets killed by a falling spike, the spike is not completely hidden, and instead it looks like the unicorn is being stabbed by the spike. (Or maybe I want killer butterflies to munch on its corpse.)
To keep the unicorn drawn on top of the rest of the sprites, I made sure to use the highest numbered sprites, and then I assigned sprites to the active enemies starting at sprite 0, and ending before the dedicated unicorn sprites.
Getting those to swap places at runtime, and work correctly was a bit tricky to pull off, and I wanted to verify that there weren't any glitches during that transition. It turned out there was a glitch where the unicorn was drawn twice on top of each other, once upside down and again right side up for a single frame (because I forgot to turn off the old sprites during the switchover) but I couldn't actually see it while playing the game because it happened only for a single frame.
Unfortunately single-stepping in cuzebox doesn't always advance by a single video frame, so the best way I found to truly see anything frame by frame at 60fps is to tell cuzebox to record a video and then convert it to a series of PNG files and then step through those with an image viewer program, because that allows you to go back and forward in time easily.
After fixing my glitch, you can now see the transition for the Z-order swap happens at the exact instant the unicorn dies. (Again, the hitbox for enemies is a bit smaller than the actual object to make things feel more fair, which is why the unicorn doesn't die until the spike is well into it.)
The above animated GIF created by recording the inputs in cuzebox, then playing the input recording back while telling cuzebox to record a video, then running the following commands to convert the video recording to a series of PNG files (takes up a lot of space!) and then making an animated gif of the frames I wanted, and then cropping that animated gif:
Code: Select all
ffmpeg -i capture.mp4 -vf fps=60 out%04d.png
convert -delay 33 -loop 0 out0{356..385}.png spike.gif
convert spike.gif -coalesce -repage 0x0 -crop 256x256+275+134 +repage output.gif