I'm having trouble getting rid of a graphical glitch in a game I'm working on.
When the player dies, the game state switches from the main gameplay screen to an intermediate screen that waits for a keypress before returning to the main gameplay screen. If that doesn't make sense, it's similar to Super Mario Bros.; when Mario dies, the main gameplay screen is replaced by a black screen that shows lives remaining, then after a short time returns to the main gameplay screen.
The glitch happens at this return to the main gameplay screen. Before the first frame is drawn, the screen flashes with what appears to be the last frame drawn to the main gameplay screen before it changed to the intermediate screen. Is this the back buffer? It seems like it shouldn't be, because I'm drawing other stuff on the intermediate screen. Is there something else that could be saving the last frame drawn?
I'm running at 60fps and using cls() at the beginning of each _draw() call. The draw operations for each game state are called from within _draw() based on the current game state.
I found the following in the manual: "If your program does not call flip before a frame is up, and a _draw() callback is not in progress, the current contents of the back buffer are copied to screen." Might this have something to do with it?
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/17143/wqrnpdxjvdcr1mn0xre2_400x400.png)
It shouldn't be doing that.
I have a sneaking suspicion that you'll find you're switching back to your in-game draw routine BEFORE you reset your game data.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/29213/tobias_pico8.png)
No, it can't be the back buffer in this situation. As you say, you're drawing other stuff.
Probably best to show the code, but apLundell is probably right. Sounds like _draw() has time to run for one frame with the old contents. What does your mode/state system look like?
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/12505/be.png)
Ugh, I'm an idiot. I had a call to camera() in the main update cycle, a remnant from before I broke the update cycle out into game states. So it wasn't a buffer issue (obviously), but a shift in the camera offset for one frame.
Sorry to waste your time. Nevertheless, I found the problem while looking for relevant code to post, so thanks for steering me in the right direction!
[Please log in to post a comment]