Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
Hill Climb Racing: trees that break, its README, pictures and GIFs
Mason363ba5f74575f73
diff --git a/LICENSES/OFL-1.1-Teko.txt b/LICENSES/OFL-1.1-Teko.txtnew file mode 100644index 00000000..11fd1f04--- /dev/null+++ b/LICENSES/OFL-1.1-Teko.txt@@ -0,0 +1,93 @@+Copyright 2023 The Teko Project Authors (https://www.github.com/googlefonts/teko)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/docs/media/gallery/hillclimb.gif b/docs/media/gallery/hillclimb.gifnew file mode 100644index 00000000..48c73453Binary files /dev/null and b/docs/media/gallery/hillclimb.gif differdiff --git a/docs/media/hillclimb.gif b/docs/media/hillclimb.gifnew file mode 100644index 00000000..9e86c74bBinary files /dev/null and b/docs/media/hillclimb.gif differdiff --git a/docs/media/thumb_hillclimb.png b/docs/media/thumb_hillclimb.pngnew file mode 100644index 00000000..e10def72Binary files /dev/null and b/docs/media/thumb_hillclimb.png differdiff --git a/games/hillclimb/README.md b/games/hillclimb/README.mdnew file mode 100644index 00000000..1f94fc90--- /dev/null+++ b/games/hillclimb/README.md@@ -0,0 +1,88 @@+> **Hill Climb Racing is a [NumPlay](../../README.md) game that comes on its own.** It is too big to sit next to NumPlay. Get `HillClimbRacing.nwa` from the [latest release](https://github.com/Mason363/NumPlay/releases/latest).++<p align="center">+ <img src="src/icon.png" width="84" alt="Hill Climb Racing icon">+</p>++<h1 align="center">Hill Climb Racing</h1>++<p align="center">+ <b>Newton Bill's ride up the hills, on the NumWorks calculator.</b><br>+ Ten stages, eight vehicles and every one of their upgrades: drive as far as your fuel and Bill's neck allow.+</p>++<p align="center">+ <a href="https://github.com/Mason363/NumPlay/releases/latest/download/HillClimbRacing.nwa"><b>Download HillClimbRacing.nwa</b></a>+ · <a href="#controls">Controls</a>+</p>++<p align="center">+ <img src="../../docs/media/hillclimb.gif" width="640" alt="The Hill Climber up the Countryside's hills, then the Motocross Bike's back flip on the Moon">+</p>++## Highlights++* **Real physics, like the game's:** the chassis and each wheel are bodies of their own, the wheels hang on springs, and the engine turns them against the chassis, so the nose rises when you floor it and you can flip over backwards on a steep hill. In the air, gas tilts you back and brake tilts you forward.+* **Bill's neck:** land on his head, or let the roof of a cave touch it, and it's *Driver down*. Run out of fuel and you roll to a stop. Fuel cans come at the stage's own spacing, as in the game.+* **Coins of 5, 25, 100 and 500**, bigger the further you go, in rows and stacks along the road. **Air time** pays from a second in the air on (25, 50, 75, 100, then *Big air time* 200 to 500, then *Insane air time* from 1,000 up to 25,000), every **flip** and **back flip** 1,000, and a **neck flip** (going down in the middle of one) 2,500. Each **level** of the road pays its reward when you reach its end.+* **Ten stages**, each with its own ground, sky, grip, gravity and spacing of fuel, with the game's prices:++ | Stage | Price | |+ | --- | --- | --- |+ | Countryside | free | Rolling hills that get steep and jagged further on |+ | Desert | 35,000 | Steep dunes and rope bridges over canyons, sagging under you |+ | Arctic | 75,000 | The Countryside's hills, but on slippery snow |+ | Highway | 125,000 | Flat and fast at first; the fuel cans get further and further apart |+ | Cave | 150,000 | A ceiling over your head: hit it with Bill and it's over. Fuel every 150, 120 and 90 m |+ | Moon | 175,000 | Low gravity: long jumps, big air time and flips, the Earth in the sky |+ | Mars | 250,000 | Lighter than home, with tunnels now and then |+ | Alien Planet | 750,000 | A slimy, sloped world under a green night |+ | Arctic Cave | 800,000 | A cave of ice, slippery, with icicles hanging from its roof |+ | Forest | 850,000 | Bunches of pine trees in the way: ram them or push them over |++* **Eight vehicles** that each drive their own way, with the game's prices and their four upgrades, each in the game's number of levels and at its prices:++ | Vehicle | Price | Upgrades |+ | --- | --- | --- |+ | Hill Climber | free | Engine, Suspension, Tires, 4WD |+ | Motocross Bike | 75,000 | Engine, Suspension, Tires, Air Control |+ | Monster Truck | 100,000 | Engine, Suspension, Tires, 4WD |+ | Quad Bike | 175,000 | Engine, Suspension, Tires, Air Control (four-wheel drive) |+ | Race Car | 250,000 | Engine, Suspension, Tires, Downforce |+ | Rally Car | 750,000 | Engine, Suspension, Tires, Downforce |+ | Dune Buggy | 800,000 | Engine, Suspension, Tires, Fuel |+ | Tank | 1,000,000 | Engine, Suspension, Tracks, Fuel |++* **The game's own look:** its vehicles, wheels and Bill, its coins and fuel cans, each stage's sky, surface and ground, the pedals and the RPM and boost meters on the dashboard, the garage and the stage cards, all from the game itself.+* **Saved as you go:** coins, what you own and its upgrades, and your best distance on each stage with each vehicle. A run left halfway keeps its coins. The save is also copied into `hillclimb_saves.py`, so installing the app again doesn't erase it.++<table>+ <tr>+ <td align="center" width="33%"><img src="docs/countryside.png" width="100%" alt="The Hill Climber on the Countryside, coins ahead"><br>The Countryside</td>+ <td align="center" width="33%"><img src="docs/bridge.png" width="100%" alt="The Hill Climber on a rope bridge over a canyon in the Desert"><br>A rope bridge in the Desert</td>+ <td align="center" width="33%"><img src="docs/moon.png" width="100%" alt="The Motocross Bike's back flip on the Moon"><br>A back flip on the Moon</td>+ </tr>+ <tr>+ <td align="center"><img src="docs/cave.png" width="100%" alt="The Hill Climber in the Cave, under its rocky ceiling"><br>The Cave</td>+ <td align="center"><img src="docs/forest.png" width="100%" alt="The Hill Climber ramming the Forest's pine trees"><br>The Forest's trees</td>+ <td align="center"><img src="docs/garage.png" width="100%" alt="The garage: the Hill Climber and its four upgrades"><br>The garage</td>+ </tr>+</table>++## Controls++| Key | Action |+| --- | --- |+| **Right**, **OK** or **EXE** (or 6) | Gas; in the air, tilt back |+| **Left** (or 4) | Brake, then reverse; in the air, tilt forward |+| **Back** | Pause: Resume, Restart, Garage, Quit game (it asks first) |+| **Home** or **On/Off** | Keep the run's coins and quit |+| In the menus | **Left**, **Right** to choose a vehicle or a stage, **Down** to the upgrades, **OK** to buy or go, **Back** to go back |++## Credits++**Hill Climb Racing** is [Fingersoft](https://fingersoft.com)'s game (2012), with Newton Bill at the wheel. This version is written in C for NumPlay: its physics, stages and menus are made for the calculator, and its pictures (the vehicles, Bill, the coins, the stages' grounds and skies, the pedals, meters, icons and the logo) are the game's own, as the [Hill Climb Racing Wiki](https://hillclimbracing.fandom.com) keeps them; the prices, upgrades, stages' fuel and levels, and the coins' and bonuses' values are the game's as the wiki records them. Its text is set in **Teko** (SIL Open Font License, [license](../../LICENSES/OFL-1.1-Teko.txt)). It is an unofficial fan game, not affiliated with Fingersoft.++`tools/fetch.py` gathers the wiki's pictures and the font, and `tools/pack.py` turns them into `src/data.bin` (committed, so building needs no network).++Build: `make` (needs `arm-none-eabi-gcc` and Node.js for nwlink). `make test` plays it on a computer with the sanitizers (tests/check.py).diff --git a/games/hillclimb/docs/bridge.png b/games/hillclimb/docs/bridge.pngnew file mode 100644index 00000000..035a989dBinary files /dev/null and b/games/hillclimb/docs/bridge.png differdiff --git a/games/hillclimb/docs/cave.png b/games/hillclimb/docs/cave.pngnew file mode 100644index 00000000..04fbea63Binary files /dev/null and b/games/hillclimb/docs/cave.png differdiff --git a/games/hillclimb/docs/countryside.png b/games/hillclimb/docs/countryside.pngnew file mode 100644index 00000000..f9d7e554Binary files /dev/null and b/games/hillclimb/docs/countryside.png differdiff --git a/games/hillclimb/docs/forest.png b/games/hillclimb/docs/forest.pngnew file mode 100644index 00000000..be03895dBinary files /dev/null and b/games/hillclimb/docs/forest.png differdiff --git a/games/hillclimb/docs/garage.png b/games/hillclimb/docs/garage.pngnew file mode 100644index 00000000..52434b95Binary files /dev/null and b/games/hillclimb/docs/garage.png differdiff --git a/games/hillclimb/docs/moon.png b/games/hillclimb/docs/moon.pngnew file mode 100644index 00000000..ff839f80Binary files /dev/null and b/games/hillclimb/docs/moon.png differdiff --git a/games/hillclimb/docs/stages.png b/games/hillclimb/docs/stages.pngnew file mode 100644index 00000000..a22880bdBinary files /dev/null and b/games/hillclimb/docs/stages.png differdiff --git a/games/hillclimb/src/car.c b/games/hillclimb/src/car.cindex 3f35e2fe..77e811e1 100644--- a/games/hillclimb/src/car.c+++ b/games/hillclimb/src/car.c@@ -44,7 +44,7 @@ void car_init(Car *c, int veh, const uint8_t lv[4], float x) {const VehDef *d = &vehicles[veh];const VehArt *a = &veh_art[veh];memset(c, 0, sizeof *c);- c->veh = veh, c->nw = a->naxles, c->tree_broken = -1;+ c->veh = veh, c->nw = a->naxles, c->tree_broken = -1, c->tree_hurt_id = -1;float eng = 0, sus = 0, tir = 0, awd = d->awd, air = d->air, down = 0;for (int u = 0; u < 4; u++) {float f = (float)(lv[u] - 1) / (float)(d->max[u] - 1);@@ -376,6 +376,21 @@ void car_step(Car *c, float gas, float brake, bool fuel) {/* a little air: nothing spins forever */c->ch.w *= 1 - 0.3f * DT;find_contacts(c);+ /* a tree hit fast snaps at once: the vehicle goes through, a little slower */+ for (int i = 0; i < ncon; i++) {+ Contact *k = &con[i];+ if (k->tree < 0 || !stage_tree_standing(k->tree)) continue;+ float vn = (k->b->vx - k->b->w * k->ry) * k->nx + (k->b->vy + k->b->w * k->rx) * k->ny;+ if (vn > -3.5f) continue;+ stage_tree_fall(k->tree);+ c->tree_broken = k->tree;+ c->ch.vx *= 0.85f;+ for (int w = 0; w < c->nw; w++) c->wh[w].vx *= 0.85f;+ }+ for (int i = 0; i < ncon;) { /* (the pushes of trees that fell are gone) */+ if (con[i].tree >= 0 && !stage_tree_standing(con[i].tree)) con[i] = con[--ncon];+ else i++;+ }prepare_contacts();prepare_joints(c, gas, brake, fuel);for (int it = 0; it < ITER; it++) {@@ -383,11 +398,19 @@ void car_step(Car *c, float gas, float brake, bool fuel) {solve_contacts();}/* trees that took too hard a knock fall */- for (int i = 0; i < ncon; i++)- if (con[i].tree >= 0 && con[i].jn > 55.0f) {+ for (int i = 0; i < ncon; i++) {+ if (con[i].tree < 0) continue;+ float knock = 0; /* (all the pushes on that tree this step) */+ for (int j = 0; j < ncon; j++)+ if (con[j].tree == con[i].tree) knock += con[j].jn, con[j].jn = 0;+ /* a hard knock, or pushing on it a while */+ if (c->tree_hurt_id != con[i].tree) c->tree_hurt_id = con[i].tree, c->tree_hurt = 0;+ c->tree_hurt += knock;+ if (knock > 300.0f || c->tree_hurt > 700.0f) {stage_tree_fall(con[i].tree);c->tree_broken = con[i].tree;}+ }integrate(&c->ch);for (int i = 0; i < c->nw; i++) {integrate(&c->wh[i]);diff --git a/games/hillclimb/src/car.h b/games/hillclimb/src/car.hindex e81fa4f0..94849384 100644--- a/games/hillclimb/src/car.h+++ b/games/hillclimb/src/car.h@@ -34,6 +34,8 @@ typedef struct {float wob[2], wobv[2]; /* Bill's head nodding on its neck (chassis frame) */float last_vx, last_vy;int tree_broken; /* a tree knocked down this step, or -1 */+ int tree_hurt_id; /* the tree being pushed on, and how hard so far (N s) */+ float tree_hurt;} Car;/* levels: the vehicle's four upgrades (1 and up) */diff --git a/games/hillclimb/src/run.c b/games/hillclimb/src/run.cindex d81ca0b5..a46c1192 100644--- a/games/hillclimb/src/run.c+++ b/games/hillclimb/src/run.c@@ -179,8 +179,9 @@ void run_frame(uint32_t keys) {if (c->tree_broken >= 0) {float tx;if (stage_tree(c->tree_broken, &tx))- for (int s = 0; s < 6; s++)- particle(tx, stage_floor(tx) + 0.6f + rndf() * 1.4f, rndf() * 3, rndf() * 2, 0.7f, 0.35f, 0);+ for (int s = 0; s < 14; s++)+ particle(tx, stage_floor(tx) + 0.3f + rndf() * 2.0f, c->ch.vx * 0.5f + rndf() * 4 - 1, rndf() * 4, 0.9f,+ 0.3f + rndf() * 0.2f, 0);}/* fuel burns while the run goes on */if (!run.over && run.fuel > 0) {@@ -390,15 +391,11 @@ static void draw_trees(void) {}if (tx > x1w) break;float ty = stage_floor(tx), sc = s / (img(IMG_TREE_TOP)->ppm4 / 4.0f);- if (stage_tree_standing(k)) {- /* a pine: the trunk, then three tiers of branches, each smaller */- gfx_image(IMG_TREE_TRUNK, scr_x(tx), scr_y(ty) + 2, sc, 0, 255);- for (int i = 0; i < 3; i++)- gfx_image(IMG_TREE_TOP, scr_x(tx), scr_y(ty + 0.75f + 0.55f * (float)i), sc * (1 - 0.18f * (float)i), 0, 255);- } else { /* knocked down: lying ahead */- gfx_image(IMG_TREE_TRUNK, scr_x(tx + 0.4f), scr_y(ty + 0.2f), sc, -1.35f, 255);- gfx_image(IMG_TREE_TOP, scr_x(tx + 1.5f), scr_y(ty + 0.25f), sc, -1.45f, 255);- }+ if (!stage_tree_standing(k)) continue; /* (knocked down: gone in a burst of needles and bark) */+ /* a pine: the trunk, then three tiers of branches, each smaller */+ gfx_image(IMG_TREE_TRUNK, scr_x(tx), scr_y(ty) + 2, sc, 0, 255);+ for (int i = 0; i < 3; i++)+ gfx_image(IMG_TREE_TOP, scr_x(tx), scr_y(ty + 0.75f + 0.55f * (float)i), sc * (1 - 0.18f * (float)i), 0, 255);}}diff --git a/games/hillclimb/tools/docpics.py b/games/hillclimb/tools/docpics.pynew file mode 100644index 00000000..483fbfe5--- /dev/null+++ b/games/hillclimb/tools/docpics.py@@ -0,0 +1,12 @@+#!/usr/bin/env python3+"""The README's pictures from tests/play's screenshots: docpics.py OUT.png SHOT.ppm [WIDTH HEIGHT] (smaller: for+thumbnails), kept small with a palette of 256 colours."""+import sys++from PIL import Image++out, src = sys.argv[1], sys.argv[2]+im = Image.open(src).convert("RGB")+if len(sys.argv) > 4:+ im = im.resize((int(sys.argv[3]), int(sys.argv[4])), Image.LANCZOS)+im.quantize(colors=256, method=Image.MEDIANCUT, dither=Image.NONE).save(out, optimize=True)