Skip to content

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.

Isaac: more items do what they do, controls to choose, host tests

Mason3630ee2758d58b4
diff --git a/games/isaac/src/bosses.c b/games/isaac/src/bosses.c
index 72ee9090..4cfcd8ae 100644
--- a/games/isaac/src/bosses.c
+++ b/games/isaac/src/bosses.c
@@ -159,7 +159,7 @@ void boss_spawn(int type, float x, float y) {
return;
case MON_SATAN:
e = boss_new(MON_SATAN, x, y - 20, 100);
- if (e) e->spr = SPR_SATAN, e->state = 0;
+ if (e) e->spr = SPR_FALLEN, e->state = 0;
return;
case MON_ENVY: case MON_GLUTTONY: case MON_SLOTH: case MON_LUST: case MON_WRATH: case MON_GREED: case MON_PRIDE:
sins_count++;
diff --git a/games/isaac/src/ents.c b/games/isaac/src/ents.c
index 131bac2a..b74d24e5 100644
--- a/games/isaac/src/ents.c
+++ b/games/isaac/src/ents.c
@@ -85,6 +85,7 @@ static void touch_player(Ent *e) {
return;
}
/* half a heart, a whole one from the Womb (and from the Depths' bosses) */
+ if (pl.has[13] && !(e->flags & EF_BOSS)) e->poison = 60, e->poison_dmg = 2;
player_hurt(fl.stage >= 7 || ((e->flags & EF_BOSS) && fl.stage >= 5) ? 2 : 1, e->type);
}
}
@@ -111,6 +112,7 @@ void ents_update(void) {
if (e->fear) e->fear--;
if (pl.hourglass > 0 && (g_frame & 1)) break;
if (e->slow && (g_frame & 1)) break;
+ if (g_room_frames < 10 && !(e->flags & EF_FRIEND)) break; /* (they wake as he comes in) */
if (!boss_update(e)) mon_update(e);
if (e->kind == EK_MON) touch_player(e);
break;
diff --git a/games/isaac/src/floor.c b/games/isaac/src/floor.c
index 8f7cec5a..1368c338 100644
--- a/games/isaac/src/floor.c
+++ b/games/isaac/src/floor.c
@@ -185,6 +185,8 @@ static int pick_boss(int stage) {
}
void floor_new(int stage) {
+ ents_clear();
+ tears_clear();
memset(&fl, 0, sizeof fl);
memset(fl.map, -1, sizeof fl.map);
fl.stage = (uint8_t)stage;
@@ -299,6 +301,7 @@ static int door_lock(int d) {
if (room_cur()->doors_open & (1 << d)) return 0;
if ((k == ROOM_TREASURE || k == ROOM_SHOP) && fl.stage > 1) return 1;
if (k == ROOM_LIBRARY) return 1;
+ if (k == ROOM_CHALLENGE && pl.red < pl.containers * 2 && !(room_cur()->doors_open & (1 << d))) return 3;
return 0;
}
@@ -319,7 +322,7 @@ static void open_both(int d) {
/* he walks into a locked door: a key opens it */
bool door_try_unlock(int d) {
if (door_lock(d) != 1) return false;
- if (pl.has[175]) { /* (Dad's Key opens them all) */
+ if (pl.has[175] || fl.golden_key) { /* (Dad's Key, a golden key: no key needed) */
open_both(d);
return true;
}
@@ -530,6 +533,14 @@ void floor_enter_room(int index, int from_dir) {
for (int d = 0; d < 4; d++) {
int j = room_at(r->mx + DIR_X[d], r->my + DIR_Y[d]);
if (j >= 0 && fl.rooms[j].kind != ROOM_SECRET && fl.rooms[j].kind != ROOM_SUPERSECRET) fl.rooms[j].state |= RS_SEEN;
+ /* the Spelunker Hat: what the rooms next door are, and the rooms past them */
+ if (j >= 0 && pl.has[91]) {
+ fl.rooms[j].state |= RS_SEEN | RS_FOUND;
+ for (int e = 0; e < 4; e++) {
+ int k = room_at(fl.rooms[j].mx + DIR_X[e], fl.rooms[j].my + DIR_Y[e]);
+ if (k >= 0) fl.rooms[k].state |= RS_SEEN;
+ }
+ }
}
if (first) {
room_build_grid(r);
diff --git a/games/isaac/src/game.c b/games/isaac/src/game.c
index c79e831b..859d7a91 100644
--- a/games/isaac/src/game.c
+++ b/games/isaac/src/game.c
@@ -136,7 +136,7 @@ static void boss_reward(void) {
}
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];
+ fl.devil_angel = pl.devil_deals == 0 && rnd(2) == 0;
}
}
}
@@ -191,8 +191,8 @@ static void play_update(void) {
}
/* the keys of a room */
if (g_pressed & K_ITEM || (g_pressed & K_OK)) item_use_active();
- if ((g_pressed & K_BOMB) && pl.bombs > 0 && !pl.has[52]) {
- pl.bombs--;
+ if ((g_pressed & K_BOMB) && (pl.bombs > 0 || fl.golden_bomb) && !pl.has[52]) {
+ if (!fl.golden_bomb) pl.bombs--;
bomb_place(pl.x, pl.y + 1, 0);
}
if ((g_pressed & K_CARD) && pl.pocket_kind) {
@@ -203,6 +203,7 @@ static void play_update(void) {
}
int hp_before = pl.red + pl.soul;
player_update(k);
+ grid_update();
ents_update();
tears_update();
lasers_update();
@@ -276,15 +277,27 @@ static void draw_title(void) {
if (g_frame % 50 < 34) gfx_text_c(FONT_UPHEAVAL, 160, 206, "PRESS OK", C_WHITE, 1, true);
}
-static const char *const menu_new[] = {"NEW RUN", "HOW TO PLAY"};
-static const char *const menu_cont[] = {"NEW RUN", "CONTINUE", "HOW TO PLAY"};
+bool g_swap;
+enum { M_NEW, M_CONTINUE, M_CONTROLS, M_HELP };
+/* the menu's lines: Continue only with a run kept */
+static int menu_items(int *ids, const char **names) {
+ static const char *const all[4] = {"NEW RUN", "CONTINUE", "CONTROLS", "HOW TO PLAY"};
+ int n = 0;
+ for (int i = 0; i < 4; i++)
+ if (i != M_CONTINUE || run_saved()) ids[n] = i, names[n] = all[i], n++;
+ return n;
+}
static void draw_menu(void) {
gfx_backdrop(BD_ISAACS_ROOM);
gfx_rect(0, 0, SCREEN_W, SCREEN_H, C_BLACK, 12);
- paper(70, 40, 180, 150);
- bool cont = run_saved();
- menu_list(cont ? menu_cont : menu_new, cont ? 3 : 2, menu_sel, 160, 64);
+ paper(70, 30, 180, 170);
+ int ids[4];
+ const char *names[4];
+ int n_items = menu_items(ids, names);
+ menu_list(names, n_items, menu_sel, 160, 48);
+ for (int i = 0; i < n_items; i++)
+ if (ids[i] == M_CONTROLS) gfx_text_c(FONT_UPHEAVAL, 160, 48 + i * 24 + 17, g_swap ? "NUMBERS WALK, ARROWS CRY" : "ARROWS WALK, NUMBERS CRY", INK2, 1, false);
char s[48];
int n = 0;
const char *p = "RUNS ";
@@ -295,19 +308,20 @@ static void draw_menu(void) {
do digits[nd++] = (char)('0' + v % 10), v /= 10; while (v && nd < 6);
while (nd) s[n++] = digits[--nd];
s[n] = 0;
- gfx_text_c(FONT_UPHEAVAL, 160, 162, s, INK2, 1, false);
+ gfx_text_c(FONT_UPHEAVAL, 160, 172, s, INK2, 1, false);
/* the bosses beaten: Mom, Mom's Heart, Satan, Isaac */
static const int16_t marks[4] = {SPR_MOM_EYE, SPR_MOMS_HEART, SPR_SATAN, SPR_ISAAC_BOSS};
for (int i = 0; i < 4; i++)
- if (g_wins & (1 << i)) gfx_sprite_scaled(marks[i], 0, 112 + i * 32, 186, 90, 90, 0, 0, 0, 32);
+ if (g_wins & (1 << i)) gfx_sprite_scaled(marks[i], 0, 112 + i * 32, 226, 90, 90, 0, 0, 0, 32);
}
static void draw_help(void) {
gfx_rect(0, 0, SCREEN_W, SCREEN_H, rgb565(0x1A1210), 32);
paper(14, 10, 292, 220);
gfx_text_c(FONT_UPHEAVAL, 160, 18, "HOW TO PLAY", INK, 2, false);
- static const char *const rows[][2] = {
- {"ARROWS", "WALK"}, {"8 4 6 2 (5)", "CRY TEARS UP, LEFT, RIGHT, DOWN"}, {"9 OR SHIFT", "DROP A BOMB"},
+ const char *rows[][2] = {
+ {g_swap ? "8 4 6 5 (2)" : "ARROWS", "WALK"},
+ {g_swap ? "ARROWS" : "8 4 6 2 (5)", "CRY TEARS UP, LEFT, RIGHT, DOWN"}, {"9 OR SHIFT", "DROP A BOMB"},
{"7 OR OK", "USE THE ACTIVE ITEM"}, {"1 OR 3", "TAKE THE PILL OR CARD"}, {"TOOLBOX", "HOLD FOR THE MAP"},
{"BACK", "PAUSE"}, {"HOME", "KEEP THE RUN AND QUIT"},
};
@@ -358,6 +372,22 @@ static void draw_pause(void) {
/* the items he found */
for (int i = 0; i < pl.norder && i < 30; i++) gfx_sprite(item_sprite(pl.order[i]), 0, 40 + (i % 10) * 25, 158 + (i / 10) * 24, 0, 32);
gfx_text_c(FONT_UPHEAVAL, 160, 128, stage_name(fl.stage, fl.alt), INK2, 1, false);
+ char t[40];
+ uint32_t secs = g_frame / FPS, k = 0;
+ static const char seed_chars[] = "ABCDEFGHJKLMNPQRSTWXYZ01234V6789";
+ const char *lbl = "TIME ";
+ while (*lbl) t[k++] = *lbl++;
+ if (secs >= 3600) t[k++] = (char)('0' + secs / 36000 % 10), t[k++] = (char)('0' + secs / 3600 % 10), t[k++] = ':';
+ t[k++] = (char)('0' + secs / 600 % 6), t[k++] = (char)('0' + secs / 60 % 10), t[k++] = ':';
+ t[k++] = (char)('0' + secs / 10 % 6), t[k++] = (char)('0' + secs % 10);
+ lbl = " SEED ";
+ while (*lbl) t[k++] = *lbl++;
+ for (int i = 0; i < 8; i++) {
+ t[k++] = seed_chars[(g_run_seed >> (i * 4 % 28)) & 31];
+ if (i == 3) t[k++] = ' ';
+ }
+ t[k] = 0;
+ gfx_text_c(FONT_UPHEAVAL, 160, 140, t, INK2, 1, false);
}
static void draw_stage(void) {
@@ -442,6 +472,7 @@ static int up_down(int sel, int n) {
}
void game_frame(uint32_t keys) {
+ if (g_swap) keys = (keys & ~(uint32_t)(K_MOVE | K_SHOOT)) | (keys & K_MOVE) << 4 | (keys & K_SHOOT) >> 4;
g_pressed = keys & ~g_keys;
g_keys = keys;
if (keys & K_HOME) { /* Home and On/Off: the run kept, then out */
@@ -460,14 +491,17 @@ void game_frame(uint32_t keys) {
break;
case MODE_MENU: {
g_frame++;
- bool cont = run_saved();
- int n = cont ? 3 : 2;
+ int ids[4];
+ const char *names[4];
+ int n = menu_items(ids, names);
menu_sel = up_down(menu_sel, n);
if (g_pressed & K_BACK) g_mode = MODE_TITLE;
- if (ok) {
- int pick = cont ? menu_sel : (menu_sel == 0 ? 0 : 2);
- if (pick == 0) game_new_run();
- else if (pick == 1) {
+ bool side = g_pressed & (K_LEFT | K_RIGHT | K_SLEFT | K_SRIGHT);
+ if (ok || (side && ids[menu_sel] == M_CONTROLS)) {
+ int pick = ids[menu_sel];
+ if (pick == M_NEW) game_new_run();
+ else if (pick == M_CONTROLS) g_swap = !g_swap, save_progress();
+ else if (pick == M_CONTINUE) {
if (load_run()) {
floor_enter_room(fl.cur, DIR_NONE);
player_stats();
diff --git a/games/isaac/src/game.h b/games/isaac/src/game.h
index 888e240b..1df44884 100644
--- a/games/isaac/src/game.h
+++ b/games/isaac/src/game.h
@@ -263,6 +263,7 @@ typedef struct {
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 */
+ bool golden_key, golden_bomb; /* found on this floor: keys and bombs for nothing */
uint32_t seed;
Room rooms[MAX_ROOMS];
} Floor;
@@ -292,6 +293,9 @@ void move_ent(float *x, float *y, float *vx, float *vy, float r, bool flying, bo
void grid_hit(int c, int r, float dmg); /* a tear hits a poop or a fire */
void grid_explode(float x, float y, float radius);
void grid_draw_row(int r);
+void grid_update(void);
+void grid_break_at(float x, float y);
+extern bool g_ladder; /* fire burns, red fire shoots */
bool door_try_unlock(int d);
void door_bombed(float x, float y);
int floor_neighbour(int d);
@@ -323,6 +327,7 @@ extern int g_transition; /* frames of the dip to black between rooms */
extern uint8_t g_wins; /* runs won: Mom, Mom's Heart, Satan, Isaac (progress kept) */
extern uint16_t g_deaths, g_runs;
extern uint8_t g_best_stage;
+extern bool g_swap; /* the number keys walk and the arrows cry (as WASD and the arrows) */
void game_init(void);
void game_frame(uint32_t keys);
diff --git a/games/isaac/src/hud.c b/games/isaac/src/hud.c
index b333e88f..18312db8 100644
--- a/games/isaac/src/hud.c
+++ b/games/isaac/src/hud.c
@@ -68,7 +68,7 @@ static void room_cell(int x, int y, int w, int h, Room *r, int i, bool big) {
case ROOM_CHALLENGE: icon = 9; break;
default: break;
}
- if (icon >= 0 && ((r->state & (RS_VISITED | RS_FOUND)) || pl.has[21] || (r->state & RS_SEEN))) {
+ if (icon >= 0 && ((r->state & (RS_VISITED | RS_FOUND)) || pl.has[21])) {
static const uint32_t col[10] = {0xC02020, 0xE0C030, 0x40A040, 0x606060, 0x902020, 0xD050A0, 0xA03030, 0x806040, 0xC06020, 0xA02020};
gfx_sprite_tint(SPR_MAP_ICON, icon, x + w / 2, y + h / 2, 0, rgb565(col[icon]), 32, 32);
(void)big;
@@ -124,7 +124,7 @@ void hud_draw(void) {
if (pl.active) {
const ItemInfo *ii = item_info(pl.active);
gfx_sprite(item_sprite(pl.active), 0, 16, 26, 0, 32);
- if (ii && ii->charge && ii->charge != 255) {
+ if (ii && ii->charge && ii->charge < 254) {
int h = 22, n = ii->charge;
gfx_rect(29, 4, 6, h + 2, C_BLACK, 32);
int full = pl.active_charge > n ? n : pl.active_charge;
@@ -140,7 +140,8 @@ void hud_draw(void) {
gfx_sprite(SPR_HUD_ICON, 0, 3, cy, 0, 32), number(14, cy, pl.coins);
gfx_sprite(SPR_HUD_ICON, 1, 3, cy + 11, 0, 32), number(14, cy + 11, pl.bombs);
gfx_sprite(SPR_HUD_ICON, 2, 3, cy + 22, 0, 32), number(14, cy + 22, pl.keys);
- if (pl.has[175] || pl.keys >= 99) {}
+ if (fl.golden_key) gfx_rect(26, cy + 25, 3, 3, rgb565(0xF0C030), 32);
+ if (fl.golden_bomb) gfx_rect(26, cy + 14, 3, 3, rgb565(0xF0C030), 32);
minimap();
/* the pill or card */
if (pl.pocket_kind) {
diff --git a/games/isaac/src/items.c b/games/isaac/src/items.c
index 0dd12835..a8884878 100644
--- a/games/isaac/src/items.c
+++ b/games/isaac/src/items.c
@@ -136,7 +136,7 @@ static const ItemInfo items[] = {
{132, "A LUMP OF COAL", "MY XMAS PRESENT", T, 0, 2},
{133, "GUPPY'S PAW", "SOUL CONVERTER", D, 1, 2},
{134, "GUPPY'S TAIL", "CURSED?", D, 0, 1},
- {135, "IV BAG", "PORTABLE BLOOD BANK", S, 0, 1},
+ {135, "IV BAG", "PORTABLE BLOOD BANK", S, 254, 1},
{136, "BEST FRIEND", "REUSABLE DECOY", T | S, 3, 0},
{137, "REMOTE DETONATOR", "REMOTE BOMB DETONATION", T | S, 1, 1},
{138, "STIGMATA", "DMG + HP UP", T, 0, 2},
@@ -146,7 +146,7 @@ static const ItemInfo items[] = {
{144, "BUM FRIEND", "HE'S GREEDY", T | S, 0, 1},
{145, "GUPPY'S HEAD", "REUSABLE FLY HIVE", D, 1, 2},
{146, "PRAYER CARD", "REUSABLE ETERNITY", A, 6, 2},
- {147, "NOTCHED AXE", "ROCKS DON'T STAND A CHANCE", S, 0, 1},
+ {147, "NOTCHED AXE", "ROCKS DON'T STAND A CHANCE", S | T, 0, 1},
{149, "IPECAC", "EXPLOSIVE SHOTS", T, 0, 3},
{150, "TOUGH LOVE", "TOOTH SHOT", T, 0, 2},
{152, "TECHNOLOGY 2", "LASER", T, 0, 2},
@@ -171,7 +171,7 @@ static const ItemInfo items[] = {
{174, "RAINBOW BABY", "RANDOM BUDDY", T, 0, 1},
{175, "DAD'S KEY", "OPEN SESAME", S, 2, 1},
{176, "STEM CELLS", "HP UP + SHOT SPEED UP", BO, 0, 1},
- {177, "PORTABLE SLOT", "GAMBLE 24/7", S, 0, 1},
+ {177, "PORTABLE SLOT", "GAMBLE 24/7", S, 254, 1},
{178, "HOLY WATER", "SPLASH!", A, 0, 1},
{179, "FATE", "FLIGHT ETERNAL", A, 0, 3},
{182, "SACRED HEART", "HOMING SHOTS + DMG UP", A, 0, 4},
@@ -250,7 +250,7 @@ void item_give(int id) {
hud_banner(ii->name, ii->text);
if (ii->charge) {
pl.active = (int16_t)id;
- pl.active_charge = ii->charge == 255 ? 1 : ii->charge;
+ pl.active_charge = ii->charge >= 254 ? (ii->charge == 255) : ii->charge;
}
switch (id) {
case 11: pl.lives++; break;
@@ -474,7 +474,7 @@ static bool use_effect(int id) {
void item_use_active(void) {
const ItemInfo *ii = item_info(pl.active);
if (!ii) return;
- int need = ii->charge == 255 ? 1 : ii->charge;
+ int need = ii->charge == 255 ? 1 : ii->charge == 254 ? 0 : ii->charge;
if (pl.active_charge < need && ii->charge != 0) return;
if (!use_effect(pl.active)) return;
if (ii->charge == 255) { /* used once: gone */
@@ -489,7 +489,7 @@ void item_use_active(void) {
/* a room cleared: a charge, and the familiars that bring things */
void item_room_cleared(void) {
const ItemInfo *ii = item_info(pl.active);
- if (ii && ii->charge && ii->charge != 255) {
+ if (ii && ii->charge && ii->charge < 254) {
int max = ii->charge * (pl.has[63] ? 2 : 1);
pl.active_charge = (int16_t)(pl.active_charge + 1 + (pl.has[116] ? 1 : 0));
if (pl.active_charge > max) pl.active_charge = (int16_t)max;
@@ -569,7 +569,7 @@ void pill_use(int color) {
case PL_LUCK_DOWN: pl.pill_luck -= 1; break;
case PL_LUCK_UP: pl.pill_luck += 1; break;
case PL_TELEPILLS: random_room_teleport(-1); break;
- case PL_48H: { const ItemInfo *ii = item_info(pl.active); if (ii && ii->charge && ii->charge != 255) pl.active_charge = ii->charge; break; }
+ case PL_48H: { const ItemInfo *ii = item_info(pl.active); if (ii && ii->charge && ii->charge < 254) pl.active_charge = ii->charge; break; }
case PL_HEMATEMESIS: { int n = pl.red / 2; pl.red = pl.containers ? 1 : 0; for (int i = 0; i < n && i < 5; i++) pickup_spawn(PK_HEART, 0, pl.x, pl.y, true); break; }
case PL_PARALYSIS: pl.invuln = 0; pl.vx = pl.vy = 0; break;
case PL_SEE: floor_reveal(4); break;
@@ -728,7 +728,25 @@ void familiar_update(Ent *e) {
}
return;
}
- if (dir == DIR_NONE || id == 144 || id == 99 * 0) return;
+ if (id == 144) { /* Bum Friend: after the coins, and something back now and then */
+ Ent *c = NULL;
+ float bd = 1e9f;
+ for (int i = 0; i < MAX_ENTS; i++)
+ if (ents[i].kind == EK_PICKUP && !(ents[i].flags & EF_SHOP) && ents[i].type >= PK_PENNY && ents[i].type <= PK_DIME) {
+ float d = dist2(ents[i].x, ents[i].y, e->x, e->y);
+ if (d < bd) bd = d, c = &ents[i];
+ }
+ if (c) {
+ e->x += (c->x - e->x) * 0.1f, e->y += (c->y - e->y) * 0.1f;
+ if (bd < 8 * 8) {
+ e->c += c->type == PK_PENNY ? 1 : c->type == PK_NICKEL ? 5 : 10;
+ c->kind = EK_NONE;
+ if (e->c >= 3 + rnd(4)) e->c = 0, pickup_drop_random(e->x, e->y);
+ }
+ }
+ return;
+ }
+ if (dir == DIR_NONE) return;
float sx = DIR_X[dir] * 5, sy = DIR_Y[dir] * 5;
if (id == 188) sx = -sx, sy = -sy;
switch (id) {
diff --git a/games/isaac/src/pickups.c b/games/isaac/src/pickups.c
index 2d81b37c..2ba77181 100644
--- a/games/isaac/src/pickups.c
+++ b/games/isaac/src/pickups.c
@@ -57,6 +57,14 @@ void room_clear_reward(void) {
if (r->kind == ROOM_BOSS || r->kind == ROOM_MINIBOSS) return;
float luck = pl.luck;
int roll = rnd(100) + (int)(luck * 4);
+ if (pl.has[134]) { /* Guppy's Tail: a third nothing, a third a chest */
+ int g = rnd(3);
+ if (g == 0) return;
+ if (g == 1) {
+ pickup_spawn(rnd(3) ? PK_CHEST : PK_LOCKED_CHEST, 0, 160, 120, true);
+ return;
+ }
+ }
if (roll < 45) return;
/* where: the room's middle, or the nearest free cell */
float x = 160, y = 120;
@@ -128,13 +136,13 @@ static bool try_collect(Ent *e) {
case PK_DIME: collect_coins(10); break;
case PK_KEY: if (pl.keys < 99) pl.keys++; break;
case PK_KEY_RING: pl.keys = (uint8_t)(pl.keys + 2 > 99 ? 99 : pl.keys + 2); break;
- case PK_GOLDEN_KEY: pl.keys = (uint8_t)(pl.keys + 1 > 99 ? 99 : pl.keys + 1), pl.has[175] |= 0; break;
+ case PK_GOLDEN_KEY: fl.golden_key = true; break;
case PK_BOMB: if (pl.bombs < 99) pl.bombs++; break;
case PK_DOUBLE_BOMB: pl.bombs = (uint8_t)(pl.bombs + 2 > 99 ? 99 : pl.bombs + 2); break;
- case PK_GOLDEN_BOMB: pl.bombs = (uint8_t)(pl.bombs + 1 > 99 ? 99 : pl.bombs + 1); break;
+ case PK_GOLDEN_BOMB: fl.golden_bomb = true; break;
case PK_BATTERY: {
const ItemInfo *ii = item_info(pl.active);
- if (!ii || !ii->charge || ii->charge == 255 || pl.active_charge >= ii->charge) return false;
+ if (!ii || !ii->charge || ii->charge >= 254 || pl.active_charge >= ii->charge) return false;
pl.active_charge = ii->charge;
break;
}
@@ -154,8 +162,8 @@ static bool try_collect(Ent *e) {
open_chest(e);
return true;
case PK_LOCKED_CHEST:
- if (!pl.keys && !pl.has[175]) return false;
- if (!pl.has[175]) pl.keys--;
+ if (!pl.keys && !pl.has[175] && !fl.golden_key) return false;
+ if (!pl.has[175] && !fl.golden_key) pl.keys--;
open_chest(e);
return true;
default: break;
@@ -245,6 +253,7 @@ void pedestal_update(Ent *e) {
else if (pl.soul >= 6 && pl.containers == 0) pl.soul = (uint8_t)(pl.soul - 6);
else if (pl.containers > 0) player_add_containers(-pl.containers);
else return;
+ pl.devil_deals++;
if (!pl.containers && !pl.soul) player_kill(-7);
}
int item = e->t3;
diff --git a/games/isaac/src/player.c b/games/isaac/src/player.c
index 0dc474e5..b421951e 100644
--- a/games/isaac/src/player.c
+++ b/games/isaac/src/player.c
@@ -38,7 +38,8 @@ void player_stats(void) {
/* damage ups */
dmg_up += h[7] * 1.0f + h[51] * 1.0f + h[50] * 1.0f + h[79] * 1.0f + h[70] * 1.0f + h[90] * 1.0f + h[193] * 0.3f
+ h[138] * 0.3f + h[80] * 0.5f + h[4] * 0.5f + h[12] * 0.3f + h[121] * 1.0f + h[197] * 0.5f + h[201] * 0.3f
- + h[165] * 0.3f + h[101] * 0.3f + h[189] * 0.3f + h[182] * 1.0f + h[122] * 0 + h[154] * 0;
+ + h[165] * 0.3f + h[101] * 0.3f + h[189] * 0.3f + h[182] * 1.0f;
+ flat += h[154] * 1.0f;
if (h[4]) mult *= 1.5f;
if (h[12]) mult *= 1.5f;
if (h[169]) mult *= 2, flat += 4;
@@ -190,6 +191,8 @@ bool player_hurt(int halves, int source) {
}
}
if (pl.has[142] && pl.red + pl.soul <= 1) player_add_soul(2, false), pl.has[142] = 2; /* Scapular */
+ if (pl.has[117]) mon_spawn(MON_BLUE_FLY, pl.x, pl.y - 12); /* Dead Bird's bird */
+ if (pl.has[178]) creep_spawn(pl.x, pl.y, 24, 150, false, 3); /* Holy Water */
if (pl.red == 0 && pl.soul == 0 && pl.eternal == 0) player_kill(source);
if (pl.has[122]) player_stats();
return true;
@@ -323,7 +326,10 @@ void player_update(uint32_t keys) {
if (absf(pl.vx) < 0.05f && !mx) pl.vx = 0;
if (absf(pl.vy) < 0.05f && !my) pl.vy = 0;
if (pl.pony > 0 && (mx || my)) pl.vx = mx * 7, pl.vy = my * 7; /* (A Pony's dash) */
+ g_ladder = pl.has[60];
move_ent(&pl.x, &pl.y, &pl.vx, &pl.vy, 5, pl.flight, false);
+ g_ladder = false;
+ if (pl.has[147] && (mx || my) && (g_frame & 7) == 0) grid_break_at(pl.x + mx * 9, pl.y + my * 9);
if (mx || my) {
pl.walk++;
if (absf(mx) > absf(my)) pl.face = mx < 0 ? DIR_LEFT : DIR_RIGHT;
@@ -342,7 +348,7 @@ void player_update(uint32_t keys) {
bdir = dir;
if (pl.charge < pl.tear_delay) pl.charge++;
} else if (pl.charge >= pl.tear_delay && pl.charge > 0) {
- laser_fire(pl.x, pl.y - 10, bdir, 9, pl.damage * 0.33f, 15, 0, false);
+ laser_fire(pl.x, pl.y - 10, bdir, 9, pl.damage * 0.6f, 15, 0, false);
pl.charge = 0;
} else
pl.charge = 0;
diff --git a/games/isaac/src/room.c b/games/isaac/src/room.c
index c5816c37..01cba75a 100644
--- a/games/isaac/src/room.c
+++ b/games/isaac/src/room.c
@@ -6,6 +6,7 @@
#define GRID_RUBBLE 100 /* (a rock blown up: rubble on the floor) */
+bool g_ladder; /* (Isaac moving, with The Ladder) */
static uint8_t g(int c, int r) {
if (c < 0 || r < 0 || c >= COLS || r >= ROWS) return CELL_BLOCK;
return room_cur()->grid[r][c];
@@ -19,7 +20,8 @@ bool grid_solid(int c, int r, bool flying) {
switch (k) {
case CELL_ROCK: case CELL_BLOCK: case CELL_TINTED: case CELL_BOMB_ROCK: case CELL_TNT: case CELL_KEY_BLOCK:
return !flying || k == CELL_BLOCK || k == CELL_KEY_BLOCK;
- case CELL_PIT: return !flying;
+ case CELL_PIT: return !flying && !(g_ladder && !(g(c - 1, r) == CELL_PIT && g(c + 1, r) == CELL_PIT)
+ && !(g(c, r - 1) == CELL_PIT && g(c, r + 1) == CELL_PIT));
case CELL_FIRE: case CELL_RED_FIRE: return ghp(c, r) > 0 && !flying;
default: return is_poop(k) && ghp(c, r) > 0 && !flying;
}
@@ -246,11 +248,32 @@ void grid_explode(float x, float y, float radius) {
if (k == CELL_ROCK || k == CELL_TINTED || k == CELL_BOMB_ROCK || k == CELL_TNT || is_poop(k) || k == CELL_FIRE
|| k == CELL_RED_FIRE || k == CELL_COBWEB)
destroy_cell(c, r);
- if (k == CELL_ROCK && pl.has[147]) destroy_cell(c, r);
}
door_bombed(x, y);
}
+/* Notched Axe: a rock he walks into breaks */
+void grid_break_at(float x, float y) {
+ int c = col_of(x), r = row_of(y);
+ if (c < 0 || r < 0 || c >= COLS || r >= ROWS) return;
+ int k = g(c, r);
+ if (k == CELL_ROCK || k == CELL_TINTED || k == CELL_BOMB_ROCK || k == CELL_POOP) destroy_cell(c, r);
+}
+
+void grid_update(void) {
+ Room *rm = room_cur();
+ for (int r = 0; r < ROWS; r++)
+ for (int c = 0; c < COLS; c++) {
+ int k = rm->grid[r][c];
+ if ((k != CELL_FIRE && k != CELL_RED_FIRE) || !rm->gridhp[r][c]) continue;
+ float x, y;
+ cell_center(c, r, &x, &y);
+ float d2 = dist2(x, y, pl.x, pl.y);
+ if (d2 < 14 * 14) player_hurt(1, -4);
+ if (k == CELL_RED_FIRE && d2 < 110 * 110 && g_room_frames > 20 && rnd(90) == 0) enemy_shot_at(x, y - 10, 3);
+ }
+}
+
/* ---------------------------------------------------------------- drawing */
static int rock_sprite(void) {
Room *r = room_cur();
@@ -349,7 +372,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();
+ bool locked = !open && !ents_alive_monsters() && kind != ROOM_CHALLENGE;
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);
diff --git a/games/isaac/src/save.c b/games/isaac/src/save.c
index 679aba57..d80b2eba 100644
--- a/games/isaac/src/save.c
+++ b/games/isaac/src/save.c
@@ -153,7 +153,8 @@ 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 | (fl.devil_side & 3) << 4);
+ put8(fl.devil_open | fl.devil_angel << 1 | fl.boss_beaten << 2 | fl.trapdoor << 3 | (fl.devil_side & 3) << 4
+ | fl.golden_key << 6 | fl.golden_bomb << 7);
put(&fl.seed, 4);
for (int i = 0; i < fl.nrooms; i++) {
Room *r = &fl.rooms[i];
@@ -198,6 +199,7 @@ bool load_run(void) {
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);
+ fl.golden_key = (b >> 6) & 1, fl.golden_bomb = (b >> 7) & 1;
get(&fl.seed, 4);
if (fl.nrooms > MAX_ROOMS) return false;
for (int i = 0; i < fl.nrooms && !bad; i++) {
@@ -239,7 +241,7 @@ typedef struct {
} Progress;
void save_progress(void) {
- Progress p = {PROGRESS_MAGIC, g_runs, g_deaths, g_wins, g_best_stage, {0, 0}};
+ Progress p = {PROGRESS_MAGIC, g_runs, g_deaths, g_wins, g_best_stage, {g_swap, 0}};
plat_save(PROGRESS_NAME, &p, sizeof p);
copy_write();
}
@@ -251,5 +253,5 @@ void load_progress(void) {
if (!d || len != sizeof p) return;
memcpy(&p, d, sizeof p);
if (p.magic != PROGRESS_MAGIC) return;
- g_runs = p.runs, g_deaths = p.deaths, g_wins = p.wins, g_best_stage = p.best_stage;
+ g_runs = p.runs, g_deaths = p.deaths, g_wins = p.wins, g_best_stage = p.best_stage, g_swap = p.pad[0] & 1;
}
diff --git a/games/isaac/src/tears.c b/games/isaac/src/tears.c
index aa1e3f21..b85b91dd 100644
--- a/games/isaac/src/tears.c
+++ b/games/isaac/src/tears.c
@@ -346,6 +346,10 @@ void explode(float x, float y, float radius, float dmg, bool hurt_player, int ki
} else if (e->kind == EK_PICKUP || e->kind == EK_BOMB) {
e->vx += dx / d * 4, e->vy += dy / d * 4;
if (e->kind == EK_BOMB && e->t > 2) e->t = 2; /* (a chain) */
+ } else if (e->kind == EK_MACHINE && e->type == MA_SHOPKEEPER) {
+ for (int k = 0; k < 3 + rnd(4); k++) pickup_spawn(PK_PENNY, 0, e->x, e->y, true);
+ fx_spawn(FX_POOF, e->x, e->y, 10);
+ e->kind = EK_NONE;
} else if (e->kind == EK_MACHINE && e->type <= MA_BOMB_BUM && e->state != 255) {
/* a blown-up machine pays out once */
e->state = 255;
diff --git a/games/isaac/tests/check.py b/games/isaac/tests/check.py
new file mode 100644
index 00000000..2acee993
--- /dev/null
+++ b/games/isaac/tests/check.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python3
+"""Checks of The Binding of Isaac on a computer (make test): the host build, with AddressSanitizer and UBSan,
+through the menus, a run kept and continued, dying, every boss, every special room, every item, pill and card,
+and runs played by the bot (tests/play.c) down through the floors.
+
+ python3 tests/check.py build/play [--quick]
+
+--quick plays fewer and shorter runs."""
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+PLAY = sys.argv[1] if len(sys.argv) > 1 else "build/play"
+HERE = os.path.dirname(os.path.abspath(__file__))
+QUICK = "--quick" in sys.argv
+ENV = dict(os.environ, ASAN_OPTIONS="detect_leaks=0", UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1")
+failures = []
+
+H = open(os.path.join(HERE, "..", "src", "data.h")).read()
+MON = {m.group(1): i for i, m in enumerate(re.finditer(r"^ MON_(\w+),", H, re.M))}
+ROOM = {m.group(1): i for i, m in enumerate(re.finditer(r"^ ROOM_(\w+),", H, re.M))}
+ITEMS = [int(x) for x in re.search(r"#define ITEM_ID_TABLE \{([\d,]+)\}", H).group(1).split(",")]
+MODE_MENU, MODE_PLAY, MODE_DEAD = 1, 2, 5
+
+
+def run(args, what, saves=None):
+ own = saves is None
+ if own:
+ saves = tempfile.mkdtemp(prefix="isaac_check_")
+ p = subprocess.run([PLAY, "--saves", saves, "--out", saves] + args, capture_output=True, text=True, env=ENV,
+ timeout=1800)
+ if own:
+ shutil.rmtree(saves, ignore_errors=True)
+ if p.returncode or "runtime error" in p.stderr or "AddressSanitizer" in p.stderr:
+ failures.append(f"{what}: crashed or a sanitizer error\n{p.stderr[-2000:]}")
+ return None
+ m = re.search(r"END mode (\d+) stage (\d+) room (\d+) kind (\d+) hp (\d+)/(\d+) soul (\d+) coins (\d+) bombs (\d+) "
+ r"keys (\d+) items (\d+) frames (\d+) floors (\d+) dropped (\d+)", p.stdout)
+ if not m:
+ failures.append(f"{what}: no end state\n{p.stdout[-500:]}")
+ return None
+ keys = ["mode", "stage", "room", "kind", "hp", "max", "soul", "coins", "bombs", "keys", "items", "frames", "floors",
+ "dropped"]
+ st = dict(zip(keys, map(int, m.groups())))
+ pk = re.search(r"POCKET (\d+) (\d+) ACTIVE (\d+) LIVES (\d+)", p.stdout)
+ st["pocket"], st["active"] = (int(pk.group(1)), int(pk.group(3))) if pk else (0, 0)
+ if st["dropped"]:
+ failures.append(f"{what}: {st['dropped']} drawing commands dropped")
+ return st
+
+
+def expect(cond, what):
+ if not cond:
+ failures.append(what)
+
+
+# ---- the menus: the title, a new run, the floor's name, then the first room
+st = run(["--frames", "120", "--keys", "5:ok,15:ok,30:ok"], "menus")
+expect(st and st["mode"] == MODE_PLAY and st["stage"] == 1 and st["kind"] == ROOM["START"], f"menus: not playing ({st})")
+st = run(["--frames", "60", "--keys", "5:ok,10:down,12:down,15:ok,30:back"], "how to play")
+expect(st and st["mode"] == MODE_MENU, f"how to play: not back to the menu ({st})")
+
+# ---- a run kept on Home, continued
+saves = tempfile.mkdtemp(prefix="isaac_check_")
+run(["--run", "--frames", "200", "--bot", "--god", "--keys", "190:home", "--seed", "4"], "keep the run", saves)
+expect(os.path.exists(os.path.join(saves, "isaacrun.sav")), "the run wasn't kept on Home")
+expect(os.path.exists(os.path.join(saves, "isaac_saves.py")), "no copy of the saves in isaac_saves.py")
+st = run(["--frames", "60", "--keys", "5:ok,15:ok"], "continue", saves)
+expect(st and st["mode"] == MODE_PLAY, f"continue: not playing ({st})")
+# the copy brings the run back once the files are gone (as installing apps does)
+os.remove(os.path.join(saves, "isaacrun.sav"))
+st = run(["--frames", "60", "--keys", "5:ok,15:ok"], "continue from the copy", saves)
+expect(st and st["mode"] == MODE_PLAY, f"continue from the copy: not playing ({st})")
+shutil.rmtree(saves, ignore_errors=True)
+
+# ---- dying: the bot in the Womb without help, then a new run from the death screen
+st = run(["--run", "--stage", "7", "--frames", "3000", "--bot", "--seed", "5"], "death")
+expect(st and st["mode"] in (MODE_DEAD, MODE_PLAY), f"death: {st}")
+
+# ---- every boss, fought by the bot for a while
+bosses = ["MONSTRO", "LARRY", "DUKE", "GEMINI", "GURDY_JR", "FAMINE", "STEVEN", "WIDOW", "PIN", "HAUNT", "DINGLE",
+ "BLIGHTED_OVUM", "CHUB", "GURDY", "PEEP", "PESTILENCE", "CARRION_QUEEN", "MEGA_FATTY", "POLYCEPHALUS", "HUSK",
+ "MONSTRO2", "LOKI", "WAR", "MASK_OF_INFAMY", "GISH", "BLOAT", "WRETCHED", "DARK_ONE", "BLASTOCYST",
+ "DADDY_LONG_LEGS", "SCOLEX", "DEATH", "LOKII", "CONQUEST", "MAMA_GURDY", "MR_FRED", "TRIACHNID", "TERATOMA",
+ "SLOTH", "LUST", "WRATH", "GLUTTONY", "GREED", "ENVY", "PRIDE"]
+killed = 0
+for b in bosses[:12] if QUICK else bosses:
+ st = run(["--run", "--stage", "2", "--boss", str(MON[b]), "--goto", str(ROOM["BOSS"]), "--bot", "--god",
+ "--give", "4,7,12", "--frames", "2500", "--seed", "3"], f"boss {b}")
+ if st and st["kind"] != ROOM["BOSS"]:
+ killed += 1 # (beaten, and the bot went on)
+for b, stage in (("MOM", 6), ("MOMS_HEART", 8), ("SATAN", 9), ("ISAAC", 9)):
+ st = run(["--run", "--stage", str(stage), "--goto", str(ROOM["BOSS"]), "--bot", "--god", "--give", "4,7,12,51,79",
+ "--frames", "4000", "--seed", "3"], f"boss {b}")
+print(f"bosses: {killed} beaten by the bot in time")
+
+# ---- the special rooms, on a few floors
+for kind in ("TREASURE", "SHOP", "SECRET", "SUPERSECRET", "CURSE", "ARCADE", "SACRIFICE", "LIBRARY", "MINIBOSS",
+ "CHALLENGE", "DEVIL", "ANGEL"):
+ for stage in (2, 5):
+ run(["--run", "--stage", str(stage), "--goto", str(ROOM[kind]), "--bot", "--god", "--frames", "400",
+ "--seed", str(stage)], f"room {kind}")
+
+# ---- every item, ten at a time, the bot playing with them (actives used now and then)
+for i in range(0, len(ITEMS), 10):
+ group = ITEMS[i:i + 10]
+ st = run(["--run", "--stage", "3", "--give", ",".join(map(str, group)), "--bot", "--god", "--frames", "900",
+ "--seed", str(i)], f"items {group}")
+for it in (33, 34, 35, 36, 37, 38, 39, 41, 42, 44, 45, 47, 49, 56, 58, 65, 66, 77, 78, 83, 84, 85, 86, 97, 102, 105,
+ 111, 123, 124, 126, 127, 130, 133, 135, 136, 137, 145, 146, 158, 160, 164, 166, 170, 171, 175, 177, 186, 192):
+ st = run(["--run", "--stage", "2", "--give", f"{it},63", "--bot", "--god", "--frames", "200",
+ "--keys", "40:item,120:item", "--seed", str(it)], f"active {it}")
+
+# ---- pills (each colour) and cards (each one)
+for c in range(1, 14):
+ st = run(["--run", "--pocket", f"1,{c}", "--frames", "60", "--keys", "20:card"], f"pill {c}")
+ expect(st and st["pocket"] == 0, f"pill {c} not taken")
+for c in range(1, 32):
+ st = run(["--run", "--stage", "2", "--pocket", f"2,{c}", "--frames", "60", "--keys", "20:card"], f"card {c}")
+ expect(st and st["pocket"] == 0, f"card {c} not used")
+
+# ---- runs played by the bot, down the floors
+seeds = range(1, 3) if QUICK else range(1, 9)
+deepest = 0
+for s in seeds:
+ st = run(["--run", "--bot", "--god", "--frames", "12000" if QUICK else "40000", "--seed", str(s)], f"bot run {s}")
+ if st:
+ deepest = max(deepest, st["floors"])
+print(f"the bot's deepest floor: {deepest}")
+expect(deepest >= 3, f"the bot never got past the Caves ({deepest})")
+
+if failures:
+ print(f"{len(failures)} failures:")
+ for f in failures:
+ print(" -", f)
+ sys.exit(1)
+print("all checks passed")
diff --git a/games/isaac/tests/play.c b/games/isaac/tests/play.c
index 9e21ecb8..14f4d390 100644
--- a/games/isaac/tests/play.c
+++ b/games/isaac/tests/play.c
@@ -2,12 +2,14 @@
*
* 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] [--goto KIND]
+ * [--pocket KIND,ID]
*
* 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; --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. */
+ * (ROOM_* in src/data.h), --boss makes the floor's boss that one (MON_*), --pocket gives a pill (1) or card (2).
+ * Screenshots are DIR/shot_<frame>.ppm. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -145,8 +147,8 @@ static uint32_t bot_keys(void) {
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, gokind = -1;
+ bool all = false, run = false, bot = false, god = false, immortal = false;
+ int boss = -1, gokind = -1, pocket_kind = 0, pocket = 0;
for (int i = 1; i < argc; i++) {
const char *a = argv[i];
const char *v = i + 1 < argc ? argv[i + 1] : "";
@@ -164,9 +166,11 @@ int main(int argc, char **argv) {
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, "--pocket")) sscanf(v, "%d,%d", &pocket_kind, &pocket), i++;
else if (!strcmp(a, "--run")) run = true;
else if (!strcmp(a, "--bot")) bot = true;
else if (!strcmp(a, "--god")) god = true;
+ else if (!strcmp(a, "--immortal")) immortal = true;
}
mkdir(out, 0755);
mkdir(saves, 0755);
@@ -184,6 +188,7 @@ 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));
+ if (pocket_kind) pl.pocket_kind = (uint8_t)pocket_kind, pl.pocket = (uint8_t)pocket;
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;
@@ -204,6 +209,7 @@ int main(int argc, char **argv) {
if (bot && !k) k = bot_keys();
if (getenv("TRACE") && f % 50 == 0) printf("f %d pl %.1f,%.1f v %.2f,%.2f keys %x mode %d room %d\n", f, pl.x, pl.y, pl.vx, pl.vy, k, g_mode, fl.cur);
if (god) pl.invuln = pl.invuln > 2 ? pl.invuln : 2, pl.dead = false;
+ if (immortal && pl.red < 2 && pl.containers) pl.red = (uint8_t)(pl.containers * 2), pl.dead = false;
host_keys = k;
host_time += 33;
game_frame(k);
@@ -221,6 +227,7 @@ int main(int argc, char **argv) {
if (ents[i].kind == EK_MON)
printf("MON %d type %d hp %.1f/%.1f state %d at %.0f,%.0f flags %x\n", i, ents[i].type, ents[i].hp, ents[i].maxhp,
ents[i].state, ents[i].x, ents[i].y, ents[i].flags);
+ printf("POCKET %d %d ACTIVE %d LIVES %d\n", pl.pocket_kind, pl.pocket, pl.active, pl.lives);
printf("END mode %d stage %d room %d kind %d hp %d/%d soul %d coins %d bombs %d keys %d items %d frames %u floors %d dropped %d\n",
g_mode, fl.stage, fl.cur, room_cur()->kind, pl.red, pl.containers * 2, pl.soul, pl.coins, pl.bombs, pl.keys, pl.norder,
g_frame, floors_seen, gfx_dropped);
diff --git a/games/isaac/tools/characters.py b/games/isaac/tools/characters.py
new file mode 100644
index 00000000..987d6a21
--- /dev/null
+++ b/games/isaac/tools/characters.py
@@ -0,0 +1,117 @@
+"""The other characters of Rebirth: Isaac's frames (tools/art.py) with their hair, hats and colours drawn over the top
+of the head (the face below it is his), and their bodies in their own colours."""
+from PIL import Image, ImageDraw
+
+import art as A
+
+COLOURS = {
+ "h": (214, 176, 84), "H": (156, 116, 46), # Magdalene's blond hair
+ "c": (112, 72, 42), "C": (72, 42, 22), # Cain's brown hair
+ "f": (204, 34, 34), "F": (132, 12, 12), "t": (20, 20, 20), # Judas's fez and its tassel
+ "e": (44, 38, 44), "E": (14, 10, 14), # Eve's black hair
+ "s": (122, 82, 52), "S": (82, 52, 32), # Samson's long hair
+ "a": (70, 24, 24), "A": (204, 186, 166), # Azazel's horns
+}
+HAIR = {
+ "magdalene": [
+ "..........########..........",
+ "........##hhhhhhhh##........",
+ "......##hhhhhhhhhhhh##......",
+ ".....#hhhhhhhHHhhhhhhh#.....",
+ "....#hhhhhhhHHHHhhhhhhh#....",
+ "...#hhhhhhhH....Hhhhhhhh#...",
+ "..#hhhhhhH........Hhhhhhh#..",
+ "..#hhhhH............Hhhhh#..",
+ ".#hhhH................Hhhh#.",
+ ".#hhH..................Hhh#.",
+ "#hhH....................Hhh#",
+ "#hH......................Hh#",
+ ],
+ "cain": [
+ "........###.##.###..........",
+ ".......#ccc#cc#ccc##........",
+ "......#cccccccccccccc#......",
+ ".....#ccCccccCcccccCcc#.....",
+ "....#cccCCcccCCcccCCccc#....",
+ "...#ccC..CccC..CccC..Ccc#...",
+ "..#cC.....CC....CC....Ccc#..",
+ "..#C...................Cc#..",
+ ".#C.....................C#..",
+ ],
+ "judas": [
+ ".........######.............",
+ "........#ffffff#............",
+ ".......#ffffffff#...........",
+ ".......#fFffffff#tt.........",
+ ".......#fFffffff#.tt........",
+ "......##FFFFFFFF##.t........",
+ "......#fffffffffff#.........",
+ ],
+ "eve": [
+ "..........########..........",
+ "........##eeeeeeee##........",
+ "......##eeeeeeeeeeee##......",
+ ".....#eeeeeeeeeeeeeeee#.....",
+ "....#eeeeeeeeeeeeeeeeee#....",
+ "...#eeeeeeeeeeeeeeeeeeee#...",
+ "..#eeeeeeeeeeeeeeeeeeeeee#..",
+ "..#eeeEEe.eeEe..eEee.eEEe#..",
+ ".#eeeE....E........E...Eee#.",
+ ".#eeE...................Ee#.",
+ "#eeE.....................Ee#",
+ "#eE.......................e#",
+ ],
+ "samson": [
+ "..........##.##.##..........",
+ "........##ss#ss#ss##........",
+ "......##ssssssssssss##......",
+ ".....#ssssssssssssssss#.....",
+ "....#ssssSsssssssSsssss#....",
+ "...#sssSS.sSssssS.SSssss#...",
+ "..#ssSS.....SS.S......Sss#..",
+ "..#sS...................Ss#.",
+ ".#sS.....................Ss#",
+ ".#S.......................S#",
+ "#sS.......................S#",
+ "#S........................s#",
+ ],
+ "azazel": [
+ "AA......................AA..",
+ "aAA....................AAa..",
+ ".aAA..................AAa...",
+ "..aAA................AAa....",
+ "...aa................aa.....",
+ ],
+}
+# the colours of a body: ??? is blue, Azazel black with red eyes' tears
+SKINS = {
+ "bluebaby": {"+": (140, 168, 220), "o": (110, 136, 196), "r": (80, 100, 170), "#": (10, 10, 40)},
+ "azazel": {"+": (56, 48, 54), "o": (42, 36, 40), "r": (28, 24, 28), "#": (0, 0, 0), "b": (180, 30, 30),
+ "B": (120, 10, 10)},
+}
+CHARACTERS = ["isaac", "magdalene", "cain", "judas", "bluebaby", "eve", "samson", "azazel"]
+
+
+def frames(name):
+ """a character's head (6 frames) and body (9 frames), as art.isaac_frames() gives Isaac's"""
+ pal = dict(A.ISAAC)
+ pal.update(SKINS.get(name, {}))
+ pal.update(COLOURS)
+ heads = []
+ for k, rows in enumerate([A.HEAD_FRONT, A.HEAD_FRONT_CRY, A.HEAD_SIDE, A.HEAD_SIDE_CRY, A.HEAD_BACK, A.HEAD_BACK]):
+ rows = [list(r) for r in rows]
+ for y, line in enumerate(HAIR.get(name, [])):
+ for x, ch in enumerate(line):
+ if ch != "." and y < len(rows) and x < len(rows[y]):
+ rows[y][x] = ch
+ im = A.art(["".join(r) for r in rows], pal)
+ if name == "cain" and k < 2: # his eye patch over his right eye, and its strap
+ d = ImageDraw.Draw(im)
+ d.rectangle([4, 11, 9, 15], fill=(20, 20, 20, 255))
+ d.line([(3, 9), (24, 12)], fill=(20, 20, 20, 255))
+ heads.append(im)
+ bodies = []
+ for rows in [A.BODY_FRONT, A.BODY_FRONT_STEP, A.BODY_FRONT, None, A.BODY_SIDE, A.BODY_SIDE_STEP1, A.BODY_SIDE,
+ A.BODY_SIDE_STEP2, A.BODY_HOLD]:
+ bodies.append(A.art(A.BODY_FRONT_STEP, pal).transpose(Image.FLIP_LEFT_RIGHT) if rows is None else A.art(rows, pal))
+ return heads, bodies