Discuss Scratch

Agazila
Scratcher
3 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

ignore this, i found out
Agazila
Scratcher
3 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

ignore this, i found out
bloctans_4
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

anyone know where the scratch speech bubble images are stored?
alwayspaytaxes
Scratcher
500+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

bup
jumpy_candy
Scratcher
1 post

[v1.3-beta] sb3topy: Scratch to Python with Pygame

what
WojtekGame
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

bloctans_4 wrote:

anyone know where the scratch speech bubble images are stored?
they don't technically.

the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
ajskateboarder
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

WojtekGame wrote:

bloctans_4 wrote:

anyone know where the scratch speech bubble images are stored?
they don't technically.

the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
bloctans was talking about sb3topy, not Scratch's VM

It's rendered in this function, by the way
imfh
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

ajskateboarder wrote:

WojtekGame wrote:

bloctans_4 wrote:

anyone know where the scratch speech bubble images are stored?
they don't technically.

the scratch bubble is kinda generated by the VM, and it's similar to cowsay.
bloctans was talking about sb3topy, not Scratch's VM

It's rendered in this function, by the way
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.
LukeSky47SCRATCH
Scratcher
13 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

skymover1239 wrote:

That is awesome!!
True
LukeSky47SCRATCH
Scratcher
13 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

sayHello!for2secs
and so much more don't work
thinkOof

Last edited by LukeSky47SCRATCH (Sept. 17, 2023 22:01:44)

imfh
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

LukeSky47SCRATCH wrote:

sayHello!for2secs
and so much more don't work
thinkOof
Yeah, those specific blocks don’t work. They print to the Python terminal instead.
-CelerySticks-
Scratcher
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?

Last edited by -CelerySticks- (Dec. 2, 2023 02:02:53)

bloctans_4
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

-CelerySticks- wrote:

(#72)
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?
i've already explained that pygame (iirc >2.0) supports display of svgs without any other libraries
-CelerySticks-
Scratcher
7 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

bloctans_4 wrote:

-CelerySticks- wrote:

(#72)
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?
i've already explained that pygame (iirc >2.0) supports display of svgs without any other libraries

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
Scratcher
100 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

I am running it in Replit. What does this error mean?
[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
Does replit support sound?

I think this is a problem with replit

Last edited by rishi272011 (Dec. 15, 2023 10:22:20)

cartword23
Scratcher
1 post

[v1.3-beta] sb3topy: Scratch to Python with Pygame

omg
julmik6478
Scratcher
500+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

After leopard - scratch to javascript we have Scratch to python.
Jeb444
Scratcher
9 posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

(long unnecessary quote removed by moderator - please don't spam)

thats cool

Last edited by Paddle2See (Sept. 4, 2024 17:52:01)

MonkeyBean2
Scratcher
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
Scratcher
1000+ posts

[v1.3-beta] sb3topy: Scratch to Python with Pygame

MonkeyBean2 wrote:

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 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.

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.

Powered by DjangoBB