Driftwood2D / Driftwood

Driftwood 2D Tiling Game Engine and Development Suite
http://tileengine.org/
MIT License
24 stars 1 forks source link

Clear every frame to black before drawing #84

Closed pmer closed 7 years ago

pmer commented 7 years ago

AreaManager._tick() is the first function called every frame in Driftwood's drawing process. If there's been a refocusing then AreaManager asks FrameManager to prepare a new frame. This new frame is black. Otherwise, the old frame is used and is not cleared, leaving garbage on-screen if the current draw does not overwrite every pixel.

We need to clear the frame really early in the drawing process, basically before AreaManager.__build_frame() is called since that's where we start copy()ing stuff.

This commit adds a FrameManager tick that is called before AreaManager's tick. All it does is clear the screen.

Fixes #75

pmer commented 7 years ago

I wasn't sure what self.__workspace was used for, specifically, so I just made clear() clear the self.__texture. Clearing either the texture or the workspace had the same effect as right now I think they refer to the same SDL2 texture object.

pmer commented 7 years ago

Just changed it to clear self.__workspace to be consistent with FrameManager.prepare().

pmer commented 7 years ago

Actually this is clearing the screen too often. We need to only clear the screen when we know that AreaManager is going to redraw it again.

pmer commented 7 years ago

Well, I didn't want to have to do this, but looks like AreaManager will be the one to ask for the screen to be cleared. It's the manager that knows when a new frame is going to be drawn for any particular tick. ("par-tick-ular tick?")

This removes the FrameManager tick that I described in the PR description above.