From d0863cbc9e6276776eecfbdab3f95e3bf33cfeef Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Mon, 7 Apr 2025 18:53:49 +0100 Subject: polish --- Makefile | 5 +- res/tutorial_black_white.png | Bin 0 -> 595 bytes res/tutorial_blue_1.png | Bin 0 -> 585 bytes res/tutorial_blue_2.png | Bin 0 -> 588 bytes res/tutorial_blue_clone.png | Bin 0 -> 573 bytes res/tutorial_direction_red.png | Bin 0 -> 601 bytes res/tutorial_red_yellow.png | Bin 0 -> 572 bytes src/all.c | 21 ++++++--- src/index.html.in | 105 +++++++++++++++++++++++++++++++++++++---- src/tick.c | 2 +- src/types.c | 4 +- 11 files changed, 118 insertions(+), 19 deletions(-) create mode 100644 res/tutorial_black_white.png create mode 100644 res/tutorial_blue_1.png create mode 100644 res/tutorial_blue_2.png create mode 100644 res/tutorial_blue_clone.png create mode 100644 res/tutorial_direction_red.png create mode 100644 res/tutorial_red_yellow.png diff --git a/Makefile b/Makefile index a652921..c3bf778 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,10 @@ build/main.wasm.b64: build/main.wasm build/index.html: src/index.html.in build/main.wasm.b64 build/music.mp3.b64 \ build/continue.png.b64 build/exit.png.b64 build/pause.png.b64 build/play.png.b64 build/restart.png.b64 \ build/nelson.png.b64 build/nelson_left.png.b64 build/nelson_up.png.b64 \ - build/nelson_right.png.b64 build/nelson_down.png.b64 + build/nelson_right.png.b64 build/nelson_down.png.b64 \ + build/tutorial_black_white.png.b64 build/tutorial_red_yellow.png.b64 \ + build/tutorial_direction_red.png.b64 build/tutorial_blue_1.png.b64 \ + build/tutorial_blue_2.png.b64 build/tutorial_blue_clone.png.b64 mkdir -p build clang -E -P -undef -nostdinc -x c -o build/index.html src/index.html.in diff --git a/res/tutorial_black_white.png b/res/tutorial_black_white.png new file mode 100644 index 0000000..990804a Binary files /dev/null and b/res/tutorial_black_white.png differ diff --git a/res/tutorial_blue_1.png b/res/tutorial_blue_1.png new file mode 100644 index 0000000..b289564 Binary files /dev/null and b/res/tutorial_blue_1.png differ diff --git a/res/tutorial_blue_2.png b/res/tutorial_blue_2.png new file mode 100644 index 0000000..0c82bb2 Binary files /dev/null and b/res/tutorial_blue_2.png differ diff --git a/res/tutorial_blue_clone.png b/res/tutorial_blue_clone.png new file mode 100644 index 0000000..c8edb68 Binary files /dev/null and b/res/tutorial_blue_clone.png differ diff --git a/res/tutorial_direction_red.png b/res/tutorial_direction_red.png new file mode 100644 index 0000000..7ade0dc Binary files /dev/null and b/res/tutorial_direction_red.png differ diff --git a/res/tutorial_red_yellow.png b/res/tutorial_red_yellow.png new file mode 100644 index 0000000..6d56825 Binary files /dev/null and b/res/tutorial_red_yellow.png differ diff --git a/src/all.c b/src/all.c index b118a16..cf52eca 100644 --- a/src/all.c +++ b/src/all.c @@ -390,8 +390,10 @@ static void restart_level(Game* game) { xmemcpy(&game->state.placeableCells, &levels[level].placeableCells, sizeof(game->state.placeableCells)); } -static void update(Game *game, uint64_t now, Arena a) { +static int update(Game *game, uint64_t now, Arena a) { const int offset_width = game->ui.width - GRID_OFFSET_X; + + int tutorial = 0; switch (game->input) { int x, y; @@ -451,6 +453,7 @@ static void update(Game *game, uint64_t now, Arena a) { restart_level(game); break; case BUTTON_BACK: + tutorial = 1; break; case BUTTON_PLAY: game->state.playing = !game->state.playing; @@ -495,6 +498,8 @@ static void update(Game *game, uint64_t now, Arena a) { tick(game, a); } + + return tutorial; } #if SDL @@ -677,10 +682,12 @@ void game_init(void) { perm.end = heap + MEM_SIZE; game = new(&perm, 1, Game); - xmemcpy(&game->state.grid, &levels[0].grid, sizeof(game->state.grid)); - game->state.goalx = levels[0].goalx; - game->state.goaly = levels[0].goaly; - game->state.playing = 0; + game->state.currentLevel = 0; + restart_level(game); + + for (int i = 0; i < N_BUTTONS; i++) { + game->state.buttonStates[i] = BUTTON_STATE_IDLE; + } } __attribute((export_name("game_render"))) @@ -694,11 +701,11 @@ DrawList *game_render(int width, int height, int mousex, int mousey) { } __attribute((export_name("game_update"))) -void game_update(int input, int mousex, int mousey, int now) { +int game_update(int input, int mousex, int mousey, int now) { game->input = input; game->ui.mousex = mousex; game->ui.mousey = mousey; - update(game, now, perm); + return update(game, now, perm); } #endif diff --git a/src/index.html.in b/src/index.html.in index 46d39e4..5414f09 100644 --- a/src/index.html.in +++ b/src/index.html.in @@ -11,9 +11,9 @@ html, body { overflow: hidden; text-align: center; width: 100%; + color: white; } h1 { - color: white; margin: 0; } button { @@ -22,9 +22,84 @@ button { margin: 0.3em; width: 25%; } + +canvas { + margin: auto; +} - +
+

Depths of the Mind

+ +

+ The mind is an intricate thing, with many tiny components working together + in perfect harmony... Until something came in and messed everything up! +

+ +

+ If you want to set all the pieces of the mind right, you'll need to know how + it works! +

+ + + +

+ The structure of the brain consists of black blocks filling a white void. +

+ + + +

+ Black blocks will turn red when clicked (if you have red in your inventory on the left). + While the brain is running, black blocks next to red blocks will turn red! + Red blocks will eventually tire to yellow, and then back to black. They don't stay red very long! + This is what allows the brain to send signals along a series of black blocks. + Yellow blocks can be placed with a right click on a black block (if you have one in your inventory) +

+ + + +

+ Sometimes, only one side of a block turns red. + When this happens, it will try to move in that direction (and leave a yellow behind it) + but if it cannot it will turn clockwise and try again. +

+ + + + + +

+ Blue blocks need to be moved around to keep things running smoothly! + When a blue block is touched by a single red block, it will start rolling + away from it. + Each level has a goal in faint red which needs at least one blue block to be delivered to it. + Some levels will also have faint blue areas that create new blue blocks for you! +

+ + + +

+ Finally, if a blue block touches a red block while in motion it will be cloned! + One will be left behind and the other will continue. +

+ + +
+ +