When it breaks, become a detective
A bug is a clue about a difference between what you meant and what you wrote. First decide which kind of problem you have: does the program fail to build, close while running, or run with the wrong behavior?
1. Make it repeatable
Describe the shortest steps that cause it: “Start the game, hold Right, then touch a star.” Save your work before experimenting.
2. Find the first wrong fact
Check the relevant input, position, score, or state flag. The wrong picture may simply be showing an earlier mistake.
3. Change one thing
Make the smallest correction, rebuild, and repeat exactly the same steps. Then check that the surrounding behavior still works.
Read a compiler message
The compiler points to a file, line, and column, followed by an error code and explanation. Fix the first useful error first; later messages can be side effects of the same missing word.
star-collector.smile(3,1): error SML3303:
Variable 'Scoree' must be declared because Option Explicit is enabled for this source.
This is the message from a tiny example containing a misspelled variable on line 3. Your file's line and column will be different. Here, Scoree is probably meant to be Score.
| Clue | Likely cause | What to check |
|---|---|---|
SML3303 | A name is undeclared under Option Explicit. | Compare its spelling with the Dim declaration. Declare it only if you really need a new variable. |
SML3304 | A value has the wrong type. | Score = "ten" tries to store Text in a Number. Use a number for arithmetic and a separate Text value for words. |
SML2001 | An expected word or block ending is missing. | Check the indicated line and the block immediately above it. Every If needs End If; a Sub needs End Sub. |
SML3308 | A text operation mixes incompatible types or uses an unsupported operator. | Keep numbers numeric. In a game HUD, use Draw Text for the label and Draw Number for the score. |
SML3021 | A function or routine name is unknown. | Check its spelling. For a library call, confirm the package/source reference and the matching Import alias. |
The typo, Text-to-Number, and missing-End If examples were checked against the available native SMILE compiler when this guide was written. The complete diagnostic reference lives in the official language documentation.
Try fixing a tiny broken program
This program intentionally contains two mistakes. It is a debugging exercise, not a working example.
Option Explicit
Dim Score As Number
Scoree = 3
Score = "four"
Print Score
First change Scoree to Score. Then change "four" to 4. The final printed value is 4 because the second assignment replaces the first.
It runs, but something feels wrong
| What you see | Where to investigate | Small experiment |
|---|---|---|
| The player leaves a trail. | Drawing order. | Check that Clear runs before drawing every frame. |
| The game shows an empty window. | The main loop and presentation. | Draw one bright rectangle at a known position, then call Show Screen. |
| Movement happens only when a key repeats. | Input. | Use Key_Held for continuous movement. Keep Get Key for actions such as menu choices. |
| The player speeds up on another computer. | Timing. | Use elapsed time rather than adding the same distance on every frame. |
| The player partly leaves the arena. | Boundary math. | The largest X is the right wall minus the player's width. |
| Stars count from far away. | The hitbox test. | Check that horizontal and vertical overlap are joined with And. |
| A new round keeps the old score. | Reset state. | Confirm ResetGame assigns Score = 0 and is actually called. |
In a graphics game, put temporary values on screen just before the main loop's Show Screen:
Draw Text "Player X" At 32, 110 Size 18 Color WHITE
Draw Number PlayerX At 130, 110 Size 18 Color YELLOW
In a console example, Print Score is a quick way to inspect a value. Remove temporary displays once they have answered your question. If Visual Studio debugging is configured, set a breakpoint near the suspected update and inspect its values there.
In DrawGame, temporarily add Draw Rectangle StarX, StarY, StarSize, StarSize, MAGENTA. You can now see the exact hitbox used by the collision test.
Choose your next game
Reuse one idea from Star Collector and add one new idea. Finish a small playable version before adding effects, menus, or more levels.
| Build next | What you already know | One new idea to study | Official example |
|---|---|---|---|
| Catch the falling stars | Held keys, overlap, score, and restart. | Make the star's Y position increase over time. Reset it above the arena when caught or missed. | Remix Star Collector. |
| Paddle Ball | Movement, timing, boundary limits. | A moving ball has velocity. A bounce changes the relevant velocity's sign. | Paddle Ball teaching source. |
| Snake | Food placement, collection, score. | Store a trail of grid cells, grow it, and prevent the head from hitting the body. | Snake project and model. |
| Brick Breaker | Ball movement and rectangle tests. | Use an array to remember which bricks remain. | Brick Breaker teaching source. |
| Maze Muncher | Grid movement, collecting, game states. | Parse a tile map and choose legal moves for enemies. | Maze Muncher project. |
The official games may need additional source files, maps, sounds, and project settings. Copy or open their whole project, then read its README. A Program-NoDemo.smile file keeps the playable game while removing its automatic attract demo; select it as the project's StartupFile. Snake also needs SnakeModel.smile.
Grow your toolkit when the game needs it
More things on screen
Learn loops and arrays to update a row of bricks or a list of pickups without copying the same code again and again.
Better organization
Learn Types, Classes, and Modules when related values and behaviors need a clear home.
Pictures and sound
Use graphics, input, and audio to replace simple shapes with images and add feedback when something happens.
Maps, cameras, and battles
Explore the library guide for Smile.Game, Smile.RPG, and the other source packages.
An ambitious 3D path
Study Arena and elemental effects to see how an arena and reusable Fire, Water, and Earth effects fit into a larger native SMILE program.
Those larger projects still repeat the same story: get input, update state, draw, and present. Bigger art does not replace those foundations.
A small finished game is a real achievement
Before calling your game finished, ask someone else to play it without instructions from you. Watch where they get confused, then improve the on-screen instructions or feedback.
- Can a new player understand the goal and controls?
- Can the game start, finish, and restart cleanly?
- Do the score and on-screen messages agree with the game rules?
- Can the window close normally?
- Does the complete project work from another folder with its required assets?
Keep a working copy before your next experiment. Add one feature, test it, and keep going.