- D 51.7%
- HTML 19.5%
- Python 14.7%
- Shell 12.6%
- Java 1.5%
- assets/splash.png is the logo's shine as 70 frames, played by SplashStyle.playFrames. - web/build_web.conf: --splash-frames plays them while the game downloads; the logo is 102 px now. - tools/build_web.sh from parin_kit, and parin_kit pinned to the commit with the splash frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| android | ||
| assets | ||
| source | ||
| tools | ||
| web | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| dub.json | ||
| dub.selections.json | ||
| dub.settings.json | ||
| README.md | ||
Crystal Climb
A black and white puzzle platformer in the spirit of Go Up (Atari ST, 1987): blast holes, trap the chasers, gather the crystals and climb out. Ten levels, a level editor, shareable levels, German and English, desktop and browser.
Built with Parin and parin_kit,
from the parin_game_template. The rules are
parin_kit's genre/platformer/dig_runner.
Playing
| Mouse (like Go Up) | Keyboard | Gamepad | |
|---|---|---|---|
| Run, climb | The man runs toward the crosshair | Arrows or W A S D | D-pad |
| Blast the brick behind you | Left button | Space, J or Ctrl | A |
| Pause | P or Esc | Start |
- Bricks can be blasted, stone can't. You can only blast the brick behind you at your feet, the one you just ran over. Standing in a narrow hole (walls on both sides), you blast the brick below you and dig deeper.
- Holes grow back after a few seconds. Whoever is inside then dies.
- Ladders can be climbed and stood on. On zip lines you hang and move along; down lets go. You can't jump.
- A chaser touching you costs a life, and the level starts over. Every won level gives a bonus and a life.
- Chasers are a bit slower than you, always take the same way, and don't see holes, so they can be lured in. A blinking arrow at the top shows where a dead one drops back in.
- The speaker in the corner of the title screen and in the status bar mutes. The volumes are in the options.
- How to play on the title screen explains it with pictures.
The editor and your own levels
Editor on the title screen. Pick a piece in the bar at the bottom (or 1 to 9) and draw with the left button; the right button erases (with the rectangle tool too), the middle button picks. P, R and F are pencil, rectangle and fill, Ctrl+Z and Ctrl+Y undo and redo, Enter plays the level at once, Esc opens the menu (title, author, save, new level, help, title screen), H the tutorial. The tutorial also opens the first time the editor does.
My levels keeps your levels (in saves/my_levels.ccl, in the browser's storage on the web): play, edit, copy,
delete, and share them:
- Download one level or all as a
.cclfile. On the desktop they go to the Downloads folder. - Upload file opens the browser's file picker (on the desktop: a list of the
.cclfiles in Downloads). Dropping files on the game adds them too, on every screen. - Copy code / Paste code: a level as a short text code (
CC1:...) for chats.
Levels from the editor and from files give no points, like in Go Up.
Level files
Levels are text: boards of 40x20 characters in level packs (.ccl), so a file holds one level or many, and they can
be edited in a text editor. The levels of the game are assets/levels.ccl (made once by tools/make_levels.py).
Title: First Steps
Author: Crystal Climb
^
* E ^
####H###################### ^
...
| Char | Piece |
|---|---|
|
empty |
# |
brick, can be blasted |
= |
stone |
H |
ladder |
- |
zip line |
^ |
exit ladder, hidden until every crystal is gathered; it must reach the top row |
* |
crystal |
@ |
the start of the man (one) |
E |
a chaser |
dub test checks that every level of the game is valid and that every crystal and the top of the exit ladder can be
reached (walking, climbing, falling and blasting, without chasers). Saving in the editor runs the same check and shows the warning.
Languages
Every text is in assets/lang/de.txt and assets/lang/en.txt, written by tools/make_lang.py, which has both
languages side by side: change texts there and run it. The game starts in German; the flag button under Editor on the
title screen switches, and the choice is saved. The font is Parin's monogram with ä, ö, ü, Ä,
Ö, Ü and ß added (assets/font.png, from tools/make_font.py).
Tuning
Every number of the rules is in assets/tuning.txt: the speeds of the man and the chasers (the same, like in Go Up),
falling, how long holes stay open and take to grow back, lives and points. Debug builds reload the file while the
game runs, and the console (F1, or the key left of 1) changes them: set speed 6, set chaserSpeed 4, apply
restarts the running level with them, level 5 jumps to a level.
Art and sound
assets/sprites.png: every sprite, 8x8, white on transparent (the game draws them in the ink color, so Options > Black on white gives black on white like the ST).tools/make_sprites.pydraws the placeholders; draw over them at the same places.source/art.dnames the cells.- The menus are a two-color skin (
assets/skin.png,tools/make_skin.py, F2 in debug builds edits it). - The sounds and the music are square waves made at the start with parin_kit's synth (
source/assets.d), including the Ode an die Freude jingle. Only the menu clicks are WAV files.
Building
Build with openD's LDC (see the template's notes in AGENTS.md and below). parin_kit is a path dependency
(../parin_kit) while it changes together with the game.
dub run # Debug build.
dub build -b release # Release build.
dub test # Tests: share codes, boards, and that every level can be won.
tools/build_web.sh --serve # Web build at http://localhost:8000/
Testing without the desktop
Debug builds take arguments for screenshots in a headless session:
kwin_wayland --virtual --xwayland --exit-with-session \
"./crystal_climb --scene game --level 3 --time 19 --shot /tmp/shot.png --no-chasers --script go:37,13_go:7,13_b"
--scene is title, game, pause, gameover, victory, editor, editormenu, message, levels, credits, options, controls, help or tutorial (--level picks the
level or the page). --script plays the man: go:x,y runs toward a cell like the mouse does, b blasts, w:2 waits.
Files
| File | What it does |
|---|---|
source/app.d |
Starts the game, the scenes, the debug console and the test arguments. |
source/play_field.d |
The level being played: controls, sounds of events, drawing the field. |
source/board.d |
Boards and level packs, validation, the reachability check, share codes. |
source/rules.d |
The tuning values and assets/tuning.txt. |
source/game_scene.d |
Playing: the campaign with lives and score, or one of your levels. |
source/editor_scene.d |
The editor and its menu. |
source/my_levels_scene.d |
My levels, and importing dropped and uploaded files. |
source/sharing.d |
Downloads, uploads and share codes through parin_kit's core/file_share. |
source/pages_scene.d |
How to play and the editor tutorial. |
source/lang.d |
German and English through parin_kit's core/locale. |
source/art.d |
The sprite sheet and the two colors. |
source/assets.d |
Textures, the font, the synthesized sounds and music. |
source/title_scene.d, options_scene.d, pause_scene.d, game_over_scene.d, credits_scene.d |
The other screens. |
source/mute_button.d |
The mute button of the title and the status bar. |
tools/ |
The scripts that make the art, the font, the texts and the levels, and the web and Android builds. |
Saves
saves/settings.txt (volumes, mute, controls, language, colors) and saves/my_levels.ccl. On the web, saves/ is kept in the browser's IndexedDB.
The look
Every panel, button, slider and title plate is a 9-slice from assets/skin.png: the corners of each part are drawn as
they are, and the edges and the middle stretch. assets/skin.txt says where the parts are in the image, how wide
their corners are, the spacing around them and every color of the game: the text colors of the skin, and the colors
of source/theme.d as theme.<name>. What the file leaves out keeps the default from setupSkin in source/theme.d.
The skin editor
Press F2 in a debug build (dub run) to open the skin editor over the game, and F2 again to go back.
- Left, top: every widget in the skin at the size of the game, on five pages: buttons in every state, links, plates and bars; settings rows (checkbox, toggle, slider, picker, radio, stepper, dropdown, text field); a list box, a text box and a color grid; a panel, a dialog and a window you can drag; and every color. The widgets work, so you can click, type and use the keyboard or a gamepad.
- Left, bottom: the texture with the outline of every part. Click a part to pick it.
- Right: Parts moves and sizes the picked part and its margins, Colors changes any color (hue, saturation,
value, alpha or a hex code like
#ffc448), Spacing changes the text scale, the button depth and the paddings. Guides shows where the 9 pieces of every part meet. - Export saves
assets/skin.txt, and copies the texture toassets/skin.pngwhen you draw it somewhere else. It also writes the splash color toweb/build_web.conf. Changes that aren't exported yet are marked at the top.
The texture and skin.txt reload as soon as they change on disk, also while the editor is closed, so you can keep
Aseprite (or any pixel art editor, or a text editor) open next to the game and see each save right away. Draw straight
into assets/skin.png, or set config.sourcePath in setupSkinEditor (source/app.d) to the file your art tool
exports, like an Aseprite project folder, and Export copies it into the assets.
The editor window grows to twice its size when there is room, so the pixels stay square. Maximize it or press F11 for a bigger view.
The parts
| Part | Rect in skin.png (x, y, w, h) | Margin | Used for |
|---|---|---|---|
panel |
0, 0, 24, 24 | 4 | Panels behind menus, windows |
dialog |
24, 0, 24, 24 | 4 | Dialog boxes (skinDialog) |
inset |
48, 0, 12, 12 | 3 | Checkboxes, toggles, text fields, dropdowns, list boxes, text boxes, scroll bar tracks |
plate |
60, 0, 16, 14 | 4 | The plates behind panel titles |
barFrame |
76, 0, 8, 8 | 2 | The frame of sliders and bars |
barFill |
84, 0, 4, 4 | 1 | The fill of sliders and bars, checks, scroll bar thumbs and the mark of chosen rows |
barTrail |
88, 0, 4, 4 | 1 | The trail of health bars (skinBar) |
grip |
84, 4, 6, 6 | The resize grip of windows (skinWindow) |
|
button |
0, 24, 16, 18 | 4, 4, 4, 6 | A button at rest |
buttonHot |
16, 24, 16, 18 | 4, 4, 4, 6 | A button with the focus, and the focused row of lists |
buttonActive |
32, 24, 16, 18 | 4, 4, 4, 6 | A pressed button. Its face is 1 pixel lower |
buttonDisabled |
48, 24, 16, 18 | 4, 4, 4, 6 | A button that can't be used |
Buttons have a side at the bottom (3 pixels with the outline, buttonDepth), and labels are centered above it.
To add a color of your own, give it a variable in source/theme.d and a line in listThemeColors, and make
themeColors one longer. It shows up in the editor and is saved in skin.txt.
The placeholder skin and sounds come from the scripts in tools/: python3 tools/make_skin.py (needs Pillow) and
python3 tools/make_audio.py (needs numpy and ffmpeg). Change them, or just replace the files they write.
The skin editor
Press F2 in a debug build (dub run) to open the skin editor over the game, and F2 again to go back.
- Left, top: every widget in the skin at the size of the game, on five pages: buttons in every state, links, plates and bars; settings rows (checkbox, toggle, slider, picker, radio, stepper, dropdown, text field); a list box, a text box and a color grid; a panel, a dialog and a window you can drag; and every color. The widgets work, so you can click, type and use the keyboard or a gamepad.
- Left, bottom: the texture with the outline of every part. Click a part to pick it.
- Right: Parts moves and sizes the picked part and its margins, Colors changes any color (hue, saturation,
value, alpha or a hex code like
#ffc448), Spacing changes the text scale, the button depth and the paddings. Guides shows where the 9 pieces of every part meet. - Export saves
assets/skin.txt, and copies the texture toassets/skin.pngwhen you draw it somewhere else. It also writes the splash color toweb/build_web.conf. Changes that aren't exported yet are marked at the top.
The texture and skin.txt reload as soon as they change on disk, also while the editor is closed, so you can keep
Aseprite (or any pixel art editor, or a text editor) open next to the game and see each save right away. Draw straight
into assets/skin.png, or set config.sourcePath in setupSkinEditor (source/app.d) to the file your art tool
exports, like an Aseprite project folder, and Export copies it into the assets.
The editor window grows to twice its size when there is room, so the pixels stay square. Maximize it or press F11 for a bigger view.
The parts
| Part | Rect in skin.png (x, y, w, h) | Margin | Used for |
|---|---|---|---|
panel |
0, 0, 24, 24 | 4 | Panels behind menus, windows |
dialog |
24, 0, 24, 24 | 4 | Dialog boxes (skinDialog) |
inset |
48, 0, 12, 12 | 3 | Checkboxes, toggles, text fields, dropdowns, list boxes, text boxes, scroll bar tracks |
plate |
60, 0, 16, 14 | 4 | The plates behind panel titles |
barFrame |
76, 0, 8, 8 | 2 | The frame of sliders and bars |
barFill |
84, 0, 4, 4 | 1 | The fill of sliders and bars, checks, scroll bar thumbs and the mark of chosen rows |
barTrail |
88, 0, 4, 4 | 1 | The trail of health bars (skinBar) |
grip |
84, 4, 6, 6 | The resize grip of windows (skinWindow) |
|
button |
0, 24, 16, 18 | 4, 4, 4, 6 | A button at rest |
buttonHot |
16, 24, 16, 18 | 4, 4, 4, 6 | A button with the focus, and the focused row of lists |
buttonActive |
32, 24, 16, 18 | 4, 4, 4, 6 | A pressed button. Its face is 1 pixel lower |
buttonDisabled |
48, 24, 16, 18 | 4, 4, 4, 6 | A button that can't be used |
Buttons have a side at the bottom (3 pixels with the outline, buttonDepth), and labels are centered above it.
To add a color of your own, give it a variable in source/theme.d and a line in listThemeColors, and make
themeColors one longer. It shows up in the editor and is saved in skin.txt.
The placeholder skin and sounds come from the scripts in tools/: python3 tools/make_skin.py (needs Pillow) and
python3 tools/make_audio.py (needs numpy and ffmpeg). Change them, or just replace the files they write.
The parts
| Part | Rect in skin.png (x, y, w, h) | Margin | Used for |
|---|---|---|---|
panel |
0, 0, 24, 24 | 4 | Panels behind menus, windows |
dialog |
24, 0, 24, 24 | 4 | Dialog boxes (skinDialog) |
inset |
48, 0, 12, 12 | 3 | Checkboxes, toggles, text fields, dropdowns, list boxes, text boxes, scroll bar tracks |
plate |
60, 0, 16, 14 | 4 | The plates behind panel titles |
barFrame |
76, 0, 8, 8 | 2 | The frame of sliders and bars |
barFill |
84, 0, 4, 4 | 1 | The fill of sliders and bars, checks, scroll bar thumbs and the mark of chosen rows |
barTrail |
88, 0, 4, 4 | 1 | The trail of health bars (skinBar) |
grip |
84, 4, 6, 6 | The resize grip of windows (skinWindow) |
|
button |
0, 24, 16, 18 | 4, 4, 4, 6 | A button at rest |
buttonHot |
16, 24, 16, 18 | 4, 4, 4, 6 | A button with the focus, and the focused row of lists |
buttonActive |
32, 24, 16, 18 | 4, 4, 4, 6 | A pressed button. Its face is 1 pixel lower |
buttonDisabled |
48, 24, 16, 18 | 4, 4, 4, 6 | A button that can't be used |
Buttons have a side at the bottom (3 pixels with the outline, buttonDepth), and labels are centered above it.
To add a color of your own, give it a variable in source/theme.d and a line in listThemeColors, and make
themeColors one longer. It shows up in the editor and is saved in skin.txt.
The placeholder skin and sounds come from the scripts in tools/: python3 tools/make_skin.py (needs Pillow) and
python3 tools/make_audio.py (needs numpy and ffmpeg). Change them, or just replace the files they write.
Web builds
tools/build_web.sh builds the game for the browser into web/. It takes the dependencies from dub describe, so it
works with parin_kit from git or from a path. It needs:
- openD's LDC with druntime for Emscripten: run
opend install xpack-emscriptenonce. - Emscripten 4.0.23, the version Parin recommends: in a clone of emsdk, run
./emsdk install 4.0.23and./emsdk activate 4.0.23. The script findsemccon thePATH, in$EMSDK,~/emsdkor~/Source/emsdk. - Bash, and Python 3 for
--serve.
tools/build_web.sh # Debug build into web/: index.html, .js, .wasm and .data.
tools/build_web.sh --release # Smaller and faster, for uploading.
tools/build_web.sh --serve # Build, then serve web/ at http://localhost:8000/ (Ctrl+C stops).
tools/build_web.sh --wasi # Parin's experimental WASI route. It doesn't work yet, see below.
The page is web/shell.html, written by tools/make_page.py from tools/page.html with the sprite sheet and the
splash logo put in (run it again when they change). Opened as it is, it's a small website without text: a level of the
game with falling crystals, ladders and the man digging a hole for a chaser, around a double frame with the game in
it, sized in whole steps of 320x180, and a button above the frame's right corner for the whole screen. The game runs
in an iframe of the same page with ?play, because raylib makes its canvas as big as the window; index.html?play
alone is the game filling the window. While the game downloads, it shows the splash logo with a progress bar, then
fades into the game's own splash screen. (The splash options in web/build_web.conf are only for build_web.sh's
own page, without web/shell.html.)
Browsers don't run the game from a file, so test it through a server (--serve). To publish on itch.io, put the
web/index.* files in a ZIP, create an HTML project and upload the ZIP. The game keeps its canvas in the top-left
corner of its page, because Parin reads the mouse relative to the page.
The template is ready for the web: it calls raylib only through Parin and parin_kit, hides Quit, the fullscreen
and the vsync option in web builds (canQuit, canChangeFullscreen and canChangeVsync of
parin_kit.core.app.settings), and saves through
parin_kit.core.app.save into ../saves. On the web:
../savesis the folder/savesof the page, which the script keeps in the browser's IndexedDB under the name indub.json. The settings survive reloads, and clearing the site data deletes them. Rename the game, because all itch.io games run on the same site.- Audio starts with the first click, tap or key press, because browsers block it before that.
- The game can't quit or switch to fullscreen. Players use the browser's or itch.io's fullscreen button.
- F5, Ctrl+W and other browser keys go to the browser, so don't make them controls. In Chrome, F1 opens the help, so open the debug console with the key left of 1.
- D can't catch exceptions on the web. A throw stops the game and the page says so. Failed asserts and bounds checks
print
file(line): messagein the browser console (F12) first. - Parin allows 256 textures, sounds, fonts and viewports each on the web.
- With openD, avoid
^^(writex * x). For Emscripten, openD compiles Phobos from source, and thestd.maththat^^pulls in fails there with an internal compiler error.
--wasi builds with Parin's new WASI backend instead of Emscripten and raylib, which
Parin issue #35 proposes as the future web route. In Parin 0.2.3 that
backend is a stub, and the template doesn't build with it:
- Without
--betterc, linking fails with thousands of undefined druntime symbols (_d_nullpointer,_d_arraybounds_index,TypeInfos, ...), because neither openD nor LDC has a druntime forwasm32-wasip1. - With
--betterc,parin_kit/input.ddoesn't compile:ActionMap.findPresetcompares arrays of structs with==, which needsTypeInfo. - With that changed, linking fails on
rename,removeandMakeDirectory(used byparin_kit.core.app.save) andGetCodepointPrevious(raylib, called by Parin'suiuiaddon), which the WASI build doesn't have. - Even a game that links loads, draws and plays nothing: every texture and font fails to load and the game stops at
start with "Assertion failed: null pointer" (tried with the
scenesexample of parin_collection). The page has no canvas yet.
Android builds
tools/build_android.sh packs the web build in web/ into an Android APK that shows the game in a full-screen
WebView. The back button works as Esc, and the game pauses while the app is in the background. It needs:
- A web build: run
tools/build_web.sh --releasefirst, the APK takesweb/as it is. - The Android SDK (platform 37 and its build tools) and a JDK 17 or newer. The script looks for them in
~/Programs/android/sdkand~/Programs/android/jdk. SetANDROID_TOOLSto a folder withsdk/andjdk/in it, orANDROID_HOMEandJAVA_HOME, to use others.
tools/build_android.sh # Debug APK, signed with the debug key of this machine.
tools/build_android.sh --install # Build, install on the phone connected with adb and start it.
tools/build_android.sh --release # Release APK, signed with your release key, for publishing.
tools/build_android.sh --release --install
android/gradle.properties has the settings of the app:
appIdnames the app on the phone and in the Play Store. Two apps with the same id replace each other, and the id can't change after a release.appNameis the name under the icon.orientationissensorLandscapeorsensorPortrait. The phone can turn the game upside down, but not sideways.
The icon is a placeholder in android/app/src/main/res/drawable/: a background, a foreground and a one-color version
of the foreground for themed icons, as vector drawables. The launcher masks it into its shape, and only the middle
66x66 of the 108x108 is sure to show.
Release builds are signed with your own key. Make it once per game, and keep a backup: updates of the app have to be signed with the same key, or phones and the Play Store refuse them.
keytool -genkeypair -keystore android/release.keystore -alias release -keyalg RSA -keysize 4096 -validity 10000
The script asks for the keystore password, or takes it from ANDROID_KEYSTORE_PASSWORD. ANDROID_KEYSTORE,
ANDROID_KEY_ALIAS and ANDROID_KEY_PASSWORD point it at a key somewhere else (see tools/build_android.sh --help).
Keystores are ignored by git. A phone with the debug build on it has to uninstall it before it takes the release build,
because the keys differ.