Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Leopard: Edit Scratch projects as JavaScript code
- apple502j
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Then please review my PR (https://github.com/PullJosh/leopard/pull/60 - i know edit conflicts and will fix it soon)
署名は、ディスカッションフォーラムの機能である。署名は、その人のすべての投稿の下部に追加される。署名は、BBCodeで記述できる。 署名を追加/変更/削除したい場合は、ディスカッションフォーラムのホームの一番下に行き、「Change your signature」を押す。署名の大きさは150pxまでである。これには、改行、画像を含む。- Japanese Scratch-Wiki 「署名」
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
As a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
You can see the graph of development progress how long did it take to make?here. I started working in October of 2018, took a big break, then started up again and got some help in late 2019/early 2020. Then another small break as school finished up, and now it's published.
It's definitely and if u were to make a full game but in JS (like no conversion just straight from JS) the code wouldn’t be the same would it?possible to write your own Leopard code manually, but I think if you're going to do that you might as well choose a more fully-featured game engine like Phaser.
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Comments work on CodeSandbox. eslintrc doesn't.Perhaps it could be disabled by adding I've tried to find a way to turn ESLint off for converted projects but haven't found one.to the top of the file, or including an .eslintrc file turning those rules off (idk if the latter works)/* eslint require-yield: "off", eqeqeq: "off" */
I wanted to avoid including comments at the top of every file, but it's probably worth it to avoid confusion.
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Another bug squashed! The “letter of” block should now work more consistently. KarateToast's raycaster project now gets a lot farther before breaking! Check it out! (For some reason the project still breaks when you turn around, but I'll work on that later. For now, this is progress!)https://scratch.mit.edu/projects/279544414/
- You're using the “letter of” operator block to get a character within a number (like 111110000111000). Scratch treats the number like a string, but Leopard just gets confused. I can fix this by changing the translator to always include .toString() in the exported JavaScript. That makes the code a little uglier for the average project, but at least it works.
- Pr_Testing
- Scratcher
8 posts
Leopard: Edit Scratch projects as JavaScript code
srry I didn’t make it clear for my JS question I meant if u code it like scratch… like u see how u translated scratch to JS like the move 10 steps block for example when u translated it into JS can u use them specific (as in Scratch-like - move 10 steps etc.) translations to code a game in JS? Like translated scratch code as a game but without using scratch? Is it possible to make a game like that? srry idk how to explain it
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Yet another pair of bug fixes! We're on a roll today! This time it was a joint effort between Adroitwhiz and me.
None of you had really run into these problems yet, but they were bound to become an issue eventually. Previously, …
None of you had really run into these problems yet, but they were bound to become an issue eventually. Previously, …
- Trying to make a sprite say “0” or “false” would fail, and the speech bubble wouldn't appear
- Empty inputs would become zeroes in the JavaScript rather than empty strings
Last edited by PullJosh (July 6, 2020 19:07:43)
- Jeffalo
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
oh yeah and i think honestly one of the coolest thing's i've seen or played with in a while.https://scratch.mit.edu/projects/229748163/ never loads, i think this might be beacuse it uses the microbit extenstion
some of my projects don't work
https://scratch.mit.edu/projects/322002554/ - it gets stuck on the menu
and
https://scratch.mit.edu/projects/297395617/ gets stuck on the logo animation at the start
https://scratch.mit.edu/projects/292449845/ is missing the numbers for each level
and something i've noticed is that fonts in vectors don't really work, perhaps leopard could convert them to free fonts that can be used?
anyways i had so much fun messing with this yesterday and i've got so many ideas for cool things to make (next i plan on making a portal for my games)
awesome work and it's amazing
https://scratch.mit.edu/projects/290875905/ doesn't display the variable watchers
https://scratch.mit.edu/projects/239457659/ ‘s main menu doesn’t show up and the character can't move
https://scratch.mit.edu/projects/269088736/ has no variable watchers
https://scratch.mit.edu/projects/254779600/ is just a white/light blue screen
edit my bad i didnt notice that variable watchers aren't supported yet
Last edited by Jeffalo (July 6, 2020 20:02:01)
I discovered Scratch in 2015 and created games and animations. From 2020 to 2023, I worked on Scratch browser extensions, found security vulnerabilities, and maintained a forum search engine called ocular. In the summer of 2024, I was an engineering intern with the Scratch Team. Now, I'm ready to finish my last year of high school. Scratch on!
- -Rex-
- Scratcher
500+ posts
Leopard: Edit Scratch projects as JavaScript code
I tried converting some of my recent projects
https://scratch.mit.edu/projects/406678232/ - Doesn't work correctly
https://scratch.mit.edu/projects/402906014/ - Doesn't work at all
https://scratch.mit.edu/projects/391319702/ - Doesn't work correctly (variable monitors obviously aren't shown, sounds are refreshed even when the stage isn't, setting the volume doesn't cause a script to yield, the list isn't sorted correctly)
https://scratch.mit.edu/projects/391085754/ - Doesn't work correctly (monitors aren't shown, the font is different)
https://scratch.mit.edu/projects/387514853/ - Minor differences (the font is different, using the arrow keys causes the page to scroll)
https://scratch.mit.edu/projects/383270300/ - Freezes (Scratch should refresh every 500ms; this project exploits really weird Scratch behavior which I wouldn't expect to be replicated, causing the custom block to never terminate when run in Leopard)
https://scratch.mit.edu/projects/374509791/ - Doesn't work correctly (terrain doesn't show; seems to be an issue with stamping)
https://scratch.mit.edu/projects/349634648/ - Doesn't work correctly (text isn't shown; seems to be an issue with stamping)
https://scratch.mit.edu/projects/278999727/ - Doesn't work correctly (lots of strange issues; I've encountered an issue with strings “Infinity” and “-Infinity” when comparing before, which might the repeated sounds after clicking the play button)
Windows 10 Home 1909, Edge 83.0.478.58, Intel CPU and GPU
Reminds me of OS X
https://scratch.mit.edu/projects/406678232/ - Doesn't work correctly
https://scratch.mit.edu/projects/402906014/ - Doesn't work at all
https://scratch.mit.edu/projects/391319702/ - Doesn't work correctly (variable monitors obviously aren't shown, sounds are refreshed even when the stage isn't, setting the volume doesn't cause a script to yield, the list isn't sorted correctly)
https://scratch.mit.edu/projects/391085754/ - Doesn't work correctly (monitors aren't shown, the font is different)
https://scratch.mit.edu/projects/387514853/ - Minor differences (the font is different, using the arrow keys causes the page to scroll)
https://scratch.mit.edu/projects/383270300/ - Freezes (Scratch should refresh every 500ms; this project exploits really weird Scratch behavior which I wouldn't expect to be replicated, causing the custom block to never terminate when run in Leopard)
https://scratch.mit.edu/projects/374509791/ - Doesn't work correctly (terrain doesn't show; seems to be an issue with stamping)
https://scratch.mit.edu/projects/349634648/ - Doesn't work correctly (text isn't shown; seems to be an issue with stamping)
https://scratch.mit.edu/projects/278999727/ - Doesn't work correctly (lots of strange issues; I've encountered an issue with strings “Infinity” and “-Infinity” when comparing before, which might the repeated sounds after clicking the play button)
Windows 10 Home 1909, Edge 83.0.478.58, Intel CPU and GPU
As a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
Reminds me of OS X
Last edited by -Rex- (July 7, 2020 02:00:12)
- CatsUnited
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
when we getting Snow Leopard @PullJoshAs a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
Reminds me of OS X
bottom text
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
I say we jump straight to Big Sur.when we getting Snow Leopard @PullJoshAs a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
Reminds me of OS X
- -Rex-
- Scratcher
500+ posts
Leopard: Edit Scratch projects as JavaScript code
But then it wouldn’t be a cat…I say we jump straight to Big Sur.when we getting Snow Leopard @PullJoshAs a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
Reminds me of OS X
- Pr_Testing
- Scratcher
8 posts
Leopard: Edit Scratch projects as JavaScript code
I say we jump straight to Big Sur.when we getting Snow Leopard @PullJoshAs a name? I thought Leopard was more clever. A more powerful cat! why not Purrr?
Reminds me of OS X
haha Big Sur
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Another update! From now on, you shouldn't get these annoying warning messages in CodeSandbox. All newly-converted projects will have the appropriate eslint-disable comments.usually a good idea, but it makes sense for us to break them so that projects remain compatible with Scratch. I've tried to find a way to turn ESLint off for converted projects but haven't found one.Perhaps it could be disabled by adding CodeSandbox uses a tool called ESLint to analyze your JavaScript and give you helpful tips to improve your code. Certain rules, like requiring a yield, or using === instead of ==, areto the top of the file, or including an .eslintrc file turning those rules off (idk if the latter works)/* eslint require-yield: "off", eqeqeq: "off" */
- GeckoTwin11
- Scratcher
34 posts
Leopard: Edit Scratch projects as JavaScript code
I've seen those types of broken prodgects. They were broken by Scratch 3.0.Example: This seems like a cool project - I decided to test all of my projects to see how well they work with the current version of Leopard you've got going:
The first two were made in Scratch 2, so they don't work with Leopard
Springer - this does run, although only a few of the objects seemed to successfully load in when the project started, including almost no sounds.
Tom Nook Simulator 2019 The one that graphically ran the best, though I wasn't able to complete the game. The background is missing in this one, but otherwise all the objects are there, just layered incorrectly due to a lack of sprite layer block translation (also is that running at 60 FPS?). I personally hope that the sprite layer blocks get added in soon, however about you'd go with that.
Kerbi Adventar - Extremely broken and unplayable. The first run I tested on Chrome, it played through the intro cutscene, though almost nothing was rendered correctly. After the cutscene, none of the level geometry loaded so Kerbi fell through the floor and died. Every subsequent run never made it past the first “loading” screen. On Firefox, I managed to more consistently get past that first loading screen. Due to the size of this project and that it's code is the definition of spaghetti code, I'm not surprised it's in this broken state currently
Scratch 2.0 blocks:
when green flag clickedScratch 3.0 blocks:
forever
change pen color by (1)
pen down
move (1000) steps
end
when green flag clickedScratch 3.0 will not support some blocks.
forever
pen down
move (1000) steps
end
Last edited by GeckoTwin11 (July 7, 2020 15:03:50)
nothing
- pillan
- Scratcher
35 posts
Leopard: Edit Scratch projects as JavaScript code
Here is a link to my project: https://scratch.mit.edu/projects/259674405/
When converting into JS I get an error code
When converting into JS I get an error code
Last edited by pillan (July 7, 2020 15:05:51)
- HexaHuman
- Scratcher
8 posts
Leopard: Edit Scratch projects as JavaScript code
https://scratch.mit.edu/projects/395829636/ is not working. The blueberry does not show up, nor do the variables.
Last edited by HexaHuman (July 7, 2020 15:09:06)
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Small update! When you press the up/down arrow keys while playing a project, the page no longer scrolls. (Note that it may take a few minutes for the changes to reach everyone. Unpkg caches files for up to 10 minutes.)
Last edited by PullJosh (July 7, 2020 15:09:20)
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Another bug squashed! The “letter of” block should now work more consistently. KarateToast's raycaster project now gets a lot farther before breaking! Check it out! (For some reason the project still breaks when you turn around, but I'll work on that later. For now, this is progress!)More progress on KarateToast's raycaster! This is a bug fix that will impact lots of projects, but KarateToast's raycaster is what helped me track down the issue. (That's why sharing broken projects is so helpful!)
Previously, the project would crash if you turned to look in a particular direction. That no longer happens.
Here's what was going on: KarateToast stores the world map in a list of digits.
During the conversion process, this list is converted to a JavaScript array of numbers. Unfortunately, JavaScript has a limit on the size that numbers can be. Once numbers become greater than 9007199254740991, they start to be rounded. For example, if you type 11111111111111111111 in your JavaScript code, it will actually be treated as 11111111111111110000. This caused some walls to be missing, which meant that the raycaster got stuck in an infinite loop.
Leopard now treats large numbers as strings, which solves the problem.
Still, the conversion isn't perfect. Super strangely, the left/right arrow key controls are actually reversed in the JavaScript version, which is not a bug I ever would have anticipated. I still need to investigate why that's happening.
- apple502j
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
https://github.com/PullJosh/leopard/pull/60 - i know edit conflicts and will fix it soon)bump Then please review my PR (
署名は、ディスカッションフォーラムの機能である。署名は、その人のすべての投稿の下部に追加される。署名は、BBCodeで記述できる。 署名を追加/変更/削除したい場合は、ディスカッションフォーラムのホームの一番下に行き、「Change your signature」を押す。署名の大きさは150pxまでである。これには、改行、画像を含む。- Japanese Scratch-Wiki 「署名」
- PullJosh
- Scratcher
1000+ posts
Leopard: Edit Scratch projects as JavaScript code
Thanks for bringing this to my attention again! I do intend to check it out. I have a system for keeping track of which forum posts I've acted on, so nothing will slip through the cracks. For now, I've been trying to focus on the issues that are most urgent. Loudness blocks are an awesome addition, and I'm excited to look at your PR, but right now things like bug fixes and sprite layering have to take priority.https://github.com/PullJosh/leopard/pull/60 - i know edit conflicts and will fix it soon)bump Then please review my PR (
Thanks for understanding! And thank you for your PR!
(While I'm working on other things, you might have a chance to resolve the merge conflicts–that would be great!)
- Discussion Forums
- » Advanced Topics
- » Leopard: Edit Scratch projects as JavaScript code