Log In  

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?

P#58287 2018-10-23 11:57 ( Edited 2018-10-24 00:47)

Code ?

P#58290 2018-10-23 12:35 ( Edited 2018-10-23 16:35)

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.

P#58295 2018-10-23 13:51 ( Edited 2018-10-23 17:51)

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?

P#58302 2018-10-23 16:36 ( Edited 2018-10-23 20:36)

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!

P#58306 2018-10-23 20:47 ( Edited 2018-10-24 00:47)

[Please log in to post a comment]