@@ -77,6 +77,7 @@ def reinit_screen(self):
77
77
w = getattr (mod , 'WIDTH' , 800 )
78
78
h = getattr (mod , 'HEIGHT' , 600 )
79
79
if w != self .width or h != self .height :
80
+ self .need_redraw = True
80
81
self .screen = pygame .display .set_mode ((w , h ), DISPLAY_FLAGS )
81
82
if hasattr (self .mod , 'screen' ):
82
83
self .mod .screen .surface = self .screen
@@ -199,9 +200,13 @@ def get_update_func(self):
199
200
except AttributeError :
200
201
return None
201
202
else :
202
- if update .__code__ .co_argcount == 0 :
203
- return lambda dt : update ()
204
- return update
203
+ def update_wrapper (dt ):
204
+ if update .__code__ .co_argcount == 0 :
205
+ update ()
206
+ else :
207
+ update (dt )
208
+ self .need_redraw = True
209
+ return update_wrapper
205
210
206
211
def get_draw_func (self ):
207
212
"""Get a draw function.
@@ -250,7 +255,7 @@ def mainloop(self):
250
255
251
256
pgzclock = pgzero .clock .clock
252
257
253
- self .need_redraw = not paused
258
+ self .need_redraw = True
254
259
while True :
255
260
# TODO: Use asyncio.sleep() for frame delay if accurate enough
256
261
yield from asyncio .sleep (0 )
@@ -268,13 +273,15 @@ def mainloop(self):
268
273
self .keyboard ._release (event .key )
269
274
self .dispatch_event (event )
270
275
271
-
272
- if update and not paused :
276
+ if not paused :
273
277
pgzclock .tick (dt )
274
- update (dt )
278
+
279
+ if update :
280
+ update (dt )
281
+
275
282
276
283
screen_change = self .reinit_screen ()
277
- if screen_change or update or pgzclock .fired or self .need_redraw :
284
+ if pgzclock .fired or self .need_redraw :
278
285
draw ()
279
286
pygame .display .flip ()
280
287
self .need_redraw = False
0 commit comments