Skip to content

Commit 222d706

Browse files
committed
Scratch2Python now upscales the Scratch project to double its original size
1 parent f8db5c9 commit 222d706

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@ def loadSvg(svg_bytes):
2929

3030

3131
# Render a sprite at its coordinates
32-
def render(sprite, x, y):
32+
def render(sprite, x, y, direction):
3333
# convert Scratch coordinates into Pygame coordinates
34+
sprite = pygame.transform.scale(sprite, (sprite.get_width() * 2, sprite.get_height() * 2))
35+
# sprite = pygame.transform.rotate(sprite, 100)
3436
finalX = x + WIDTH // 2 - sprite.get_width() // 2
3537
finalY = HEIGHT // 2 - y - sprite.get_height() // 2
3638
display.blit(sprite, (finalX, finalY))
3739

3840

3941
# Set the stage background
4042
def setBackground(bg):
41-
render(bg, 0, 0)
43+
render(bg, 0, 0, 90)
4244

4345

4446
# Prepare project file
45-
projectToLoad = "ifonedgebounce.sb3" # change this to load a different project
47+
projectToLoad = "mascots.sb3" # change this to load a different project
4648
targets, currentBgFile, project = s2p_unpacker.sb3_unpack(projectToLoad)
4749
wn = tk.Tk() # Start tkinter for popups
4850
wn.withdraw() # Hide main tkinter window
@@ -51,8 +53,8 @@ def setBackground(bg):
5153
pygame.init() # Start pygame
5254
scratch.startProject()
5355
# Set player size
54-
HEIGHT = 360
55-
WIDTH = 480
56+
HEIGHT = 720
57+
WIDTH = 960
5658
projectName = projectToLoad[:-4] # Set the project name
5759
icon = pygame.image.load("icon.png")
5860
display = pygame.display.set_mode([WIDTH, HEIGHT])
@@ -90,7 +92,7 @@ def setBackground(bg):
9092
# Move all sprites to current position and direction
9193
setBackground(currentBg)
9294
for target in targets:
93-
render(loadSvg(target.costumes[target.currentCostume].file), target.x, target.y)
95+
render(loadSvg(target.costumes[target.currentCostume].file), target.x * 2, target.y * 2, 90)
9496
for _, block in target.blocks.items():
9597
if not block.blockRan and block.opcode == "event_whenflagclicked":
9698
print("DEBUG: Running opcode", block.opcode)

0 commit comments

Comments
 (0)