My son (9 yrs old) used plain JavaScript to make a game, and wants your feedback (armaansahni.com)

1251 points by veesahni ↗ HN
My 9 year old son has been learning to code. He learned HTML & CSS over the last year or two.

Recently, we had a breakthrough where he learned how to leverage Google Gemini as a learning tool (not to write code for him, but as a better search and as a coding teacher). This leveled him up big time and he decided to make his own game.

Game link here: https://www.armaansahni.com/game/

He's coded all the HTML, CSS & JS by hand in VSCode. He's made the animated graphics on his own using a web based sprite editor called Piskel.

For the game, I provided hints along the way and Gemini has helped him with syntax. View source to see the code. He's excited to share with the community.

He also wrote a blog post about how he made this game: https://www.armaansahni.com/how-i-coded-a-game-using-ai/ (he independently figured out how to leverage Gemini effectively and writes about it here).

Regarding the blog post - We had a discussion about who the target audience is (ie not 9 year olds!), what they would be interested in learning about and the general outline. He then dictated his words into the computer (which gets around spelling issues), and he went through multiple rounds of feedback from his parents (improving clarity, punctuation, etc). In other words, its his words & thoughts but he had help along the way!

NOTE: both parents are programmers, who provided valuable guidance through his coding journey.

492 comments

[ 2439 ms ] story [ 1939 ms ] thread
(comment deleted)
I love it! I'm going to show this to my 6 yo tonight. I know for a fact she'll enjoy it.
Omg this is amazing And hilarious and he should keep making games. I love that it’s both a silly fantasy game and math. Well done.
thanks for checking out the game. Appreciate the feedback! :)
That's hilariously evil turning it into a maths game.

Be fun to add some music to this.

v2 will have sound effects. I had conversation with him about copyrights and he's recording his own audio!
Love it.

In terms of constructive feedback: I would like to know when the various weapons are "charged." It doesn't seem like we can tell from looking.

Also it might be interesting to see what question the opponent is working on and what his answer is.

Yeah, I was having the same issue. I couldn't tell why the weapon was not charged up. But sometimes on the second click it would work.

But well done!

I think there are two improvement requests here:

1. Dont't allow button clicking when not the player's turn (expect tiny dev might be getting tripped up by async event handlers here)

2. Visually flag whether or not an ability is charged

both are things that are on his plan for the next version.

Appreciate the feedback!

Are you giving him the full experience? :D

"Sorry, you have to branch first."

"Sorry, you have to submit a pull request."

"Did you complete your peer code review?"

"Did you close the associated Jira tickets?"

"Did this pass your test harness?"

"Are you having this built and tested by your CICD bot?"

"... is this project's architecture even approved? Sorry, you need to submit this to the architectural review board. They meet once a month."

Come to think of it, I'm now recognizing why coding used to be more fun.

haha :)

For this version, I stopped at "does it work? alright, move forward"

> tiny dev

This has me dead. To the kiddo: great work, this is an amazing start.

improving clarity of the charging aspect is on his roadmap for v2 :)

if you use the throwing star multiple times, it charges up other ones. But if you use another one, then you have to charge it up again. I believe 4 throwing stars give you the exploding star!

We need something at the end when we win (or lose). Like a picture of a cat at least :)
> I would like to know when the various weapons are "charged." It doesn't seem like we can tell from looking.

I think it might just be doing random choice when it's clicked. I found that if you get the "it's charging" message, you can just click again & again & eventually one of them will go through.

It's not random, you just get +1 charge every time you click an attack — including if the attack doesn't have enough charge to fire.
Ugh, this bug and the "Queston" typo completely broke the immersion. I can't fight my warp core properly in these conditions.

Edit: I think the "charge" is earned when the enemy move is completed, but the logic is buggy. Pretty fun first game nevertheless.

Perhaps a grey colour to indicate no charge and a coloured to indicated charged
Yes, I've talked to him about this. He's played with CSS greyscale and also with opacity. Might be a combination of both that ends up being used in the next version.
[Dons evil cloak]

Or, something small and sneaky, like a pixel changing.

