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: every stage and vehicle on the road, the HUD and the end of a run
Mason3632c5ace376e71
diff --git a/games/hillclimb/src/car.c b/games/hillclimb/src/car.cindex 240282e7..fdcb422b 100644--- a/games/hillclimb/src/car.c+++ b/games/hillclimb/src/car.c@@ -14,6 +14,7 @@#define MAXC 64#define SEG 0.2f /* the ground is straight between points this far apart */#define HULL_R 0.05f+#define REACT 0.4f /* how much of the engine's twist the chassis feels (Bill leans into it) */typedef struct {Body *b;@@ -318,12 +319,12 @@ static void solve_joints(Car *c) {/* the engine (or brake) between chassis and wheel */if (J->mmax > 0) {float rel = B->w - A->w - J->speed;- float j = -rel / (A->ii + B->ii), old = J->jm;+ float j = -rel / (REACT * A->ii + B->ii), old = J->jm;J->jm = old + j;if (J->jm > J->mmax) J->jm = J->mmax;if (J->jm < -J->mmax) J->jm = -J->mmax;j = J->jm - old;- A->w -= A->ii * j, B->w += B->ii * j;+ A->w -= REACT * A->ii * j, B->w += B->ii * j;}/* across the axis: the wheel stays on it */float v = (B->vx - A->vx) * J->px + (B->vy - A->vy) * J->py - J->sAy * A->w;diff --git a/games/hillclimb/src/game.c b/games/hillclimb/src/game.cindex 0b024de3..00605977 100644--- a/games/hillclimb/src/game.c+++ b/games/hillclimb/src/game.c@@ -85,9 +85,7 @@ static void end_draw(void) {run_draw(false);gfx_fill(0, 0, SCREEN_W, SCREEN_H, C_BLACK, 110);const char *title = run.end == END_DRIVER_DOWN ? "DRIVER DOWN" : "OUT OF FUEL";- int a = end_t * 24 > 255 ? 255 : end_t * 24;- gfx_text(FONT_XL, 160, 58, title, run.end == END_DRIVER_DOWN ? rgb565(0xFF5A3C) : rgb565(0xFFC21A), C_BLACK, 1);- (void)a;+ gfx_text(FONT_XL, 160, 54, title, run.end == END_DRIVER_DOWN ? rgb565(0xFF5A3C) : rgb565(0xFFC21A), C_BLACK, 1);char t[48], n[20];gfx_rrect(64, 74, 192, 112, 10, rgb565(0x2A2D33), 235);snprintf(t, sizeof t, "%dm", (int)run.dist);@@ -106,11 +104,10 @@ static void end_draw(void) {gfx_fill(80, 160, 160, 1, rgb565(0x6A6F77), 255);gfx_text(FONT_M, 80, 176, "Total", C_WHITE, C_BLACK, 0);draw_coins_counter(240, 176, run_total(), 2);- gfx_rrect(64, 196, 92, 28, 7, rgb565(0x3DAA3D), 255);- gfx_rrect(164, 196, 92, 28, 7, rgb565(0x4A4F57), 255);- gfx_text(FONT_M, 110, 216, "OK: RETRY", C_WHITE, C_BLACK, 1);- gfx_text(FONT_M, 210, 216, "BACK: GARAGE", C_WHITE, C_BLACK, 1);- draw_coins_counter(312, 20, sv.coins, 2);+ gfx_rrect(58, 196, 100, 28, 7, rgb565(0x3DAA3D), 255);+ gfx_rrect(162, 196, 100, 28, 7, rgb565(0x4A4F57), 255);+ gfx_text(FONT_M, 108, 216, "OK: Retry", C_WHITE, C_BLACK, 1);+ gfx_text(FONT_M, 212, 216, "Back: Garage", C_WHITE, C_BLACK, 1);}/* ------------------------------------------------------------------ the frame */diff --git a/games/hillclimb/src/menu.c b/games/hillclimb/src/menu.cindex 9c6665ba..bc338e4c 100644--- a/games/hillclimb/src/menu.c+++ b/games/hillclimb/src/menu.c@@ -176,7 +176,7 @@ static void help_draw(void) {gfx_image(IMG_PEDAL_GAS, 272, 86, 1, 0, 255);gfx_text(FONT_M, 48, 132, "Left or 4", C_WHITE, C_BLACK, 1);gfx_text(FONT_S, 48, 146, "brake, reverse", rgb565(0xC8CDD4), C_BLACK, 1);- gfx_text(FONT_M, 272, 132, "Right, OK or 6", C_WHITE, C_BLACK, 1);+ gfx_text(FONT_M, 272, 132, "Right or OK", C_WHITE, C_BLACK, 1);gfx_text(FONT_S, 272, 146, "gas", rgb565(0xC8CDD4), C_BLACK, 1);gfx_text(FONT_M, 160, 70, "In the air:", rgb565(0xFFE14A), C_BLACK, 1);gfx_text(FONT_S, 160, 86, "gas tilts you back,", C_WHITE, C_BLACK, 1);diff --git a/games/hillclimb/src/run.c b/games/hillclimb/src/run.cindex 31cb069c..50b7e633 100644--- a/games/hillclimb/src/run.c+++ b/games/hillclimb/src/run.c@@ -8,7 +8,7 @@Run run;-#define SX 118 /* where the camera's point is on the screen */+#define SX 124 /* where the camera's point is on the screen */#define SY 138#define PI 3.14159265f#define FLIP_TURN (1.5f * PI) /* a flip counts once upside down and the other wheel on top: 270 degrees */@@ -53,7 +53,7 @@ void run_start(int vehicle, int stg) {run.fuel = run.fuel_max = car_fuel_seconds(vehicle, sv.level[vehicle]);run.start_x = run.car.ch.x;run.best = sv.best[stg][vehicle];- run.cam_x = run.car.ch.x, run.cam_y = run.car.ch.y + 0.4f, run.cam_s = 30;+ run.cam_x = run.car.ch.x, run.cam_y = run.car.ch.y + 0.4f, run.cam_s = 22;rnd_state = 12345u + (uint32_t)stg;}@@ -221,14 +221,14 @@ void run_frame(uint32_t keys) {/* dust from the wheels that spin on the ground, smoke from the exhaust */for (int i = 0; i < c->nw; i++) {float slip = fabsf(c->wh[i].w * c->wr[i] - (c->wh[i].vx)), sp = fabsf(c->wh[i].vx);- if (c->ground[i] && (slip > 2.5f || sp > 6) && (run.frame + (uint32_t)i) % 3 == 0)+ if (c->ground[i] && (slip > 2.0f || (sp > 9 && run.frame % 2)) && (run.frame + (uint32_t)i) % 4 == 0)particle(c->wh[i].x - c->wr[i] * 0.6f, c->wh[i].y - c->wr[i] * 0.8f, -c->wh[i].vx * 0.2f - rndf() * 2,1 + rndf() * 2, 0.5f, 0.22f + rndf() * 0.12f, 0);}- if (run.gas > 0.5f && fuel && run.frame % 6 == 0) {+ if (run.gas > 0.5f && fuel && run.frame % 9 == 0 && car_speed(c) < 6) {float ex, ey;car_point(c, -1.4f, 0.2f, &ex, &ey);- particle(ex, ey, -1.2f + c->ch.vx * 0.3f, 0.6f, 0.9f, 0.25f, 1);+ particle(ex, ey, -1.0f + c->ch.vx * 0.5f, 0.5f, 0.6f, 0.16f, 1);}for (int i = 0; i < run.npart; i++) {Particle *p = &run.part[i];@@ -241,13 +241,13 @@ void run_frame(uint32_t keys) {for (int i = 0; i < NPOPUPS; i++)if (run.pop[i].text[0] && ++run.pop[i].t > 110) run.pop[i].text[0] = 0;/* the camera: ahead of the vehicle as it goes, zooming out with speed */- float sp = car_speed(c), lead = c->ch.vx * 0.13f;- if (lead > 2.6f) lead = 2.6f;+ float sp = car_speed(c), lead = c->ch.vx * 0.2f;+ if (lead > 3.5f) lead = 3.5f;if (lead < -1.5f) lead = -1.5f;float tx = c->ch.x + lead, ty = c->ch.y + 0.4f;run.cam_x += (tx - run.cam_x) * 0.12f;run.cam_y += (ty - run.cam_y) * 0.12f;- float ts = 30 - (sp > 22 ? 22 : sp) * 0.42f;+ float ts = 22 - (sp > 20 ? 20 : sp) * 0.3f;run.cam_s += (ts - run.cam_s) * 0.03f;}@@ -286,7 +286,8 @@ static uint32_t hash2(uint32_t a) {static void draw_sky(void) {if (sky_of != run.stage) make_sky();- gfx_rows(sky_rows, 0, SCREEN_H);+ if (run.stage == ST_ALIEN) gfx_vgrad(0, 0, SCREEN_W, SCREEN_H, 0x0B2A22, 0x5A8A5E); /* (a green night) */+ else gfx_rows(sky_rows, 0, SCREEN_H);if (stage->stars) { /* the Moon's and the alien planet's night: stars, and the Earth or a planet */for (uint32_t i = 0; i < 46; i++) {uint32_t h = hash2(i * 77 + (uint32_t)run.stage);@@ -390,9 +391,10 @@ 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);- float th = img(IMG_TREE_TRUNK)->h * sc * 0.8f;- gfx_image(IMG_TREE_TOP, scr_x(tx), scr_y(ty) - th + 4, 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);@@ -511,7 +513,7 @@ static void draw_particles(void) {if (a > 255) a = 255;int id = p->kind == 1 ? IMG_SMOKE : p->kind == 2 ? IMG_COIN_ICON : stage->particle;const Img *im = img(id);- gfx_image(id, scr_x(p->x), scr_y(p->y), p->size * s / (float)im->w * 2.0f, p->x * 3, p->kind == 1 ? a / 2 : a);+ gfx_image(id, scr_x(p->x), scr_y(p->y), p->size * s / (float)im->w * 2.0f, p->x * 3, p->kind == 1 ? a / 3 : a);}}diff --git a/games/hillclimb/src/stage.c b/games/hillclimb/src/stage.cindex 3ed5a932..3ca352a0 100644--- a/games/hillclimb/src/stage.c+++ b/games/hillclimb/src/stage.c@@ -9,7 +9,7 @@const Stage stages[NSTAGES] = {{"Countryside", 0, 9.8f, 1.0f, IMG_SKY, IMG_SURF_COUNTRY, IMG_GROUND_COUNTRY, IMG_SURF_CAVE, IMG_STAGE_COUNTRY,IMG_GRASS, 0, FEAT_NONE, 1, 0, 11,- {64, 24, 8.5f, 2.6f}, {4.5f, 1.8f, 0.35f, 0}, {5, 3, 1.1f, 0.22f}, {12, 6, 2.2f, 0.42f}, 0, 0,+ {90, 30, 9, 2.6f}, {6, 2.5f, 0.4f, 0}, {10, 5, 1.2f, 0.22f}, {18, 8, 2.1f, 0.42f}, 0, 0,90, 90, 0, 90, 100, 200, 422, 5613, 200, 200, 5000, 3000, 0x7CC62B},{"Desert", 35000, 9.8f, 0.9f, IMG_SKY, IMG_SURF_DESERT, IMG_GROUND_DESERT, IMG_SURF_CAVE, IMG_STAGE_DESERT,IMG_DIRT, 0, FEAT_BRIDGES, 1, 0, 23,@@ -17,7 +17,7 @@ const Stage stages[NSTAGES] = {90, 90, 0, 90, 100, 220, 480, 6695, 200, 0, 3000, 2000, 0xE8D99A},{"Arctic", 75000, 9.8f, 0.42f, IMG_SKY, IMG_SURF_ARCTIC, IMG_GROUND_ARCTIC, IMG_SURF_CAVE, IMG_STAGE_ARCTIC,IMG_SNOW, 0, FEAT_NONE, 1, 0, 11,- {64, 24, 8.5f, 2.6f}, {4.5f, 1.8f, 0.35f, 0}, {5, 3, 1.1f, 0.22f}, {12, 6, 2.2f, 0.42f}, 0, 0,+ {90, 30, 9, 2.6f}, {6, 2.5f, 0.4f, 0}, {10, 5, 1.2f, 0.22f}, {18, 8, 2.1f, 0.42f}, 0, 0,90, 90, 4, 200, 90, 160, 270, 3604, 200, 0, 6000, 2000, 0xF2F6FA},{"Highway", 125000, 9.8f, 1.1f, IMG_SKY_HIGHWAY, IMG_SURF_HIGHWAY, IMG_GROUND_HIGHWAY, IMG_SURF_CAVE,IMG_STAGE_HIGHWAY, IMG_SMOKE, 0, FEAT_NONE, 1, 0, 37,@@ -27,11 +27,11 @@ const Stage stages[NSTAGES] = {IMG_ROCKS, 1, FEAT_NONE, 0, 0, 41,{48, 18, 7, 2.4f}, {1.8f, 0.8f, 0.25f, 0.05f}, {3, 2.4f, 1, 0.2f}, {7, 4.4f, 1.8f, 0.4f}, 4.3f, 2.2f,150, 120, 0, 150, 90, 180, 300, 4143, 300, 0, 11000, 9000, 0xB7B2A8},- {"Moon", 175000, 2.6f, 0.9f, IMG_SKY_MOON, IMG_SURF_MOON, IMG_GROUND_MOON, IMG_SURF_CAVE, IMG_STAGE_MOON,+ {"Moon", 175000, 3.6f, 0.9f, IMG_SKY_MOON, IMG_SURF_MOON, IMG_GROUND_MOON, IMG_SURF_CAVE, IMG_STAGE_MOON,IMG_SMOKE, 0, FEAT_NONE, 0, 1, 53,{56, 20, 7, 2.2f}, {3, 1.4f, 0.4f, 0.04f}, {4.5f, 3, 1.2f, 0.25f}, {12, 6.5f, 2.4f, 0.5f}, 0, 0,90, 90, 0, 90, 80, 160, 272, 4500, 200, 300, 10000, 12000, 0xB9BAD8},- {"Mars", 250000, 4.6f, 0.95f, IMG_SKY_MARS, IMG_SURF_MARS, IMG_GROUND_MARS, IMG_SURF_MARS, IMG_STAGE_MARS,+ {"Mars", 250000, 5.2f, 0.95f, IMG_SKY_MARS, IMG_SURF_MARS, IMG_GROUND_MARS, IMG_SURF_MARS, IMG_STAGE_MARS,IMG_ROCKS_MARS, 2, FEAT_NONE, 0, 0, 67,{60, 22, 8, 2.6f}, {2.4f, 1.2f, 0.3f, 0.04f}, {4, 2.6f, 1, 0.2f}, {10, 5.5f, 2, 0.42f}, 4.8f, 2.4f,150, 150, 10, 420, 90, 180, 302, 4800, 200, 300, 10000, 12000, 0xC77B5A},diff --git a/games/hillclimb/src/vehicle.c b/games/hillclimb/src/vehicle.cindex d5a42fef..8d57beea 100644--- a/games/hillclimb/src/vehicle.c+++ b/games/hillclimb/src/vehicle.c@@ -13,31 +13,31 @@ const uint8_t upgrade_icons[NUPKINDS] = {IMG_UP_ENGINE, IMG_UP_SUSPENSION, IMG_Uconst VehDef vehicles[NVEHICLES] = {{"Hill Climber", "Bill's trusty jeep. Upgrade its 4WD to climb anything.", 0, IMG_ICON_JEEP,{UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_AWD}, {13, 14, 16, 10}, {1000, 1000, 1000, 1000},- 300, 24, {0.02f, 0.38f}, 0.95f, 0.14f, 0.16f, 0.55f, 640, 13.5f, 0, 0.95f, 1150, 40, 0},+ 300, 24, {0.02f, 0.38f}, 0.95f, 0.14f, 0.16f, 0.55f, 430, 11.0f, 0, 0.95f, 760, 40, 0},{"Motocross Bike", "Race the hills with this impressive turboed motocross bike.", 75000, IMG_ICON_BIKE,{UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_AIR}, {12, 14, 16, 10}, {1500, 1000, 1000, 3000},- 150, 14, {-0.05f, 0.55f}, 0.62f, 0.13f, 0.18f, 0.5f, 330, 15.5f, 0, 1.0f, 420, 40, 0},+ 150, 14, {-0.05f, 0.55f}, 0.62f, 0.13f, 0.18f, 0.5f, 230, 13.0f, 0, 1.0f, 300, 40, 0},{"Monster Truck", "With large wheels and a supercharged engine this car really gives a new experience for Hill ""Climbing!", 100000, IMG_ICON_MONSTER,{UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_AWD}, {13, 14, 15, 10}, {1500, 1200, 1200, 1500},- 340, 48, {0.0f, 0.45f}, 1.05f, 0.26f, 0.3f, 0.45f, 1250, 14.5f, 0, 1.0f, 1500, 40, 0},+ 340, 48, {0.0f, 0.45f}, 1.05f, 0.26f, 0.3f, 0.45f, 820, 11.5f, 0, 1.0f, 1500, 40, 0},{"Quad Bike", "4x4 quad bike with almost the same agility as the bike offers you a different ride.", 175000,IMG_ICON_QUAD, {UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_AIR}, {13, 14, 16, 10}, {1500, 1200, 1200, 2500},- 190, 20, {0.0f, 0.5f}, 0.7f, 0.18f, 0.22f, 0.5f, 420, 15, 1.0f, 1.0f, 520, 40, 0},+ 190, 20, {0.0f, 0.5f}, 0.7f, 0.18f, 0.22f, 0.5f, 300, 12, 1.0f, 1.0f, 520, 40, 0},{"Race Car", "High power and aerodynamic ultimate hill climbing vehicle. Upgrade downforce to make this car ""follow the road like a magnet.", 250000, IMG_ICON_RACE,{UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_DOWNFORCE}, {12, 14, 16, 12}, {1500, 1500, 1500, 2500},- 270, 18, {0.05f, 0.18f}, 1.05f, 0.06f, 0.08f, 0.6f, 620, 21, 0, 1.05f, 900, 40, 9.0f},+ 270, 18, {0.05f, 0.18f}, 1.05f, 0.06f, 0.08f, 0.6f, 430, 17, 0, 1.05f, 900, 40, 9.0f},{"Rally Car", "Powerful engine and downforce upgraded provide the most ultimate combination for hill climbing.",750000, IMG_ICON_RALLY, {UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_DOWNFORCE}, {14, 14, 17, 10},{2000, 2000, 2000, 3000},- 320, 22, {0.05f, 0.3f}, 1.0f, 0.11f, 0.13f, 0.6f, 820, 20, 0.6f, 1.05f, 1000, 40, 8.0f},+ 320, 22, {0.05f, 0.3f}, 1.0f, 0.11f, 0.13f, 0.6f, 560, 16, 0.6f, 1.05f, 1000, 40, 8.0f},{"Dune Buggy", "Quick, good traction and handy hill climbing vehicle!", 800000, IMG_ICON_BUGGY,{UP_ENGINE, UP_SUSPENSION, UP_TIRES, UP_FUEL}, {15, 15, 15, 20}, {3000, 3000, 3000, 3000},- 260, 22, {0.1f, 0.32f}, 0.95f, 0.17f, 0.22f, 0.5f, 760, 18, 0.8f, 1.15f, 900, 52, 0},+ 260, 22, {0.1f, 0.32f}, 0.95f, 0.17f, 0.22f, 0.5f, 520, 15, 0.8f, 1.15f, 900, 52, 0},{"Tank", "It's a tank!", 1000000, IMG_ICON_TANK,{UP_ENGINE, UP_SUSPENSION, UP_TRACKS, UP_FUEL}, {15, 15, 15, 20}, {3000, 3000, 3000, 3000},- 900, 30, {0.0f, 0.42f}, 1.15f, 0.08f, 0.1f, 0.7f, 520, 9.5f, 1.0f, 1.45f, 2600, 40, 0},+ 900, 30, {0.0f, 0.42f}, 1.15f, 0.08f, 0.1f, 0.7f, 520, 8.0f, 1.0f, 1.45f, 2600, 40, 0},};uint32_t upgrade_cost(int v, int u, int level) { return (uint32_t)vehicles[v].cost[u] * (uint32_t)(level * level); }diff --git a/games/hillclimb/tests/play.c b/games/hillclimb/tests/play.cindex ca6ab905..03644c10 100644--- a/games/hillclimb/tests/play.c+++ b/games/hillclimb/tests/play.c@@ -88,6 +88,20 @@ int main(int argc, char **argv) {else if (!strcmp(argv[i], "--coins")) coins = atol(argv[++i]);else if (!strcmp(argv[i], "--auto")) autop = true;else if (!strcmp(argv[i], "--trace")) trace = atoi(argv[++i]);+ else if (!strcmp(argv[i], "--slopes")) { /* the steepest slope of each 100 m of a stage, in degrees */+ stage_set(atoi(argv[++i]));+ for (int s = 0; s < 4000; s += 100) {+ float most = 0, lo = 1e9f, hi = -1e9f;+ for (float x = (float)s; x < s + 100; x += 0.5f) {+ float a = atanf((stage_floor(x + 0.5f) - stage_floor(x)) / 0.5f) * 57.3f, h = stage_floor(x);+ if (fabsf(a) > fabsf(most)) most = a;+ if (h < lo) lo = h;+ if (h > hi) hi = h;+ }+ printf("%5d m: steepest %5.1f, heights %6.1f to %6.1f\n", s, most, lo, hi);+ }+ return 0;+ }}mkdir("build", 0755);mkdir(out, 0755);