Page 1 of 1
A couple of simple single-file apps
Posted: Wed Jun 01, 2022 7:40 pm
by Kartik Agaram
I recently started programming in LÖVE, and I've been building little apps for preschool kids that I wanted to put out there:
Geometric construction using compass and straightedge:
https://gist.github.com/akkartik/20a0c7 ... 8bc04b28b4
A little app for learning functional programming using shapes:
https://gist.github.com/akkartik/f7ec2d ... 5a6a08f352
A gravity simulator:
https://gist.github.com/akkartik/001dcd ... 408f99d742
I've been sharing them as raw lua rather than .love files to encourage kids to look inside them.
They're nothing too sophisticated, the goal is just to get kids used to the idea that they might _change_ overnight in response to ideas or questions or feature requests.
One mildly interesting idea is the way I draw buttons with their event handlers all in one place.
Re: A couple of simple single-file apps
Posted: Fri Jun 03, 2022 6:23 pm
by milon
Kartik Agaram wrote: ↑Wed Jun 01, 2022 7:40 pm
I recently started programming in LÖVE, and I've been building little apps for
preschool kids that I wanted to put out there:
Where I come from, preschool typically means 3 & 4 year old kids. But these seem to be for older kids instead.
And I did something similar in
Wordie, where each created GUI object implements its own callbacks and the state loop just calls each defined .draw (etc) call. It really helped me think better about scope.
Side note, I noticed that most/all of your variables are global rather than local. Is that intentional?
Re: A couple of simple single-file apps
Posted: Fri Jun 03, 2022 10:06 pm
by Kartik Agaram
I did see your post! But hadn't quite delved into the code.
I really am having 4-year olds try these out. Hence just shapes on the stack puzzle, for example. They didn't really understand what the swap button does, so I paused the stack puzzle experiment. But they do seem able to play around with the geometry app and the gravity simulator. We don't get into the theory, but it feels like it can't hurt to get a feel for how objects behave under gravity and so on.
Globals seem fine for small apps like these? They actually seem easier to read..
Re: A couple of simple single-file apps
Posted: Sat Jun 04, 2022 9:57 pm
by pgimeno
Kartik Agaram wrote: ↑Fri Jun 03, 2022 10:06 pmThey didn't really understand what the swap button does, so I paused the stack puzzle experiment.
Neither did I, and I'm more than 10 times older
At first I thought that it would only swap a circle and a square if found in the sequence in that order (like a
string rewriting system). As the problems progressed, I thought that the square stood for a variable, and the circle was supposed to be literal. At the end, I was completely confused. Only when I looked into the code and saw the operators did I understand that it was "operation by example" and it meant "swap". And even then, it wasn't immediately clear that it operated on the two elements from the left.
Maybe if using boxes with dashed lines for "variables", and arrows pointing to the new disposition, it might be easier to understand.
Re: A couple of simple single-file apps
Posted: Sun Jun 05, 2022 7:59 pm
by Kartik Agaram
Thanks for that feedback! Most appreciated. Yeah, I need to go back to the drawing board.
Re: A couple of simple single-file apps
Posted: Tue Jun 07, 2022 2:14 pm
by milon
Kartik Agaram wrote: ↑Fri Jun 03, 2022 10:06 pm
I did see your post! But hadn't quite delved into the code.
I really am having 4-year olds try these out. Hence just shapes on the stack puzzle, for example. They didn't really understand what the swap button does, so I paused the stack puzzle experiment. But they do seem able to play around with the geometry app and the gravity simulator. We don't get into the theory, but it feels like it can't hurt to get a feel for how objects behave under gravity and so on.
Globals seem fine for small apps like these? They actually seem easier to read..
Very cool! I agree - it certainly wouldn't hurt to let young kids play around with this. I'm just a little surprised, but in a great way!
And yeah, I think globals are fine for this. It's just non-standard and
slightly less performant - I expect - due to the increased lookup time for a global versus a local. But absolutely no one would notice/care without looking into the code.