[Removes cloak]

On second thought, that would kill the charm of it.

Nice work! I would suggest changing the blue font color so attacks are more easily readable
I've had a talk with him about color balance and contrast levels. Improving colors is on his plan for the next version.

Appreciate the feedback

Hey nice job. I think you should add a timer. The faster you answer the question, the greater the hit. It’s a nice challenge code-wise and adds a little stress to the game, as us dads can’t realistically subtract 19 from 56 in less than 4 seconds.
Great idea! Appreciate the feedback.
Nicely done. How much did dad/mom help?
My guess would be quite a lot, since the artwork is not something a child would make despite it looking like its made for children.
You'd be surprised what kids are capable of. An 8 year old could easily create pixel art like this with the right tools.
I learned how to use Autodesk animator on DOS when I was 7 years old. Then again, I have been a geek all my life.
We had art lessons in primary school back in prehistoric times when I was that age (sixty years ago). Plenty of us could create more complex artwork than that.
On paper, his art skills are quite underwhelming compared to what I've seen other kids do. So yes, totally agree with you.

Also 32x32 limited reduces complexity a lot when trying to make a visual.

Kids dad here. When it was time to do images, I figured something like photoshop would be way too much for him. So I found a browser based sprite editor. The 32x32 grid simplified things and actually helped him.

Then one day I explained how the animation worked in the Piskel app (it had layers and frames). I came back an hour later and he had that flying snake that absolutely blew me away. He originally had it at 4 frames we gave him feedback that he needs more frames to be smooth. He upped it to 8.

The graphics is where had the least guidance from parents. We were focused on the code/logic aspects.

From his past experience with HTML/CSS, he can already make a page, has VSCode, knows how to use VSCode to commit & sync. The big thing this time was that he had to learn a lot of JS and had to get much more proficient with CSS.

So my guidance was more of a set of hints as needed, for example "you want to boxes side by side, figure out how to do that using CSS" .. then he'd go away and talk to Gemini and ultimately Gemini would give him multiple approaches that he could try.

When it came to animation, I explained that there are many ways to animate (CSS, JS, etc) and guided him towards animated images. Basically, we "chatted" about a feature, I gave him some hints, then he went off and talked to Gemini for syntax and wrote the code. Many features he knew exactly what to do. If he wasn't sure, he'd have a discussion with me.

Basically, I was like a senior dev sounding board. He was the junior developer doing the work. Gemini was his Google/StackOverflow.

[flagged]
It would have been a great game in 1998 when plain javascript was what everyone was using.

But OP has clearly put a lot of effort in and still gotten not-great results because they aren't making use of more modern tooling (game engines etc) to turn each hour of effort into more productivity.

... or perhaps OP has gotten not-great results because _they are a small child_.

Children do not need to "turn each hour of effort into more productivity". They need to learn stuff (and feel good about their learning, so they keep doing it).

I believe the comment was satirical.
Wait what? No this is interesting because it was built by a 9 year old using ai.
Excellent - keep rocking!
That is awesome. Keep up the good work little buddy. Love the retro feel of the wizard. :)
The scorpion is not very good at math (lucky for me!) progress bar for my charge level (or change color of attack once it’s charged) would help and a more readable color scheme.

Keep it up! Just don’t add micro-transactions :P

Nice :) I feel the HP should be removed during / after the animation rather than before it. Agree with the comment on having better hit when answering faster, that would be fun
I cant tell what my charge level is. This is crazy though, congrats... Look at the blog to see how he did it mostly using ai. It looks like the dad set it up like a series of challenges to get the kid familiar w using ai then he was able to make a game. Nice work!
Kid's dad here. My goal was only to "teach him to code" .. the motivation to build a game was all his. He mixed something something he loves (fantasy worlds) with something that's useful (learning to code), so I think that helped with the motivation to keep going.
Great work, I bet you're a very proud parent!

Echoing the other comment - as a tired dad, I struggle with the Math questions :)

As a parent, I'm very proud.

As a programmer, I'm surprised - I can say a few words (eg: "look into css background styles") and he can say it to Gemini and slowly figure out stuff on his own.

As a test player of this game - I don't want to think so much, but if it means he'll learn some math in the process, I'll do it. :)

Very cool. One of the attacks was blocked due to insufficient charge. Has he considered a charging status indicator e.g., bar or countdown timer?
charging isn't clear here. He plans to fix this for the next version.

We've talked about using a visual indicator, perhaps greying out uncharged attacks.

Yeah that's cool. Will try it again once new version ready.
there's a newsletter link on his page. He'll type up a message to send when the next version is out!
Amazing. Younger people (and people new in any field) often think of intersting approaches without the blessing/curse of "best practices." The process for creating the game was very good and very logical way to learn a new field.

I would recommend a couple of small things for the code. Variable names are usually ALL_CAPS if they never change (for instance const PI =3.142) and camelCaseForOtherVariables. snake_case_variables aren't really used in JavaScript, but aren't technically wrong. Also, it's usually good to put variables into nested data structures with hashmaps instead of comparing based upon array index. This is in "the real world" though, in academic computer science algorithms based on position in lists are more common.

If you want to get what we call "Code Review" a good way would be to feed your source code into a LLM to have the LLM give feedback based on your code, and recommend improvements. Most people like Claude best for dealing with code nowadays.

I would also recommend putting your code on Github so that people can check it out.

Very impressive!

Appreciate the feedback on the code style & variables. I raised this previously but perhaps external feedback will be what he needs to get him motivated to clean it up :)
Agree 100%. Since dad helped, I was expecting to see sprites sheets, or some JS classes for some OOP, etc. Was pleasantly surprised to see how "simple" the approach was for such fun output with a decent amount of variety.
This is how cool new ideas arrive each generation
He doesn't understand what a sprite is, or really the motivation behind sprite sheets. To him they're just animated images he made in a tool. Internally he switches the "costumes" of characters (terminology he got from Scratch I believe).
That's so great. So many software engineers (myself included) tend to overcomplicate things.
Could have a virtual numpad
yeah, I think an improvement would be not using alert(). writing the question to a DOM element and then getting the response from an input field would be much more valuable experience for real world applications as web trends have moved away from the heavy use of alerts
this on his plan for the next version! Appreciate the feedback.
Great strongbad vibes for some reason. I loved it!
[flagged]
Frankly, it looks like a scam. It mentions AI and NFTs everywhere, in-app purchases are for “Mint Passes” and “Sticky Coins”, and it tracks users.

What this 9-year old did is different. Maybe it’s a modest game, but they used an LLM as a tool to learn to code, not just to produce AI slop.

It feels crummy that you’ve taken a thread that is about celebrating a kid’s first achievement in creating a game and made it about promoting your gamified app which appears to celebrate everything that is wrong with modern games.

[flagged]
"It looks like a scam" is arguably the most charitable feedback you'll get for launching a NFT-laden product in 2024.
It's not an NFT-laden product, and it wasn't launched in 2024.
Okay... but.. A blog and a newsletter form? What could your 9 year old probably want to message me about? That's honestly a bit much.
We originally posted a link to the game on on reddit in r/programming, but they removed the post because it was an "app demo" and suggested a blog post instead. That got him motivated to write about the game (And I leveraged that motivation to help him learn how to communicate better - structure of a blog posts, etc)

Newsletter was added after people on reddit asked about how they can be notified for v2 of the game :) - I had to help him with the newsletter integration.

Why are you trying so hard to market your 9 year-old's project on multiple aggregators and leaning on his age to do it?

As a parent, is fame really something you want for him?

I believe what he's created is remarkable for his age, and thus worth sharing. The way he used the LLM is very interesting, even to an adult audience.

The feedback received has been incredibly valuable. Not just for improving the game, but also for sparking conversations at home about game mechanics, color balance, coding standards, and even broader concepts like design and flow.

Ultimately, I'm showing him how we do things in the real world - build it, write about it, make sense of the feedback, and iterate.

Looks amazing! Would love to know when the weapon is charged and how much each shot takes.

Btw, this game reminds me of BBS door games. Great stuff.