Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » [v1.3-beta] sb3topy: Scratch to Python with Pygame
- Agazila
-
3 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
ignore this, i found out 

- Agazila
-
3 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
ignore this, i found out 

- bloctans_4
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
anyone know where the scratch speech bubble images are stored?
- WojtekGame
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
they don't technically. anyone know where the scratch speech bubble images are stored?
the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
- ajskateboarder
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
bloctans was talking about sb3topy, not Scratch's VMthey don't technically. anyone know where the scratch speech bubble images are stored?
the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
It's rendered in this function, by the way
- imfh
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
No, that function is used for drawing the FPS or other debug info. I haven’t actually implemented speech bubbles, it just prints out the text.bloctans was talking about sb3topy, not Scratch's VMthey don't technically. anyone know where the scratch speech bubble images are stored?
the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
It's rendered in this function, by the way
- LukeSky47SCRATCH
-
13 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
True That is awesome!!
- LukeSky47SCRATCH
-
13 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
and so much more don't work
Last edited by LukeSky47SCRATCH (Sept. 17, 2023 22:01:44)
- imfh
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
Yeah, those specific blocks don’t work. They print to the Python terminal instead.and so much more don't work
- -CelerySticks-
-
7 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
If you're looking for a different library to convert svg to png, you can use Wand-py. The code to convert is slightly more confusing, but it's still only 2 lines.
Edit: I don't see a way to install one of the wand-py dependencies on windows, you would have to look into that
Also, how hard is it to parse the scratch json file?
Edit: I don't see a way to install one of the wand-py dependencies on windows, you would have to look into that
Also, how hard is it to parse the scratch json file?
Last edited by -CelerySticks- (Dec. 2, 2023 02:02:53)
- bloctans_4
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
(#72)i've already explained that pygame (iirc >2.0) supports display of svgs without any other libraries
If you're looking for a different library to convert svg to png, you can use Wand-py. The code to convert is slightly more confusing, but it's still only 2 lines.
Edit: I don't see a way to install one of the wand-py dependencies on windows, you would have to look into that
Also, how hard is it to parse the scratch json file?
- -CelerySticks-
-
7 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
(#72)i've already explained that pygame (iirc >2.0) supports display of svgs without any other libraries
If you're looking for a different library to convert svg to png, you can use Wand-py. The code to convert is slightly more confusing, but it's still only 2 lines.
Edit: I don't see a way to install one of the wand-py dependencies on windows, you would have to look into that
Also, how hard is it to parse the scratch json file?
Ok, just looked it up, and pygame2 (and pygame-ce, for that matter, which I prefer) has direct svg support due to SDL2. The only thing is that we would still need a converter if this tool is using pygame 1.9.x, although in that case the creator should just upgrade it
- rishi272011
-
100 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
I am running it in Replit. What does this error mean?
Does replit support sound?
I think this is a problem with replit
[INFO] Extracting project... [INFO] Converting project assets... [WARNING] Package cairosvg is not installed correctly. [ERROR] SVG conversion is enabled but cairosvg does not appear to be installed. Consider configuring Inkscape under Asset settings in the GUI. [WARNING] Costume conversion is disabled. Any SVGs in the project will not be visible. [INFO] Overwriting engine files at '/home/runner/SolidCostlyTrees/output/engine' [INFO] Compiling project into Python... [INFO] Initializing parser... [INFO] Running optimizations... [INFO] Generating Python code... [INFO] Saving converted project to '/home/runner/SolidCostlyTrees/output/project.py' [INFO] Finished converting project. Saved in '/home/runner/SolidCostlyTrees/output' [INFO] Running project... pygame 2.5.0 (SDL 2.28.0, Python 3.10.11) Hello from the pygame community. https://www.pygame.org/contribute.html [CRITICAL] Unhandled exception during the conversion process: Traceback (most recent call last): File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 110, in _run_worker run() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 90, in run packer.run_project(manifest.output_dir) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/packer/packer.py", line 105, in run_project project.engine.start_program() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 207, in start_program runtime = Runtime(SPRITES) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 39, in __init__ pg.mixer.set_num_channels(config.AUDIO_CHANNELS) pygame.error: mixer not initialized CRITICAL:sb3topy.main:Unhandled exception during the conversion process: Traceback (most recent call last): File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 110, in _run_worker run() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 90, in run packer.run_project(manifest.output_dir) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/packer/packer.py", line 105, in run_project project.engine.start_program() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 207, in start_program runtime = Runtime(SPRITES) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 39, in __init__ pg.mixer.set_num_channels(config.AUDIO_CHANNELS) pygame.error: mixer not initialized Process Process-1: Traceback (most recent call last): File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap self.run() File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/multiprocessing/process.py", line 108, in run self._target(*self._args, **self._kwargs) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 110, in _run_worker run() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/main.py", line 90, in run packer.run_project(manifest.output_dir) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/sb3topy/packer/packer.py", line 105, in run_project project.engine.start_program() File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 207, in start_program runtime = Runtime(SPRITES) File "/home/runner/SolidCostlyTrees/sb3topy-master/src/engine/runtime.py", line 39, in __init__ pg.mixer.set_num_channels(config.AUDIO_CHANNELS) pygame.error: mixer not initialized
I think this is a problem with replit
Last edited by rishi272011 (Dec. 15, 2023 10:22:20)
- julmik6478
-
500+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
After leopard - scratch to javascript we have Scratch to python.
- Jeb444
-
9 posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
(long unnecessary quote removed by moderator - please don't spam)
thats cool
thats cool
Last edited by Paddle2See (Sept. 4, 2024 17:52:01)
- MonkeyBean2
-
500+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
Very cool, I'd suggest trying to get pygame to render SVGs though. Maybe you could use some other python SVG renderer library and convert the SVGs to bitmaps and store them in-memory when you load all of the assets.
- imfh
-
1000+ posts
[v1.3-beta] sb3topy: Scratch to Python with Pygame
The latest release of the converter does support Pygame SVGs, but only as a fallback. Pygame SVGs aren't great, as Pygame essentially converts the SVG to a bitmap but with bad resolution. If there was an option to set the DPI, it would be a lot better. Very cool, I'd suggest trying to get pygame to render SVGs though. Maybe you could use some other python SVG renderer library and convert the SVGs to bitmaps and store them in-memory when you load all of the assets.
The converter also supports CairoSVG or Inkscape to convert SVGs into bitmap PNG file. Both of these tools support custom DPI, which lets the bitmap image look sharper. I guess I could convert them at runtime, but that would be potentially laggy. The conversion is usually kind of slow and not good to do in realtime.
- Discussion Forums
- » Advanced Topics
-
» [v1.3-beta] sb3topy: Scratch to Python with Pygame