Where to start with LittleJS for game design
_________________
I’d use its examples:
1. Hello World → Text: change the displayed words and their position.
2. Shapes → Colors: change a shape’s size, position, and color.
3. Input: examine how keyboard, mouse, and touch input are handled.
4. Top Down Game: study movement once the smaller examples make sense.
5. Tile Layer → Custom Editor: investigate rooms, walls, and keys later.
___
My suggested first goal: “I can move one character around a small room.” Not an entire roguelike, map editor, inventory, and music system at once.
__
## How to turn experimenting into learning
Use this small practice cycle:
- Predict: “Changing this number should move the object farther right.”
- Edit: change just that number.
- Run: check whether your prediction was right.
- Explain: write one sentence describing what the change did.
- Rebuild: try making the same change again without looking at the answer.
For your first session, aim to change three things in an example and explain each one. That is a more manageable target than “finish a game.”
As you work, keep a short vocabulary list:
| Concept to investigate | Question to answer in your own project |
|---|---|
| Variables |
Where does the game keep the player’s position? |
| Functions |
Which piece of code draws the player? |
| Conditions |
Where does it decide whether movement is allowed? |
| Arrays |
How could I represent a row of map tiles? |
| Objects |
How could I group a character’s position and health? |
| Updating and drawing |
Which code changes the game, and which code displays it? |
Treat these as questions to explore, not material you must memorize before starting.
__
## Use AI as a tutor, not just a code dispenser
Here is a prompt you can reuse with whichever AI app you prefer:
> I am learning JavaScript using the LittleJS example browser. Help me make one small change at a time. Explain only the code involved in that change. Ask me to predict what will happen before giving the answer. Do not rewrite the entire project or introduce extra features. Use the actual code I paste, rather than guessing LittleJS function names.
When something breaks, try:
> Here is my code and the exact error message. Help me locate the problem. Give me a hint first, then the smallest correction, and explain why it fixes the error.
And after getting something working:
> Give me a similar small exercise that I must solve myself. Do not show the solution yet.
That approach fits the distinction you were making earlier: the generated demo becomes some thing you study and alter, rather than just something you possess.
## A first project tailored to your interests
I’d suggest a tiny “key and door” room:
1. Display a player and a room.
2. Add movement.
3. Stop movement at walls.
4. Place one collectible key.
5. Make one door require that key.
6. Display a short victory message.
Citations:
[1] LittleJS Example Browser