Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
City simulator I made in Scratch (scratch.mit.edu)
205 points by Annulus 12 months ago | hide | past | favorite | 30 comments


This is very impressive, amazing work!

One question: how do you manage large code bases in scratch? Is it easy to find a piece of code? Something like grepping for specific things seems difficult.

I've recently been really warming up to Scratch since one of my kids picked it up and really enjoys it. I love the built-in concurrency model - it's a bit like CSP. Gets kids to think concurrently from day 1.


Scratch is not conducive to complex (traditional) projects, which I think is sort of the appeal for seasoned programmers. For my part, I woke up one weekend knowing I had to make a recursive bisection demo in it [1]. The effort I knew it would take vs the banality and lack of game play was really funny to me in an absurd way.

Scratch lacks functions with return values, but if you hack global variables to be like registers, you can emulate them and even do recursion. At least that's how I did it. The Cartesian plane has (0,0) in the centre, which is annoying if you're used to traditional graphics.

I have a young cousin who's intimidated by making the jump from Scratch into traditional game dev. I tell him that Scratch simplifies a lot of things, but it also makes a lot of things harder if you're used to regular programming.

"Recursive Bisection on a Cartesian Plane in the Horizontal and Vertical Axes." (hold shift when you press "go" for fast mode): https://scratch.mit.edu/projects/1098438053


My younger daughter, who is pretty good at making games in Scratch is not that interested in jumping into text/code based programming. I do think Scratch makes things a lot easier and text based programming is not thar appealing to kids. I will try to start her with Pygame but even that might make it seem very arcane and not very visual.


PICO-8 [1] might be a good choice. I always consider that kids want their friends to try their games, and so being able to easily distribute to the web is awesome. They can link their game from the site [2], or with some parental help they could even serve them from their own website, which could be very empowering for a kid.

1. https://www.lexaloffle.com/pico-8.php

2. https://www.lexaloffle.com/bbs/?cat=7&carts_tab=1&#sub=2&mod...


Another vote for Pico-8. It’s such an incredible little package.

The simple IDE and forced constraints makes you really focus on the basics like fun gameplay loops and minimal graphics, and the fact you can do the code, graphics, sound effects, and music all in one little program is a really smart way to teach you all different aspects of game dev.

It’s also so ridiculously easy to share your creations, outputting a simple HTML/JS combo that works perfectly on mobile and desktop even if they don’t own the program.


My daughter (12) got her start in Scratch, but had a hard time jumping into Python. She's enjoyed GBStudio, and has made a number of small games in that environment, and enjoys loading them onto a flash cart to run them on an old physical Gameboy.


Maybe try something with instant feedback?

I'm not sure what precisely, but I'm picturing a split view with text on the left and the output on the right.

I do this in web dev, React + hot reload is wonderful. For games, I've done it with instantly recompiling shaders but not much else.


https://code.org/student/middle-high has an environment that's scratch-like i the UI but the code is blockified JavaScript. (If you try to transpile a Scratch project to JavaScript using normal tools, you get an unmanageable JSON monstrosity)

It hides some of the text syntax, while still being an onramp to text-based programming.


That's really clever, bravo.


It is really hard to search when there’s a lot of code - I just had to be pretty careful with how I laid out everything, so I roughly knew where everything was


Apart from keeping your code tidy and succinct, there's also third party extensions like https://scratchaddons.com/addons/ which can make writing code much more enjoyable - notably the `middle-click-popup`, `folders`, and `editor-devtools`. There's also an entire Debugger addon, which lets you log stuff, set breakpoints, see running threads.. Scratch Addons is awesome.


I think for me it was something that came with practice and intentionally organizing my code in a way that made spatial sense to me.


Has anyone made a way to write Scratch in plain text?



Are any of these bidirectional, so you can near-seamlessly edit the project in alternate sessions of Scratch and text? Scratch for high-level sprite/event management, and text for nitty-gritty coding of algorithms?


That could even be useful for writing real programs!


but... WHY?


This looks really cool. Kindof a random question, but how did you come up with the biome names? Are they inspired by something or just totally random? I like the world-building touch, either way.


Found a bug (on Chrome, reality mode): if you open and close the achievements/settings screen enough times, eventually things start to disappear and you can no longer place buildings.


Oh man I love a city builder - this is very cool thanks for sharing


on firefox at least, the WASD controls seems inverted?


Had a similar comment on starting reality mode.

One issue that arrive after a few minutes that's related, is the map arrows to be able to scroll around would often vanish. Going to the zoomed out overview map would eventually have the navigation return, yet kept occasionally happening for some reason.

Fun game, although world got flooded pretty much instantly, so was a bit of a downer. Still not sure if trade routes actually do anything other than explore the map. Did not ever seem to actually connect to nearby structures.

Be nice if there was some way to zoom out one level at least. Really... wanted to be able to zoom out after having 5-10 structures.


On Dvorak, WASD never works; game designers should use arrow keys or find a lower-level way to access key events that doesn't depend on the software layout.


Usually game developers use keyboard scancodes which are layout agnostic rather than the character generated when pressing a key, so it works on dvorak, AZERTY, etc.

I don't know if Scratch supports them though. Seems like it would given it's game focus.


Whatever the reason, in this case, it's broken


yeah it's broken for like 0.000001% of user


Well, WASD also is slightly broken for most left-handers, at least for games that assume one hand is on WASD and the other on the mouse.


Safari as well, and I couldn't get any other keys to work besides WASD


You have to click a square of land first, and then space will add a building (or whatever you cycle to with the arrows).

(Edit: at least in fantasy mode. I haven't yet worked out what to do in reality mode.)


This looks very much like Polytopia

https://polytopia.io/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: