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
Isaac: padlocks, the Devil's door, prices in hearts, the Cathedral's floor
Mason363541134c3a8fe
diff --git a/games/isaac/src/bosses.c b/games/isaac/src/bosses.cindex 68420939..72ee9090 100644--- a/games/isaac/src/bosses.c+++ b/games/isaac/src/bosses.c@@ -828,7 +828,7 @@ void boss_draw(Ent *e) {if (e->vx < -0.1f || (e->type >= MON_FAMINE && e->type <= MON_DEATH && e->vx < 0)) flags = GFX_FLIPX;uint16_t tint = 0;int amount = 0;- if (e->flash) tint = C_WHITE, amount = 18;+ if (e->flash) tint = rgb565(0xFF5050), amount = e->flash > 1 ? 12 : 6;else if (e->freeze) tint = rgb565(0xC0C0C0), amount = 24;else if (e->poison) tint = rgb565(0x40C040), amount = 12;int sx = 256, sy = 256;diff --git a/games/isaac/src/data.bin b/games/isaac/src/data.binindex 171de10c..ef5d60e8 100644Binary files a/games/isaac/src/data.bin and b/games/isaac/src/data.bin differdiff --git a/games/isaac/src/floor.c b/games/isaac/src/floor.cindex 61307986..8f7cec5a 100644--- a/games/isaac/src/floor.c+++ b/games/isaac/src/floor.c@@ -270,13 +270,13 @@ static int room_at(int mx, int my) {bool room_door_exists(int d, int *kind) {Room *r = room_cur();- if (fl.cur == fl.devil_room) { /* the Devil's (or an angel's) room: its one door, down */+ if (fl.cur == fl.devil_room) { /* the Devil's (or an angel's) room: its one door, back the way he came */if (kind) *kind = ROOM_BOSS;- return d == DIR_DOWN;+ return d == ((fl.devil_side + 2) & 3);}if (r->mx == 0 && r->my == 0) return false;int j = room_at(r->mx + DIR_X[d], r->my + DIR_Y[d]);- if (fl.cur == fl.boss_room && d == DIR_UP && fl.devil_open && j < 0) {+ if (fl.cur == fl.boss_room && d == fl.devil_side && fl.devil_open && j < 0) {if (kind) *kind = fl.devil_angel ? ROOM_ANGEL : ROOM_DEVIL;return true;}@@ -547,6 +547,7 @@ void floor_enter_room(int index, int from_dir) {int d = from_dir < 0 || from_dir > 4 ? 4 : from_dir;pl.x = ex[d], pl.y = ey[d], pl.vx = pl.vy = 0;if (r->kind == ROOM_START && d == 4) pl.x = 160, pl.y = 120;+ if (d == 4 && r->kind != ROOM_START) pl.y = ROOM_B - 14; /* (sent here: by the bottom wall, clear of what's in the room) */familiars_spawn();g_room_frames = 0;/* per-room effects end */@@ -587,7 +588,7 @@ void floor_reveal(int what) {int floor_neighbour(int d) {Room *r = room_cur();if (fl.cur == fl.devil_room) return fl.boss_room;- if (fl.cur == fl.boss_room && d == DIR_UP && fl.devil_open && room_at(r->mx, r->my - 1) < 0) {+ if (fl.cur == fl.boss_room && d == fl.devil_side && fl.devil_open && room_at(r->mx + DIR_X[d], r->my + DIR_Y[d]) < 0) {floor_open_devil();return fl.devil_room;}diff --git a/games/isaac/src/game.c b/games/isaac/src/game.cindex ecad88cb..c79e831b 100644--- a/games/isaac/src/game.c+++ b/games/isaac/src/game.c@@ -128,8 +128,14 @@ static void boss_reward(void) {float p = 0.15f + (boss_hit ? 0 : 0.35f) + (pl.damage_taken_floor ? 0 : 0.35f);if (pl.has[51]) p += 0.1f;if (pl.has[122]) p += 0.1f;- if (chance(p)) {- fl.devil_open = true;+ int side = -1;+ for (int k = 0; k < 4 && side < 0; k++) {+ static const int8_t order[4] = {DIR_UP, DIR_LEFT, DIR_RIGHT, DIR_DOWN};+ int mx = r->mx + DIR_X[order[k]], my = r->my + DIR_Y[order[k]];+ if (mx < 0 || my < 0 || mx >= MAP_W || my >= MAP_H || fl.map[my][mx] < 0) side = order[k];+ }+ if (side >= 0 && chance(p)) {+ fl.devil_open = true, fl.devil_side = (int8_t)side;fl.devil_angel = !pl.has[79] && !pl.has[80] && rnd(2) == 0 && g_frame > 0 && !pl.has[118] && !pl.has[51];}}diff --git a/games/isaac/src/game.h b/games/isaac/src/game.hindex dc42421f..888e240b 100644--- a/games/isaac/src/game.h+++ b/games/isaac/src/game.h@@ -262,6 +262,7 @@ typedef struct {int8_t cur, start, boss_room, devil_room;uint8_t boss; /* the boss's MON_* */bool devil_open, devil_angel, boss_beaten, trapdoor;+ int8_t devil_side; /* the wall of the boss's room it opens in */uint32_t seed;Room rooms[MAX_ROOMS];} Floor;diff --git a/games/isaac/src/monsters.c b/games/isaac/src/monsters.cindex dd628a3e..c0bdb4f8 100644--- a/games/isaac/src/monsters.c+++ b/games/isaac/src/monsters.c@@ -716,7 +716,7 @@ void mon_draw(Ent *e) {}uint16_t tint = 0;int amount = 0;- if (e->flash) tint = C_WHITE, amount = 20;+ if (e->flash) tint = rgb565(0xFF5050), amount = e->flash > 1 ? 14 : 8;else if (e->freeze) tint = rgb565(0xC0C0C0), amount = 24;else if (e->poison) tint = rgb565(0x40C040), amount = 12;else if (e->flags & EF_CHAMPION) {diff --git a/games/isaac/src/pickups.c b/games/isaac/src/pickups.cindex 4128f8a2..2d81b37c 100644--- a/games/isaac/src/pickups.c+++ b/games/isaac/src/pickups.c@@ -267,13 +267,15 @@ void pedestal_draw(Ent *e) {int spr = item_sprite(e->t3);if ((fl.curse & CURSE_BLIND) && !e->price && room_cur()->kind != ROOM_SHOP) spr = SPR_ITEM_1, gfx_text_c(FONT_UPHEAVAL, x, y - 22, "?", C_WHITE, 2, true);else gfx_sprite(spr, 0, x, y - 4 - bob, 0, 32);- if (e->price) {+ if (e->price || (e->flags & EF_DEVIL)) {char s[8];int n = 0, p = e->flags & EF_DEVIL ? devil_price(e->t3) : e->price;if (p >= 10) s[n++] = (char)('0' + p / 10);s[n++] = (char)('0' + p % 10), s[n] = 0;if (e->flags & EF_DEVIL) {- for (int k = 0; k < p; k++) gfx_sprite(SPR_HUD_HEART, 0, x - p * 6 + k * 12, y + 8, 0, 32);+ bool soul = pl.containers == 0; /* (no red hearts to give: three soul hearts) */+ if (soul) p = 3;+ for (int k = 0; k < p; k++) gfx_sprite(SPR_HUD_HEART, soul ? 3 : 0, x - p * 6 + k * 12, y + 8, 0, 32);} elsegfx_text_c(FONT_UPHEAVAL, x, y + 9, s, C_WHITE, 1, true);}@@ -378,8 +380,8 @@ void machine_update(Ent *e) {void machine_draw(Ent *e) {int sh = e->t2 ? ((e->t2 & 2) ? 1 : -1) : 0;- if (e->type == MA_DEVIL_STATUE || e->type == MA_ANGEL_STATUE) {- gfx_sprite_tint(e->spr, 0, (int)e->x, (int)e->y, 0, rgb565(0x707070), 18, 32);+ if (e->type == MA_DEVIL_STATUE || e->type == MA_ANGEL_STATUE) { /* a statue: grey stone, smaller */+ gfx_sprite_scaled(e->spr, 0, (int)e->x, (int)e->y, 150, 150, 0, rgb565(0x8A8A8A), 22, 32);return;}gfx_sprite(e->spr, 0, (int)e->x + sh, (int)e->y + 8, 0, 32);@@ -528,7 +530,8 @@ void trapdoor_update(Ent *e) {return;}float dx = pl.x - e->x, dy = pl.y - e->y;- if (dx * dx + dy * dy < 8 * 8) {+ if (dx * dx + dy * dy > 16 * 16) e->state = 1;+ if (e->state && dx * dx + dy * dy < 8 * 8) {if (e->type == 1) fl.alt = 1; /* the beam: the Cathedral */else if (fl.stage == 8) fl.alt = 0;game_next_floor();diff --git a/games/isaac/src/room.c b/games/isaac/src/room.cindex dfaa4231..c5816c37 100644--- a/games/isaac/src/room.c+++ b/games/isaac/src/room.c@@ -349,6 +349,7 @@ void doors_draw(void) {if (!room_door_exists(d, &kind)) continue;int fk = door_frame_kind(kind, false, here);bool open = room_door_open(d);+ bool locked = !open && !ents_alive_monsters();int f = fk * 2 + (open ? 0 : 1);if (fk == 3) f = 6; /* (a hole stays a hole) */if (d == DIR_UP) gfx_sprite(SPR_DOOR, f, door_x[2], door_y[2], 0, 32);@@ -358,5 +359,14 @@ void doors_draw(void) {if (d == DIR_LEFT) gfx_sprite(spr, open ? 0 : 1, door_x[1], door_y[1], 0, 32);else gfx_sprite(spr, open ? 0 : 1, door_x[3], door_y[3], GFX_FLIPX, 32);}+ if (locked) { /* its padlock */+ static const int16_t px[4] = {160, ROOM_X - 9, 160, ROOM_R + 9}, py[4] = {ROOM_B + 9, 120, ROOM_Y - 9, 120};+ int x = px[d], y = py[d];+ gfx_rect(x - 3, y - 6, 2, 4, rgb565(0xB0B0B0), 32);+ gfx_rect(x + 2, y - 6, 2, 4, rgb565(0xB0B0B0), 32);+ gfx_rect(x - 1, y - 7, 3, 2, rgb565(0xB0B0B0), 32);+ gfx_rect(x - 4, y - 2, 9, 7, rgb565(0xD8A020), 32);+ gfx_rect(x, y + 1, 1, 3, C_BLACK, 32);+ }}}diff --git a/games/isaac/src/save.c b/games/isaac/src/save.cindex 7fe10b63..679aba57 100644--- a/games/isaac/src/save.c+++ b/games/isaac/src/save.c@@ -153,7 +153,7 @@ bool save_run(void) {/* the floor, then each room: its grid in runs of (cell, state) */put8(fl.stage), put8(fl.alt), put8(fl.curse), put8(fl.nrooms), put(fl.map, sizeof fl.map);put8(fl.cur), put8(fl.start), put8(fl.boss_room), put8(fl.devil_room), put8(fl.boss);- put8(fl.devil_open | fl.devil_angel << 1 | fl.boss_beaten << 2 | fl.trapdoor << 3);+ put8(fl.devil_open | fl.devil_angel << 1 | fl.boss_beaten << 2 | fl.trapdoor << 3 | (fl.devil_side & 3) << 4);put(&fl.seed, 4);for (int i = 0; i < fl.nrooms; i++) {Room *r = &fl.rooms[i];@@ -197,6 +197,7 @@ bool load_run(void) {fl.boss = (uint8_t)get8();int b = get8();fl.devil_open = b & 1, fl.devil_angel = (b >> 1) & 1, fl.boss_beaten = (b >> 2) & 1, fl.trapdoor = (b >> 3) & 1;+ fl.devil_side = (int8_t)((b >> 4) & 3);get(&fl.seed, 4);if (fl.nrooms > MAX_ROOMS) return false;for (int i = 0; i < fl.nrooms && !bad; i++) {diff --git a/games/isaac/tests/play.c b/games/isaac/tests/play.cindex 3cbf751a..9e21ecb8 100644--- a/games/isaac/tests/play.c+++ b/games/isaac/tests/play.c@@ -1,12 +1,13 @@/* Plays The Binding of Isaac on a computer, with scripted keys, and saves frames.** play [--frames N] [--keys "10-40:right,50:ok,..."] [--shots 30,60|all|every:N] [--out DIR] [--saves DIR]- * [--seed N] [--run] [--stage S] [--give ID,ID...] [--bot] [--god] [--boss MON] [--room KIND]+ * [--seed N] [--run] [--stage S] [--give ID,ID...] [--bot] [--god] [--boss MON] [--goto KIND]** Keys: left right up down sleft sright sup sdown ok back bomb item card map home; "a-b:key" holds the key* from frame a to b, "a:key" for one frame. --run starts a new run past the title (--stage: on that floor).* --bot plays by itself: it goes for the monsters, crying at them, then on through the doors to the rooms it- * hasn't seen, then down the trapdoor; --god keeps Isaac alive. Screenshots are DIR/shot_<frame>.ppm. */+ * hasn't seen, then down the trapdoor; --god keeps Isaac alive; --goto starts in the floor's first room of that kind+ * (ROOM_* in src/data.h), --boss makes the floor's boss that one (MON_*). Screenshots are DIR/shot_<frame>.ppm. */#include <stdio.h>#include <stdlib.h>#include <string.h>@@ -145,7 +146,7 @@ int main(int argc, char **argv) {int frames = 600, seed = 1, stage = 1, every = 0;char keys[65536] = "", shots[65536] = "", out[512] = "build/shots", saves[512] = "build/host-saves", give[1024] = "";bool all = false, run = false, bot = false, god = false;- int boss = -1;+ int boss = -1, gokind = -1;for (int i = 1; i < argc; i++) {const char *a = argv[i];const char *v = i + 1 < argc ? argv[i + 1] : "";@@ -162,6 +163,7 @@ int main(int argc, char **argv) {else if (!strcmp(a, "--stage")) stage = atoi(v), i++;else if (!strcmp(a, "--give")) snprintf(give, sizeof give, "%s", v), i++;else if (!strcmp(a, "--boss")) boss = atoi(v), i++;+ else if (!strcmp(a, "--goto")) gokind = atoi(v), i++;else if (!strcmp(a, "--run")) run = true;else if (!strcmp(a, "--bot")) bot = true;else if (!strcmp(a, "--god")) god = true;@@ -183,6 +185,16 @@ int main(int argc, char **argv) {if (boss >= 0) fl.boss = (uint8_t)boss, fl.rooms[fl.boss_room].boss = (uint8_t)boss;for (char *tok = strtok(give, ","); tok; tok = strtok(NULL, ",")) item_give(atoi(tok));g_mode = MODE_PLAY;+ if (gokind == ROOM_DEVIL || gokind == ROOM_ANGEL) { /* (straight into the Devil's or an angel's room) */+ fl.devil_angel = gokind == ROOM_ANGEL;+ floor_open_devil();+ room_teleport(fl.devil_room);+ } else if (gokind >= 0)+ for (int i = 0; i < fl.nrooms; i++)+ if (fl.rooms[i].kind == gokind) {+ room_teleport(i);+ break;+ }}int floors_seen = fl.stage;for (int f = 0; f < frames && g_running; f++) {diff --git a/games/isaac/tools/pack.py b/games/isaac/tools/pack.pyindex 20a2c705..ef2089b8 100644--- a/games/isaac/tools/pack.py+++ b/games/isaac/tools/pack.py@@ -21,6 +21,7 @@ import osimport structimport sys+import numpy as npfrom PIL import Image, ImageDraw, ImageFontHERE = os.path.dirname(os.path.abspath(__file__))@@ -353,7 +354,15 @@ BACKDROPS = [def encode_backdrop(name):- im = scaled(bg(name)).convert("RGB") # 234 x 156 -> 180 x 120+ src = bg(name)+ if src.getextrema()[3][0] < 255:+ # (the Cathedral's floor has a cross left open for a layer under it: the floor's own colour, darker)+ a = np.asarray(src.crop((100, 80, 230, 150)))+ mean = tuple(int(v) * 3 // 4 for v in a[a[:, :, 3] == 255][:, :3].mean(axis=0))+ under = Image.new("RGBA", src.size, mean + (255,))+ under.alpha_composite(src)+ src = under+ im = scaled(src).convert("RGB") # 234 x 156 -> 180 x 120assert im.size == (180, 120), im.sizeq = im.quantize(colors=256, method=Image.Quantize.MEDIANCUT, dither=Image.Dither.NONE)pal = q.getpalette()[:256 * 3]