@@ -240,6 +240,7 @@ def buttonbox(self):
240
240
keyEventContainer = eventContainer .EventContainer ()
241
241
242
242
# Mainloop
243
+ counterValue = 0
243
244
while projectRunning :
244
245
# Process Pygame events
245
246
for event in pygame .event .get ():
@@ -254,7 +255,6 @@ def buttonbox(self):
254
255
if event .type == pygame .KEYDOWN :
255
256
keyEventContainer .keyEvents .add (event .key )
256
257
print ("new key event" , time .time_ns ())
257
- print (keyEventContainer .keyEvents , "after populating in main.py" )
258
258
keysRaw = pygame .key .get_pressed ()
259
259
keyEventContainer .keys = set (k for k in scratch .KEY_MAPPING .values () if keysRaw [k ])
260
260
@@ -307,14 +307,13 @@ def buttonbox(self):
307
307
print (redrawMessage )
308
308
309
309
display .fill ((255 , 255 , 255 ))
310
- if toExecute :
311
- for block in toExecute :
312
- pass
313
310
if not isPaused :
311
+ print ("Starting frame at" , time .time_ns ())
314
312
for e in eventHandlers :
315
313
# TODO why does it run so many times???
316
- print ("running" , e .blockID )
317
314
if e .opcode == "event_whenkeypressed" and keyEventContainer .keyEvents and not e .blockRan :
315
+ print ("running" , e .blockID )
316
+
318
317
e .blockRan = True
319
318
nextBlock = scratch .execute (e , e .target .sprite , keyEventContainer )
320
319
if nextBlock and isinstance (nextBlock , list ):
@@ -344,6 +343,8 @@ def buttonbox(self):
344
343
block .executionTime , block .timeDelay = 0 , 0
345
344
if not block .blockRan and not block .opcode .startswith ("event" ): # TODO add broadcast blocks
346
345
nextBlock = scratch .execute (block , block .target .sprite , keyEventContainer )
346
+ if block .opcode == "looks_nextcostume" :
347
+ counterValue += 1
347
348
if not block .next \
348
349
and block .top \
349
350
and block .top .opcode .startswith ("event" ) \
@@ -368,6 +369,9 @@ def buttonbox(self):
368
369
allSprites .update ()
369
370
else :
370
371
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 ))
371
375
pygame .display .flip ()
372
376
mainWindow .update ()
373
377
doScreenRefresh = False
0 commit comments