Skip to content

Commit 1d9edac

Browse files
committed
Finally!!!!!!!!!
1 parent 88bd8ca commit 1d9edac

File tree

6 files changed

+20
-103
lines changed

6 files changed

+20
-103
lines changed

assets/87e963282db9e020e8c4d075891ea12b.svg

Lines changed: 0 additions & 95 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Loading

assets/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#Fk?(8x)AV.-my variable":["variabila mea",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"87e963282db9e020e8c4d075891ea12b","name":"Rays","bitmapResolution":1,"dataFormat":"svg","rotationCenterX":240.1199951171875,"rotationCenterY":180}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":44100,"sampleCount":1032,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Personaj1","variables":{},"lists":{},"broadcasts":{},"blocks":{"KJ*~ja{K12RKNMN(*}8`":{"opcode":"event_whenflagclicked","next":"ocpvrg]:AlBO|pm)r_HU","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":34,"y":65},"ocpvrg]:AlBO|pm)r_HU":{"opcode":"motion_gotoxy","next":null,"parent":"KJ*~ja{K12RKNMN(*}8`","inputs":{"X":[1,[4,"100"]],"Y":[1,[4,"100"]]},"fields":{},"shadow":false,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"assetId":"bcf454acf82e4504149f7ffe07081dbc","name":"costum1","bitmapResolution":1,"md5ext":"bcf454acf82e4504149f7ffe07081dbc.svg","dataFormat":"svg","rotationCenterX":48,"rotationCenterY":50},{"assetId":"0fb9be3e8397c983338cb71dc84d0b25","name":"costum2","bitmapResolution":1,"md5ext":"0fb9be3e8397c983338cb71dc84d0b25.svg","dataFormat":"svg","rotationCenterX":46,"rotationCenterY":53}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Miau","dataFormat":"wav","format":"","rate":44100,"sampleCount":37376,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"0.2.0-prerelease.20210908050643","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"}}
1+
{"targets":[{"isStage":true,"name":"Stage","variables":{"`jEk@4|i[#Fk?(8x)AV.-my variable":["variabila mea",0]},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"decor1","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":44100,"sampleCount":1032,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Personaj1","variables":{},"lists":{},"broadcasts":{},"blocks":{"KJ*~ja{K12RKNMN(*}8`":{"opcode":"event_whenflagclicked","next":"KcPq6|D!oQI$!wzjgn//","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":34,"y":65},"ocpvrg]:AlBO|pm)r_HU":{"opcode":"motion_gotoxy","next":null,"parent":"KcPq6|D!oQI$!wzjgn//","inputs":{"X":[1,[4,"100"]],"Y":[1,[4,"100"]]},"fields":{},"shadow":false,"topLevel":false},"KcPq6|D!oQI$!wzjgn//":{"opcode":"control_wait","next":"ocpvrg]:AlBO|pm)r_HU","parent":"KJ*~ja{K12RKNMN(*}8`","inputs":{"DURATION":[1,[5,"1"]]},"fields":{},"shadow":false,"topLevel":false}},"comments":{},"currentCostume":0,"costumes":[{"assetId":"bcf454acf82e4504149f7ffe07081dbc","name":"costum1","bitmapResolution":1,"md5ext":"bcf454acf82e4504149f7ffe07081dbc.svg","dataFormat":"svg","rotationCenterX":48,"rotationCenterY":50},{"assetId":"0fb9be3e8397c983338cb71dc84d0b25","name":"costum2","bitmapResolution":1,"md5ext":"0fb9be3e8397c983338cb71dc84d0b25.svg","dataFormat":"svg","rotationCenterX":46,"rotationCenterY":53}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Miau","dataFormat":"wav","format":"","rate":44100,"sampleCount":37376,"md5ext":"83c36d806dc92327b9e7049a565c6bff.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":90,"draggable":false,"rotationStyle":"all around"}],"monitors":[],"extensions":[],"meta":{"semver":"3.0.0","vm":"0.2.0-prerelease.20210908050643","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"}}

gobo_cat.sb3

49.3 KB
Binary file not shown.

main.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Prepare project file
2020
allSprites = pygame.sprite.Group()
21-
projectToLoad = "wait_gotoxy.sb3" # change this to load a different project
21+
projectToLoad = "gobo_cat.sb3" # change this to load a different project
2222
targets, currentBgFile, project = s2p_unpacker.sb3_unpack(projectToLoad)
2323
for t in targets:
2424
sprite = TargetSprite(t)
@@ -49,7 +49,11 @@
4949
for s in allSprites:
5050
for _, block in s.target.blocks.items():
5151
if block.opcode == "event_whenflagclicked":
52-
scratch.execute(block, s)
52+
print("DEBUG: Running opcode", block.opcode)
53+
print("DEBUG: Running ID", block.blockID)
54+
nextBlock = scratch.execute(block, block.target.sprite)
55+
if nextBlock:
56+
toExecute.append(nextBlock)
5357

5458
scratch.setBackground(currentBg, display)
5559
while projectRunning:
@@ -81,18 +85,22 @@
8185
nextBlocks = []
8286
for block in toExecute:
8387
if block.waiting:
88+
print("DEBUG: Block execution time is", block.executionTime, "delay is", block.timeDelay)
8489
block.executionTime += clock.get_time()
8590
if block.executionTime >= block.timeDelay:
8691
block.waiting = False
92+
block.blockRan = True
93+
nextBlocks.append(block.target.blocks[block.next])
8794
block.executionTime, block.timeDelay = 0, 0
8895
print("DEBUG: Wait period ended")
8996
if not block.blockRan:
9097
print("DEBUG: Running opcode", block.opcode)
9198
print("DEBUG: Running ID", block.blockID)
9299
nextBlock = scratch.execute(block, block.target.sprite)
93100
if nextBlock:
101+
print("DEBUG: Next block is", nextBlock.opcode)
94102
nextBlocks.append(nextBlock)
95-
toExecute = nextBlocks
103+
toExecute = nextBlocks[:]
96104
allSprites.draw(display)
97105
allSprites.update()
98106
pygame.display.flip()

scratch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def execute(block, s):
4444
if opcode == "motion_gotoxy":
4545
s.setXy(int(inputs["X"][1][1]), int(inputs["Y"][1][1]))
4646
if opcode == "control_wait":
47-
block.timeDelay = int(round(float(inputs["DURATION"][1][1]) * 1000))
48-
block.waiting = True
49-
block.executionTime = 0
50-
print("DEBUG: Waiting for", block.timeDelay, "ms")
47+
if not block.waiting:
48+
block.timeDelay = int(round(float(inputs["DURATION"][1][1]) * 1000))
49+
block.waiting = True
50+
block.executionTime = 0
51+
print("DEBUG: Waiting for", block.timeDelay, "ms")
5152
return block
5253
if opcode == "event_whenflagclicked":
5354
pass

0 commit comments

Comments
 (0)