@@ -240,6 +240,7 @@ def buttonbox(self):
240240keyEventContainer = eventContainer .EventContainer ()
241241
242242# Mainloop
243+ counterValue = 0
243244while projectRunning :
244245 # Process Pygame events
245246 for event in pygame .event .get ():
@@ -254,7 +255,6 @@ def buttonbox(self):
254255 if event .type == pygame .KEYDOWN :
255256 keyEventContainer .keyEvents .add (event .key )
256257 print ("new key event" , time .time_ns ())
257- print (keyEventContainer .keyEvents , "after populating in main.py" )
258258 keysRaw = pygame .key .get_pressed ()
259259 keyEventContainer .keys = set (k for k in scratch .KEY_MAPPING .values () if keysRaw [k ])
260260
@@ -307,14 +307,13 @@ def buttonbox(self):
307307 print (redrawMessage )
308308
309309 display .fill ((255 , 255 , 255 ))
310- if toExecute :
311- for block in toExecute :
312- pass
313310 if not isPaused :
311+ print ("Starting frame at" , time .time_ns ())
314312 for e in eventHandlers :
315313 # TODO why does it run so many times???
316- print ("running" , e .blockID )
317314 if e .opcode == "event_whenkeypressed" and keyEventContainer .keyEvents and not e .blockRan :
315+ print ("running" , e .blockID )
316+
318317 e .blockRan = True
319318 nextBlock = scratch .execute (e , e .target .sprite , keyEventContainer )
320319 if nextBlock and isinstance (nextBlock , list ):
@@ -344,6 +343,8 @@ def buttonbox(self):
344343 block .executionTime , block .timeDelay = 0 , 0
345344 if not block .blockRan and not block .opcode .startswith ("event" ): # TODO add broadcast blocks
346345 nextBlock = scratch .execute (block , block .target .sprite , keyEventContainer )
346+ if block .opcode == "looks_nextcostume" :
347+ counterValue += 1
347348 if not block .next \
348349 and block .top \
349350 and block .top .opcode .startswith ("event" ) \
@@ -368,6 +369,9 @@ def buttonbox(self):
368369 allSprites .update ()
369370 else :
370371 display .blit (paused , (WIDTH // 2 - pausedWidth // 2 , WIDTH // 2 - pausedHeight // 2 ))
372+
373+ counter = font .render (str (counterValue ), True , (0 , 0 , 128 ))
374+ display .blit (counter , (WIDTH // 2 - pausedWidth // 2 , WIDTH // 2 - pausedHeight // 2 ))
371375 pygame .display .flip ()
372376 mainWindow .update ()
373377 doScreenRefresh = False
0 commit comments