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
fix physics being bad
Lily Pitiot14fd5c612df4
diff --git a/.github/workflows/dinorun-full.yml b/.github/workflows/dinorun-full.ymlnew file mode 100644index 00000000..3d78f343--- /dev/null+++ b/.github/workflows/dinorun-full.yml@@ -0,0 +1,75 @@+name: Dino inside NumPlay (full launcher build)++# Build on push to the feature branch; manual dispatch is also available if+# the workflow is later added to the repo's default branch. No releases.+on:+ push:+ branches: [add-chrome-dino]+ paths:+ - 'games/dinorun/**'+ - 'games/games.json'+ - 'tools/integrate_dinorun.py'+ - '.github/workflows/dinorun-full.yml'+ workflow_dispatch:++permissions:+ contents: read++jobs:+ numplay-dino:+ runs-on: ubuntu-24.04+ steps:+ - uses: actions/checkout@v4++ - name: ARM toolchain+ run: |+ v=15.2.1-1.1+ curl -fsSL "https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v$v/xpack-arm-none-eabi-gcc-$v-linux-x64.tar.gz" | tar -xz -C "$RUNNER_TEMP"+ echo "$RUNNER_TEMP/xpack-arm-none-eabi-gcc-$v/bin" >> "$GITHUB_PATH"++ - uses: actions/setup-node@v4+ with:+ node-version: 20+ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'++ - name: Tools+ run: |+ sudo apt-get update -q && sudo apt-get install -yq pngquant+ pip install pillow numpy zopfli pyelftools unicorn==2.1.4+ npm install -g [email protected]+ rustup target add thumbv7em-none-eabihf++ - name: Verify integrated manifest+ run: |+ python3 - <<'PY'+ import json+ data = json.load(open('games/games.json', encoding='utf-8'))+ names = [g['id'] for g in data]+ assert 'dinorun' in names, 'Run python3 tools/integrate_dinorun.py and commit the manifest first'+ print('Game count:', len(names), '; Dino index:', names.index('dinorun'))+ PY++ - name: Check Python-equivalent Dino physics+ run: make -C games/dinorun host-test++ - name: Build every game and the full NumPlay launcher, check flash/RAM+ run: make -j4 nwa apps check NWLINK=nwlink++ # Upload before lengthy emulator smoke tests. A later test failure should+ # never discard a successfully compiled calculator app again.+ - uses: actions/upload-artifact@v4+ with:+ name: NumPlay-with-Dino+ path: |+ build/NumPlay.nwa+ build/NumPlay-Invisible.nwa+ build/NumPlay-Matrices.nwa+ build/NumPlay-Upsilon.nwa+ build/apps/*.nwa+ if-no-files-found: error++ # A short independent check; the complete project suite still runs in build.yml.+ - name: Emulator smoke test (Snake)+ run: python3 tests/test_games.py build/apps --game snakediff --git a/games/dinorun/README.md b/games/dinorun/README.mdindex ce41d9cb..b4a5abad 100644--- a/games/dinorun/README.md+++ b/games/dinorun/README.md@@ -16,6 +16,8 @@ This C game uses the original *rectangle-defined pixel art* decoded from [Lily's| **SHIFT** at title | Help screen || **HOME** | Exit back to calculator |+Physics now follows the Python original: **49-pixel jump apex**, 10–14 px/frame cactus speed, 5–14 px/frame bird speed, score advancing by one each frame, and night/day switching every 300 points. Actual real-time speed can still vary with the calculator and rendering cost.+The game features the original pixel cacti, flying bird frames, scrolling clouds, moon/stars, gradually increasing speed, day/night changes, high-score storage (`dinorun.sav`) and instant restart.## Build as an individual NumWorks app@@ -34,7 +36,7 @@ Install the `.nwa` using https://my.numworks.com/apps (Chrome/Edge). **NumPlay i## Integration into the combined NumPlay launcher-`module` and `sim-module` targets are already included to support future integration. At present, **Dino Run is intentionally not added to `games/games.json`**, because the full NumPlay app was already close to the 2 MB flash cap. Adding the manifest entry now would make the full build fail unless enough flash is freed. See `INTEGRATION.md` in the standalone patch.+`module` and `sim-module` targets are already included to support future integration. For a full English NumPlay hardware test, run `python3 tools/integrate_dinorun.py` at repo root and then push; the `Dino inside NumPlay (full launcher build)` workflow triggers automatically on `add-chrome-dino`. The integration reclaims flash by lowering the color depth of five carousel previews while preserving all games. See `FULL_NUMPLAY_README.md`.## Development checksdiff --git a/games/dinorun/docs/game.png b/games/dinorun/docs/game.pngindex 96d28905..534d0a9c 100644Binary files a/games/dinorun/docs/game.png and b/games/dinorun/docs/game.png differdiff --git a/games/dinorun/docs/shot.png b/games/dinorun/docs/shot.pngindex 96d28905..534d0a9c 100644Binary files a/games/dinorun/docs/shot.png and b/games/dinorun/docs/shot.png differdiff --git a/games/dinorun/docs/title.png b/games/dinorun/docs/title.pngindex 7a6c0c0a..72521ca6 100644Binary files a/games/dinorun/docs/title.png and b/games/dinorun/docs/title.png differdiff --git a/games/dinorun/src/icon.png b/games/dinorun/src/icon.pngindex a86bd8c8..f022b8dc 100644Binary files a/games/dinorun/src/icon.png and b/games/dinorun/src/icon.png differdiff --git a/games/dinorun/src/main.c b/games/dinorun/src/main.cindex 7eb674a9..db60f94a 100644--- a/games/dinorun/src/main.c+++ b/games/dinorun/src/main.c@@ -1,6 +1,6 @@/* Dino Run — C gameplay for NumWorks / NumPlay with geometry converted from* the Python Chrome Dino sprites. See dino_sprites.h for source/rights note.- * 320x240, RGB565, 16-row bands, 30 fps.+ * 320x240, RGB565, 16-row bands; physics follows the Python frame steps.* Keyboard: OK/Up/Exe jump, Down duck, Back/Backspace pause, Home exit.*/#include <eadk.h>@@ -39,7 +39,11 @@ static color pixels[W * BAND];static int band_y, scene;static color bg, ink, faint;static obstacle obstacles[8];-static int count, dino_y, dino_vy, duck, score, high_score, speed, spawn_left;+static int count, dino_y, dino_vy, duck, score, high_score, speed;+/* Python values: H=-13 for jump, gravity ad=2 (+7 each duck frame),+ * cacti move Q=10..14 px/frame, birds move T=5..14 px/frame.+ * The simulation uses one step per frame, just like the source. */+static int gravity_units, cactus_meter, bird_meter;static uint32_t rng=0xA319F4B5u, ticks, distance_px;static bool new_record;@@ -140,8 +144,9 @@ static void cactus(obstacle *o) {static void bird(obstacle *o) {/* Python aB/an: original flapping bird poses. */- if ((ticks/7)&1) SPRITE(BIRD_WING_DOWN,o->x,o->y+3,ink);- else SPRITE(BIRD_WING_UP,o->x,o->y+3,ink);+ /* Original sprite coordinates use the bird's y directly. */+ if ((ticks/5)&1) SPRITE(BIRD_WING_DOWN,o->x,o->y,ink);+ else SPRITE(BIRD_WING_UP,o->x,o->y,ink);}static void scenery(void) {@@ -188,21 +193,36 @@ static bool collision(void) {return false;}static void start_game(void) {- scene=PLAY;count=0;score=0;speed=4;spawn_left=260;distance_px=0;+ scene=PLAY;count=0;score=0;speed=10;distance_px=0;+ cactus_meter=0;bird_meter=0;gravity_units=2;duck=0;dino_y=DY*256;dino_vy=0;ticks=0;new_record=false;}+/* Python Chrome Dino uses counters E (cactus) and q (birds), with random+ * thresholds and 1-in-4 / 1-in-7 spawn chances. No obstacles initially. */static void spawn(void) {- if(count>=8)return;- obstacle *o=&obstacles[count++];- o->x=W+5;- if(score>350 && randint(5)==0) {- o->kind=BIRD;o->w=21;o->h=18;- /* Low birds require ducking; high birds can cross a jump. */- o->y=randint(2)?GROUND-28:GROUND-56;- } else {- o->kind=randint(3)==0?LARGE_CACTUS:CACTUS;- o->w=o->kind==LARGE_CACTUS?30:14;- o->h=23;o->y=DY-14;+ int difficulty=(int)(ticks/60); /* original variable a */+ int last_x=-1000, birds=0;+ for(int i=0;i<count;i++) {+ if (obstacles[i].kind==BIRD) birds++;+ else if(obstacles[i].x>last_x)last_x=obstacles[i].x;+ }+ cactus_meter+=1+randint(4+difficulty/3);+ int threshold=20+randint(40+21);+ if(count<6 && cactus_meter>=threshold && randint(4)==0 && last_x<210) {+ int amount=(randint(6)==0)?2+randint(2):1;+ for(int i=0;i<amount && count<8;i++) {+ obstacle *o=&obstacles[count++];+ *o=(obstacle){(int16_t)(350+i*20),DY-14,14,23,CACTUS};+ }+ cactus_meter=0;+ }+ /* Original birds appear after 300 points, with positions y=150..180. */+ bird_meter++;+ int ready=40;+ if(score>300 && birds==0 && count<8 && bird_meter>=ready+randint(40) && randint(7)==1) {+ obstacle *o=&obstacles[count++];+ *o=(obstacle){400,(int16_t)(150+randint(31)),21,18,BIRD};+ bird_meter=0;}}static void lose(void) {@@ -214,26 +234,37 @@ static void lose(void) {}}static void update(bool jump,bool down) {- ticks++;score=(int)(ticks/4);speed=4+(score/140);if(speed>10)speed=10;- if(jump && dino_y>=DY*256 && !down) dino_vy=-2600;+ ticks++;+ score=(int)ticks; /* Python's O increases by one every game frame. */+ speed=10+(int)(ticks/180); if(speed>14)speed=14;++ /* The original program updates position first, then acceleration, so a+ * new jump goes: -13,-11,-9,-7,-5,-3,-1,+1,... = 49 px rise. */+ if(jump && dino_y>=DY*256 && !down) dino_vy=-13*256;duck=down && dino_y>=DY*256;- if(dino_y<DY*256 || dino_vy<0) {- if(down)dino_vy+=220;- dino_y+=dino_vy;dino_vy+=155;- if(dino_y>=DY*256){dino_y=DY*256;dino_vy=0;}+ dino_y+=dino_vy;+ if(dino_y<DY*256) {+ dino_vy+=gravity_units*256;+ } else {+ dino_y=DY*256;+ dino_vy=0;}+ /* Holding Down increases falling acceleration by 7 each frame, just+ * like Python's ad += 7; release resets it to 2. */+ if(down)gravity_units+=7;+ else gravity_units=2;+distance_px+=(uint32_t)speed;for(int i=0;i<count;) {- obstacles[i].x-=(int16_t)speed;- if(obstacles[i].x+obstacles[i].w<0) {- for(int j=i+1;j<count;j++) obstacles[j-1]=obstacles[j];+ int move=(obstacles[i].kind==BIRD)?5+(int)(ticks/180):speed;+ if(move>14)move=14;+ obstacles[i].x-=(int16_t)move;+ if(obstacles[i].x+obstacles[i].w<-24) {+ for(int j=i+1;j<count;j++)obstacles[j-1]=obstacles[j];count--;} else i++;}- spawn_left-=speed;- if(spawn_left<=0) {- spawn();spawn_left=200+randint(95)+(speed-4)*13;- }+ spawn();if(collision())lose();}static void frame(void) {diff --git a/games/dinorun/tests/test_dino.c b/games/dinorun/tests/test_dino.cindex 7d4c1193..de793c6e 100644--- a/games/dinorun/tests/test_dino.c+++ b/games/dinorun/tests/test_dino.c@@ -31,14 +31,24 @@ int main(int argc,char **argv) {frame();if(argc>=2)screenshot(argv[1]);start_game();assert(scene==PLAY && score==0 && count==0);+ /* Python H=-13, ad=2: first frame -13, apex -49 at frame 7. */int y=dino_y;- update(true,false);assert(dino_y<y && dino_vy<0);- for(int t=0;t<80;t++)update(false,false);+ update(true,false);assert(dino_y==y-13*256);+ for(int t=0;t<6;t++)update(false,false);+ assert(dino_y==y-49*256);+ for(int t=0;t<7;t++)update(false,false);assert(dino_y==DY*256);- update(false,true);assert(duck);- update(false,false);assert(!duck);+ assert(score==14 && speed==10);+ /* The old C game was -2600/+155 (over 80 px) and scrolled at 4 px.+ * In Python speed is 10 at start, 11 after ~180 frames and 14 max. */+ start_game();+ ticks=179; cactus_meter=-9999; bird_meter=-9999;+ update(false,false);+ assert(speed==11 && score==180);+ update(false,true);assert(duck && gravity_units==9);+ update(false,false);assert(!duck && gravity_units==2);/* Force a collision, test the game-over state and restart. */- count=1;obstacles[0]=(obstacle){DX+12,DY-14,14,23,CACTUS};+ high_score=0;count=1;obstacles[0]=(obstacle){DX+12,DY-14,14,23,CACTUS};update(false,false);assert(scene==DEAD && high_score==score);start_game();assert(scene==PLAY && score==0 && count==0);for(int i=0;i<160;i++){@@ -53,6 +63,6 @@ int main(int argc,char **argv) {obstacles[2]=(obstacle){152,GROUND-28,21,18,BIRD};frame();if(argc>=3)screenshot(argv[2]);- printf("Host test passed: jump, crouch, collision, restart, rendering.\n");+ printf("Host test passed: Python jump (49px), speed, crouch, collision, restart, rendering.\n");return 0;}diff --git a/tools/integrate_dinorun.py b/tools/integrate_dinorun.pynew file mode 100644index 00000000..75ec6e09--- /dev/null+++ b/tools/integrate_dinorun.py@@ -0,0 +1,53 @@+#!/usr/bin/env python3+"""Register Dino Run in NumPlay, retaining all original playable games.++Run from the NumPlay repo root: python3 tools/integrate_dinorun.py+Safe to run twice. Only edits games/games.json.+"""+import json+from pathlib import Path++ROOT = Path(__file__).resolve().parents[1]+PATH = ROOT / 'games' / 'games.json'+assert (ROOT / 'games' / 'dinorun' / 'src' / 'main.c').exists(), 'Place the Dino files in games/dinorun first'+games = json.loads(PATH.read_text(encoding='utf-8'))+ids = [g['id'] for g in games]+assert len(ids) == len(set(ids)), 'Duplicate game IDs in games.json'+assert 'tetris' in ids, 'Unexpected NumPlay game manifest'++# This preserves every old playable game. Screenshots for the five largest+# launcher cards use a smaller color palette to make flash room for Dino.+# They still display, but with less color fidelity. Individual games unchanged.+compact_previews = {+ 'numblocks': 4,+ 'balatro': 4,+ 'buckshot': 4,+ 'crossyroad': 4,+ 'numdash': 4,+}+for game in games:+ if game['id'] in compact_previews:+ game['colors'] = compact_previews[game['id']]++new = {+ 'id': 'dinorun',+ 'title': 'Chrome Dino',+ 'tagline': 'Jump, duck, survive',+ 'credit': 'Sprite art: Diego KHELLADI (permission pending)',+ 'top': '0xE5E5E5',+ 'bottom': '0x555555',+ 'accent': '0x71A050',+ 'records': ['dinorun.sav'],+ 'shots': ['docs/shot.png'],+ 'app': 'ChromeDino.nwa',+ 'repo': 'https://github.com/LilyTheCuteCatgirl/lilys-small-numworks-games/blob/main/games/chrome_dino.py',+}+if 'dinorun' in ids:+ games[ids.index('dinorun')] = new+else:+ games.insert(ids.index('tetris') + 1, new)+assert len(games) <= 32+PATH.write_text(json.dumps(games, ensure_ascii=False, indent=2) + '\n', encoding='utf-8')+print(f'NumPlay: {len(games)} games, Dino integrated; all original games retained.')+print('Flash optimization: five launcher previews reduced to 4 colors.')+print('Commit games/games.json along with the Dino game before running the full workflow.')