Skip to content

Commit c2876e5

Browse files
committed
New default project
1 parent 222d706 commit c2876e5

9 files changed

+9
-89
lines changed

Direction.sb3

2.28 KB
Binary file not shown.

assets/0fb9be3e8397c983338cb71dc84d0b25.svg

Lines changed: 0 additions & 42 deletions
This file was deleted.
560 Bytes
Binary file not shown.
-36.5 KB
Binary file not shown.

assets/bcf454acf82e4504149f7ffe07081dbc.svg

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 1 addition & 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":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"backdrop1","md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":240,"rotationCenterY":180}],"sounds":[],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Cat","variables":{},"lists":{},"broadcasts":{},"blocks":{"n.c=CwDM+t?O2J}PfWM[":{"opcode":"motion_movesteps","next":null,"parent":"|./)T6UKl*O^2CJV!X?9","inputs":{"STEPS":[1,[4,"50"]]},"fields":{},"shadow":false,"topLevel":false},"|./)T6UKl*O^2CJV!X?9":{"opcode":"event_whenflagclicked","next":"n.c=CwDM+t?O2J}PfWM[","parent":null,"inputs":{},"fields":{},"shadow":false,"topLevel":true,"x":13,"y":173}},"comments":{},"currentCostume":0,"costumes":[{"assetId":"bcf454acf82e4504149f7ffe07081dbc","name":"cat-a","bitmapResolution":1,"md5ext":"bcf454acf82e4504149f7ffe07081dbc.svg","dataFormat":"svg","rotationCenterX":48,"rotationCenterY":50},{"assetId":"0fb9be3e8397c983338cb71dc84d0b25","name":"cat-b","bitmapResolution":1,"md5ext":"0fb9be3e8397c983338cb71dc84d0b25.svg","dataFormat":"svg","rotationCenterX":46,"rotationCenterY":53}],"sounds":[{"assetId":"83c36d806dc92327b9e7049a565c6bff","name":"Meow","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.20210804080338","agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36"}}
1+
{"targets":[{"isStage":true,"name":"Stage","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"cd21514d0531fdffb22204e0ec5ed84a","name":"decor1","bitmapResolution":1,"md5ext":"cd21514d0531fdffb22204e0ec5ed84a.svg","dataFormat":"svg","rotationCenterX":0,"rotationCenterY":0}],"sounds":[],"volume":100,"layerOrder":0,"tempo":60,"videoTransparency":50,"videoState":"on","textToSpeechLanguage":"ro"},{"isStage":false,"name":"Personaj1","variables":{},"lists":{},"broadcasts":{},"blocks":{},"comments":{},"currentCostume":0,"costumes":[{"assetId":"f7299d83944d13c634f551e0a634f661","name":"costum1","bitmapResolution":1,"md5ext":"f7299d83944d13c634f551e0a634f661.svg","dataFormat":"svg","rotationCenterX":53.40994644165039,"rotationCenterY":15.981249999999989}],"sounds":[{"assetId":"83a9787d4cb6f3b7632b4ddfebf74367","name":"pop","dataFormat":"wav","format":"","rate":44100,"sampleCount":1032,"md5ext":"83a9787d4cb6f3b7632b4ddfebf74367.wav"}],"volume":100,"layerOrder":1,"visible":true,"x":0,"y":0,"size":100,"direction":58.273846481300026,"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"}}

main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ def loadSvg(svg_bytes):
3030

3131
# Render a sprite at its coordinates
3232
def render(sprite, x, y, direction):
33-
# convert Scratch coordinates into Pygame coordinates
33+
# upscale sprite
3434
sprite = pygame.transform.scale(sprite, (sprite.get_width() * 2, sprite.get_height() * 2))
35-
# sprite = pygame.transform.rotate(sprite, 100)
35+
# set direction
36+
sprite = pygame.transform.rotate(sprite, 90 - direction)
37+
# convert Scratch coordinates into Pygame coordinates
3638
finalX = x + WIDTH // 2 - sprite.get_width() // 2
3739
finalY = HEIGHT // 2 - y - sprite.get_height() // 2
3840
display.blit(sprite, (finalX, finalY))
@@ -44,7 +46,7 @@ def setBackground(bg):
4446

4547

4648
# Prepare project file
47-
projectToLoad = "mascots.sb3" # change this to load a different project
49+
projectToLoad = "Direction.sb3" # change this to load a different project
4850
targets, currentBgFile, project = s2p_unpacker.sb3_unpack(projectToLoad)
4951
wn = tk.Tk() # Start tkinter for popups
5052
wn.withdraw() # Hide main tkinter window
@@ -92,7 +94,7 @@ def setBackground(bg):
9294
# Move all sprites to current position and direction
9395
setBackground(currentBg)
9496
for target in targets:
95-
render(loadSvg(target.costumes[target.currentCostume].file), target.x * 2, target.y * 2, 90)
97+
render(loadSvg(target.costumes[target.currentCostume].file), target.x * 2, target.y * 2, target.direction)
9698
for _, block in target.blocks.items():
9799
if not block.blockRan and block.opcode == "event_whenflagclicked":
98100
print("DEBUG: Running opcode", block.opcode)

s2p_unpacker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def sb3_unpack(sb3):
3333
t = target.Target()
3434
t.x = target_obj["x"]
3535
t.y = target_obj["y"]
36+
t.direction = target_obj["direction"]
3637
t.currentCostume = target_obj["currentCostume"]
3738
for costume_obj in target_obj["costumes"]:
3839
c = costume.Costume()

0 commit comments

Comments
 (0)