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: Magdalene, Cain, Judas, ???, Eve, Samson and Azazel

Mason3631d66d9861b6e
diff --git a/games/isaac/src/data.bin b/games/isaac/src/data.bin
index ef5d60e8..a69d2c6e 100644
Binary files a/games/isaac/src/data.bin and b/games/isaac/src/data.bin differ
diff --git a/games/isaac/src/data.h b/games/isaac/src/data.h
index ce9dcf13..7729b35e 100644
--- a/games/isaac/src/data.h
+++ b/games/isaac/src/data.h
@@ -11,6 +11,22 @@
enum {
SPR_ISAAC_HEAD,
SPR_ISAAC_BODY,
+ SPR_HEAD_ISAAC,
+ SPR_BODY_ISAAC,
+ SPR_HEAD_MAGDALENE,
+ SPR_BODY_MAGDALENE,
+ SPR_HEAD_CAIN,
+ SPR_BODY_CAIN,
+ SPR_HEAD_JUDAS,
+ SPR_BODY_JUDAS,
+ SPR_HEAD_BLUEBABY,
+ SPR_BODY_BLUEBABY,
+ SPR_HEAD_EVE,
+ SPR_BODY_EVE,
+ SPR_HEAD_SAMSON,
+ SPR_BODY_SAMSON,
+ SPR_HEAD_AZAZEL,
+ SPR_BODY_AZAZEL,
SPR_TEAR,
SPR_BLOOD_TEAR,
SPR_ENEMY_SHOT,
diff --git a/games/isaac/src/game.c b/games/isaac/src/game.c
index 859d7a91..7023daeb 100644
--- a/games/isaac/src/game.c
+++ b/games/isaac/src/game.c
@@ -14,7 +14,7 @@ bool g_room_was_cleared;
uint32_t g_run_seed, g_rng = 0x2545F491u;
uint8_t g_wins, g_best_stage;
uint16_t g_deaths, g_runs;
-static int menu_sel, pause_sel, confirm_sel, mode_t, ending;
+static int menu_sel, pause_sel, confirm_sel, mode_t, ending, char_sel;
static int trans_dir, trans_room;
static bool boss_hit; /* he was hurt in the boss's room (the Devil's deal) */
void pills_shuffle(void);
@@ -37,13 +37,15 @@ float fcos(float a) { return cosf(a); }
float dist2(float ax, float ay, float bx, float by) { return (ax - bx) * (ax - bx) + (ay - by) * (ay - by); }
/* ---------------------------------------------------------------- a run */
-void game_new_run(void) {
+uint8_t g_last_char;
+void game_new_run(int character) {
g_run_seed = g_rng ^ (plat_millis() * 2654435761u);
if (!g_run_seed) g_run_seed = 1;
g_rng = g_run_seed;
g_frame = 0;
- player_reset();
+ player_reset(character);
items_new_run();
+ player_starting_items();
pills_shuffle();
floor_new(1);
floor_enter_room(fl.start, DIR_NONE);
@@ -315,6 +317,50 @@ static void draw_menu(void) {
if (g_wins & (1 << i)) gfx_sprite_scaled(marks[i], 0, 112 + i * 32, 226, 90, 90, 0, 0, 0, 32);
}
+/* who plays: Rebirth's characters, their hearts and what they start with */
+static void draw_charsel(void) {
+ gfx_backdrop(BD_ISAACS_ROOM);
+ gfx_rect(0, 0, SCREEN_W, SCREEN_H, C_BLACK, 12);
+ paper(50, 20, 220, 196);
+ int c = char_sel;
+ bool open = character_unlocked(c);
+ gfx_text_c(FONT_UPHEAVAL, 160, 30, open ? character_name(c) : "???", INK, 2, false);
+ int head = character_head(c);
+ int bob = (int)(g_frame / 10 % 2);
+ gfx_ellipse(160, 118, 16, 5, C_BLACK, 10);
+ gfx_sprite_scaled(head + 1, 0, 160, 118, 512, 512, 0, C_BLACK, open ? 0 : 32, 32);
+ gfx_sprite_scaled(head, 0, 160, 104 + bob, 512, 512, 0, C_BLACK, open ? 0 : 32, 32);
+ /* the neighbours, smaller, either side */
+ for (int s = -1; s <= 1; s += 2) {
+ int n = (c + CH_COUNT + s) % CH_COUNT, nh = character_head(n);
+ bool o = character_unlocked(n);
+ gfx_sprite_scaled(nh + 1, 0, 160 + s * 76, 112, 256, 256, 0, C_BLACK, o ? 12 : 32, 24);
+ gfx_sprite_scaled(nh, 0, 160 + s * 76, 105, 256, 256, 0, C_BLACK, o ? 12 : 32, 24);
+ }
+ gfx_text_c(FONT_UPHEAVAL, 84, 100, "<", INK2, 2, false);
+ gfx_text_c(FONT_UPHEAVAL, 236, 100, ">", INK2, 2, false);
+ if (!open) {
+ gfx_text_c(FONT_UPHEAVAL, 160, 140, "LOCKED", rgb565(0x901010), 2, false);
+ gfx_text_c(FONT_UPHEAVAL, 160, 162, character_unlock_hint(c), INK2, 1, false);
+ return;
+ }
+ /* his hearts and his start, as the run will give them */
+ Player keep = pl;
+ player_reset(c);
+ int x0 = 160 - (pl.containers + pl.soul / 2) * 11 / 2;
+ for (int i = 0; i < pl.containers; i++) gfx_sprite(SPR_HUD_HEART, 0, x0 + i * 11, 136, 0, 32);
+ for (int i = 0; i < pl.soul / 2; i++) gfx_sprite(SPR_HUD_HEART, (pl.black >> i) & 1 ? 5 : 3, x0 + (pl.containers + i) * 11, 136, 0, 32);
+ pl = keep;
+ static const int16_t start[CH_COUNT][3] = {{0}, {45}, {46}, {34}, {36}, {122, 117, 126}, {157}, {118}};
+ int n = 0;
+ while (n < 3 && start[c][n]) n++;
+ for (int i = 0; i < n; i++) gfx_sprite(item_sprite(start[c][i]), 0, 160 - n * 13 + 13 + i * 26, 178, 0, 32);
+ static const char *const about[CH_COUNT] = {"THE ONE WHO STARTED IT ALL", "MORE HEARTS, SLOWER", "LUCKY, QUICK, A KEY",
+ "ONE HEART, HARD TEARS", "SOUL HEARTS ONLY", "CURSED, AND STRONGER FOR IT",
+ "ANGRIER WITH EVERY HIT", "SHORT BRIMSTONE, FLIES"};
+ gfx_text_c(FONT_UPHEAVAL, 160, 190, about[c], INK2, 1, false);
+}
+
static void draw_help(void) {
gfx_rect(0, 0, SCREEN_W, SCREEN_H, rgb565(0x1A1210), 32);
paper(14, 10, 292, 220);
@@ -396,8 +442,8 @@ static void draw_stage(void) {
/* Isaac falls through the dark to the next floor */
int y = k * 4 - 30;
if (y > 150) y = 150;
- gfx_sprite(SPR_ISAAC_BODY, 0, 160, y + 7, 0, 32);
- gfx_sprite(SPR_ISAAC_HEAD, 1, 160, y, 0, 32);
+ gfx_sprite(character_head(pl.character) + 1, 0, 160, y + 7, 0, 32);
+ gfx_sprite(character_head(pl.character), 1, 160, y, 0, 32);
gfx_text_c(FONT_UPHEAVAL, 160, 90, stage_name(fl.stage, fl.alt), C_WHITE, 3, false);
if (fl.curse) {
static const char *const names[6] = {"CURSE OF DARKNESS", "CURSE OF THE LOST", "CURSE OF THE UNKNOWN", "CURSE OF THE MAZE",
@@ -412,8 +458,8 @@ static void draw_dead(void) {
gfx_rect(0, 0, SCREEN_W, SCREEN_H, rgb565(0x140808), 32);
paper(40, 16, 240, 208);
gfx_text_c(FONT_UPHEAVAL, 160, 26, "YOU DIED", rgb565(0x901010), 3, false);
- gfx_sprite(SPR_ISAAC_BODY, 0, 90, 110, 0, 32);
- gfx_sprite(SPR_ISAAC_HEAD, 1, 90, 103, 0, 32);
+ gfx_sprite(character_head(pl.character) + 1, 0, 90, 110, 0, 32);
+ gfx_sprite(character_head(pl.character), 1, 90, 103, 0, 32);
gfx_text(FONT_UPHEAVAL, 120, 66, "KILLED BY", INK2, 1, false);
const char *who = mon_name(g_killer);
if (g_killer >= MON_MONSTRO) {
@@ -441,8 +487,8 @@ static void draw_win(void) {
{"ISAAC HAS FACED HIMSELF.", "IN THE LIGHT, NOTHING IS LEFT", "TO BE AFRAID OF.", "THE END."},
};
int e = ending & 3;
- gfx_sprite(SPR_ISAAC_BODY, 0, 160, 200, 0, 32);
- gfx_sprite(SPR_ISAAC_HEAD, e >= 2 ? 0 : 1, 160, 193, 0, 32);
+ gfx_sprite(character_head(pl.character) + 1, 0, 160, 200, 0, 32);
+ gfx_sprite(character_head(pl.character), e >= 2 ? 0 : 1, 160, 193, 0, 32);
for (int i = 0; i < 4; i++)
if (mode_t > i * 25) gfx_text_c(FONT_UPHEAVAL, 160, 50 + i * 26, text[e][i], C_WHITE, i == 0 || (e >= 2 && i == 3) ? 2 : 1, false);
if (mode_t > 110) gfx_text_c(FONT_UPHEAVAL, 160, 222, e >= 2 ? "OK: TO THE MENU" : "OK: GO ON", rgb565(0xB0B0B0), 1, false);
@@ -454,6 +500,7 @@ void game_draw(void) {
case MODE_TITLE: draw_title(); break;
case MODE_MENU: draw_menu(); break;
case MODE_HELP: draw_help(); break;
+ case MODE_CHARSEL: draw_charsel(); break;
case MODE_PLAY: case MODE_MAP: draw_room(); break;
case MODE_PAUSE: case MODE_CONFIRM: draw_pause(); break;
case MODE_STAGE: draw_stage(); break;
@@ -499,7 +546,7 @@ void game_frame(uint32_t keys) {
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();
+ if (pick == M_NEW) g_mode = MODE_CHARSEL, mode_t = 0, char_sel = g_last_char;
else if (pick == M_CONTROLS) g_swap = !g_swap, save_progress();
else if (pick == M_CONTINUE) {
if (load_run()) {
@@ -507,7 +554,7 @@ void game_frame(uint32_t keys) {
player_stats();
g_mode = MODE_PLAY;
} else
- game_new_run();
+ game_new_run(g_last_char);
} else
g_mode = MODE_HELP;
}
@@ -516,6 +563,17 @@ void game_frame(uint32_t keys) {
case MODE_HELP:
if (ok || (g_pressed & K_BACK)) g_mode = MODE_MENU;
break;
+ case MODE_CHARSEL:
+ g_frame++;
+ if (g_pressed & (K_LEFT | K_SLEFT)) char_sel = (char_sel + CH_COUNT - 1) % CH_COUNT;
+ if (g_pressed & (K_RIGHT | K_SRIGHT)) char_sel = (char_sel + 1) % CH_COUNT;
+ if (g_pressed & K_BACK) g_mode = MODE_MENU;
+ if (ok && character_unlocked(char_sel)) {
+ g_last_char = (uint8_t)char_sel;
+ save_progress();
+ game_new_run(char_sel);
+ }
+ break;
case MODE_STAGE:
g_frame++;
if (mode_t > 75 || (ok && mode_t > 10)) {
@@ -549,7 +607,7 @@ void game_frame(uint32_t keys) {
}
break;
case MODE_DEAD:
- if (mode_t > 30 && ok) game_new_run();
+ if (mode_t > 30 && ok) game_new_run(pl.character);
else if (mode_t > 30 && (g_pressed & K_BACK)) g_mode = MODE_MENU, menu_sel = 0;
break;
case MODE_WIN:
diff --git a/games/isaac/src/game.h b/games/isaac/src/game.h
index 1df44884..b708bd0c 100644
--- a/games/isaac/src/game.h
+++ b/games/isaac/src/game.h
@@ -78,11 +78,18 @@ typedef struct {
uint8_t pill_effect[14]; /* what each pill colour does this run */
float pill_tears, pill_range, pill_speed, pill_luck; /* what pills did to his stats */
uint8_t devil_deals; /* deals taken (no angels after one) */
+ uint8_t character; /* CH_* */
} Player;
extern Player pl;
-void player_reset(void);
+enum { CH_ISAAC, CH_MAGDALENE, CH_CAIN, CH_JUDAS, CH_BLUEBABY, CH_EVE, CH_SAMSON, CH_AZAZEL, CH_COUNT };
+void player_reset(int character);
+const char *character_name(int c);
+bool character_unlocked(int c);
+const char *character_unlock_hint(int c);
+int character_head(int c); /* its head's sprite (its body's is the next one) */
void player_stats(void); /* recomputes stats from the items */
+void player_starting_items(void);
void player_update(uint32_t keys);
void player_draw_shadow(void);
void player_draw(void);
@@ -121,6 +128,7 @@ typedef struct {
float width, dmg;
int16_t life, max;
uint8_t active, enemy, kind; /* kind: 0 blood (Brimstone), 1 tech, 2 holy, 3 Shoop */
+ float len; /* how far it reaches (0: to the wall) */
} Laser;
#define MAX_LASERS 8
extern Laser lasers[MAX_LASERS];
@@ -313,7 +321,7 @@ extern int16_t banner_t;
/* ---------------------------------------------------------------- the game */
enum { MODE_TITLE, MODE_MENU, MODE_PLAY, MODE_PAUSE, MODE_MAP, MODE_DEAD, MODE_WIN, MODE_STAGE, MODE_HELP,
- MODE_CONFIRM, MODE_STATS };
+ MODE_CONFIRM, MODE_STATS, MODE_CHARSEL };
extern int g_mode;
extern bool g_running;
extern uint32_t g_frame; /* frames since the run began */
@@ -332,7 +340,8 @@ extern bool g_swap; /* the number keys walk and the arrows cry (as
void game_init(void);
void game_frame(uint32_t keys);
void game_draw(void);
-void game_new_run(void);
+void game_new_run(int character);
+extern uint8_t g_last_char;
void game_next_floor(void);
void game_won(int how);
void game_over(void);
diff --git a/games/isaac/src/player.c b/games/isaac/src/player.c
index b421951e..af36b0d3 100644
--- a/games/isaac/src/player.c
+++ b/games/isaac/src/player.c
@@ -16,12 +16,69 @@ const int8_t DIR_X[4] = {0, -1, 0, 1}, DIR_Y[4] = {1, 0, -1, 0};
#define BASE_SPEED 3.2f /* pixels a frame at speed 1 */
-void player_reset(void) {
+/* ---------------------------------------------------------------- the characters, as Rebirth makes them */
+static const char *const char_names[CH_COUNT] = {"ISAAC", "MAGDALENE", "CAIN", "JUDAS", "???", "EVE", "SAMSON", "AZAZEL"};
+/* their damage (a multiplier), speed, range and luck */
+static const float ch_damage[CH_COUNT] = {1, 1, 1.2f, 1.35f, 1.05f, 0.75f, 1, 1.5f};
+static const float ch_speed[CH_COUNT] = {1, 0.85f, 1.3f, 1, 1.1f, 1.23f, 1.1f, 1.25f};
+static const float ch_range[CH_COUNT] = {23.75f, 23.75f, 20.25f, 23.75f, 23.75f, 23.75f, 21.75f, 23.75f};
+static const float ch_luck[CH_COUNT] = {0, 0, 1, 0, 0, 0, 0, 0};
+
+const char *character_name(int c) { return c >= 0 && c < CH_COUNT ? char_names[c] : ""; }
+int character_head(int c) { return SPR_HEAD_ISAAC + 2 * (c >= 0 && c < CH_COUNT ? c : 0); }
+/* the first four from the start; the others once Mom, her heart, or Satan or Isaac are beaten */
+bool character_unlocked(int c) {
+ switch (c) {
+ case CH_BLUEBABY: return g_wins & 2;
+ case CH_EVE: case CH_SAMSON: return g_wins & 1;
+ case CH_AZAZEL: return g_wins & 12;
+ default: return true;
+ }
+}
+const char *character_unlock_hint(int c) {
+ switch (c) {
+ case CH_BLUEBABY: return "BEAT MOM'S HEART";
+ case CH_EVE: case CH_SAMSON: return "BEAT MOM";
+ case CH_AZAZEL: return "BEAT SATAN OR ISAAC";
+ default: return "";
+ }
+}
+
+static void start_with(int item) {
+ item_give(item);
+ banner_t = 0;
+}
+
+void player_reset(int character) {
memset(&pl, 0, sizeof pl);
- pl.containers = 3, pl.red = 6;
- pl.bombs = 1;
+ pl.character = (uint8_t)(character >= 0 && character < CH_COUNT ? character : 0);
pl.face = DIR_DOWN, pl.shoot_dir = DIR_NONE;
pl.x = 160, pl.y = 120;
+ switch (pl.character) {
+ case CH_ISAAC: pl.containers = 3, pl.red = 6, pl.bombs = 1; break;
+ case CH_MAGDALENE: pl.containers = 4, pl.red = 8; break;
+ case CH_CAIN: pl.containers = 2, pl.red = 4, pl.keys = 1; break;
+ case CH_JUDAS: pl.containers = 1, pl.red = 2, pl.coins = 3; break;
+ case CH_BLUEBABY: pl.soul = 6; break;
+ case CH_EVE: pl.containers = 2, pl.red = 4; break;
+ case CH_SAMSON: pl.containers = 3, pl.red = 6; break;
+ case CH_AZAZEL: pl.soul = 6, pl.black = 7, pl.bombs = 1; break;
+ }
+ player_stats();
+}
+
+/* what each one starts with (once the pools are ready) */
+void player_starting_items(void) {
+ switch (pl.character) {
+ case CH_ISAAC: if (g_wins & 2) start_with(105); break; /* The D6, once Mom's Heart is beaten */
+ case CH_MAGDALENE: start_with(45); break;
+ case CH_CAIN: start_with(46); break;
+ case CH_JUDAS: start_with(34); break;
+ case CH_BLUEBABY: start_with(36); break;
+ case CH_EVE: start_with(122), start_with(117), start_with(126); break;
+ case CH_SAMSON: start_with(157); break;
+ default: break;
+ }
player_stats();
}
@@ -33,7 +90,8 @@ static float tear_delay_of(float t) {
/* every item's stats, from scratch (as the game's cache) */
void player_stats(void) {
const uint8_t *h = pl.has;
- float dmg_up = 0, flat = 0, mult = 1, tears = 0, range = 23.75f, shot = 1, speed = 1, luck = 0;
+ int ch = pl.character < CH_COUNT ? pl.character : 0;
+ float dmg_up = 0, flat = 0, mult = ch_damage[ch], tears = 0, range = ch_range[ch], shot = 1, speed = ch_speed[ch], luck = ch_luck[ch];
uint32_t tf = 0;
/* 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
@@ -80,7 +138,7 @@ void player_stats(void) {
if (h[169]) delay = delay * 2.1f + 3; /* Polyphemus */
if (h[52]) delay = delay * 2.5f; /* Dr. Fetus */
if (h[149]) delay = delay * 1.33f + 10; /* Ipecac */
- if (h[118]) delay = delay * 3; /* Brimstone: charging */
+ if (h[118] || ch == CH_AZAZEL) delay = delay * 3; /* Brimstone (Azazel's, shorter): charging */
if (h[69]) delay = delay * 2.5f; /* Chocolate Milk */
if (h[152]) delay = 2; /* Technology 2: a continuous laser (shots of it) */
if (h[6]) delay = tear_delay_of(tears) < 5 ? 5 : delay;
@@ -111,7 +169,7 @@ void player_stats(void) {
if (h[7] || h[51] || h[79] || h[80] || h[118] || h[157] || h[193] || h[186] || pl.belial || pl.damage >= 9) tf |= TF_BLOOD;
pl.tear_flags = tf;
pl.shots = h[153] ? 4 : h[2] ? 3 : h[245] ? 2 : 1;
- pl.flight = h[20] || h[82] || h[159] || h[179] || h[184] || h[185] || pl.bible || pl.pony;
+ pl.flight = h[20] || h[82] || h[159] || h[179] || h[184] || h[185] || pl.bible || pl.pony || ch == CH_AZAZEL;
}
int player_hearts_total(void) { return pl.red + pl.soul + pl.eternal; }
@@ -132,6 +190,10 @@ void player_add_soul(int halves, bool black) {
}
void player_add_containers(int n) {
+ if (pl.character == CH_BLUEBABY && n > 0) {
+ player_add_soul(2 * n, false);
+ return;
+ }
int c = pl.containers + n;
if (c > 12) c = 12;
if (c < 0) c = 0;
@@ -342,13 +404,14 @@ void player_update(uint32_t keys) {
if (pl.fire_cd > 0) pl.fire_cd -= 1;
if (pl.has[114]) {
knife_update(dir, dir != DIR_NONE);
- } else if (pl.has[118]) { /* Brimstone: charge, then let go */
+ } else if (pl.has[118] || pl.character == CH_AZAZEL) { /* Brimstone: charge, then let go (Azazel's reaches less far) */
static int bdir = DIR_DOWN;
if (dir != DIR_NONE) {
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.6f, 15, 0, false);
+ Laser *l = laser_fire(pl.x, pl.y - 10, bdir, 9, pl.damage * 0.6f, 15, 0, false);
+ if (l && !pl.has[118]) l->len = 80;
pl.charge = 0;
} else
pl.charge = 0;
@@ -395,6 +458,7 @@ void player_draw_shadow(void) {
}
void player_draw(void) {
+ int head = character_head(pl.character);
int x = (int)pl.x, y = (int)pl.y;
if (pl.flight) y -= 4 + (int)((g_frame / 6) % 2);
bool flash = pl.invuln > 0 && (pl.invuln / 3) % 2 == 0;
@@ -402,12 +466,12 @@ void player_draw(void) {
uint16_t tint = C_RED;
int amount = flash ? 14 : 0;
if (pl.dead) { /* fallen over, crying */
- gfx_sprite_tint(SPR_ISAAC_HEAD, 1, x, y + 2, 0, tint, 0, alpha);
+ gfx_sprite_tint(head, 1, x, y + 2, 0, tint, 0, alpha);
return;
}
if (pl.hold_anim > 0) { /* holding up what he just found */
- gfx_sprite(SPR_ISAAC_BODY, 8, x, y, 0, alpha);
- gfx_sprite(SPR_ISAAC_HEAD, 0, x, y - 7, 0, alpha);
+ gfx_sprite(head + 1, 8, x, y, 0, alpha);
+ gfx_sprite(head, 0, x, y - 7, 0, alpha);
if (pl.hold_item > 0) gfx_sprite(item_sprite(pl.hold_item), 0, x, y - 22, 0, 32);
return;
}
@@ -417,16 +481,16 @@ void player_draw(void) {
if (f == DIR_LEFT || f == DIR_RIGHT) body = 4 + (pl.walk ? step : 0), flags = f == DIR_LEFT ? GFX_FLIPX : 0;
else body = pl.walk ? step : 0;
int bob = (pl.walk && (step & 1)) ? 1 : 0;
- gfx_sprite_tint(SPR_ISAAC_BODY, body, x, y, flags, tint, amount, alpha);
+ gfx_sprite_tint(head + 1, body, x, y, flags, tint, amount, alpha);
/* the head looks the way he cries, or else the way he walks */
int hd = pl.shoot_dir != DIR_NONE ? pl.shoot_dir : pl.face;
- bool crying = pl.shoot_dir != DIR_NONE && (pl.fire_cd > pl.tear_delay * 0.5f || pl.has[118] || pl.has[69]);
- int head = hd == DIR_UP ? 4 : (hd == DIR_LEFT || hd == DIR_RIGHT) ? 2 : 0;
- if (crying) head++;
+ bool crying = pl.shoot_dir != DIR_NONE && (pl.fire_cd > pl.tear_delay * 0.5f || pl.has[118] || pl.has[69] || pl.character == CH_AZAZEL);
+ int hf = hd == DIR_UP ? 4 : (hd == DIR_LEFT || hd == DIR_RIGHT) ? 2 : 0;
+ if (crying) hf++;
int hflags = hd == DIR_LEFT ? GFX_FLIPX : 0;
- gfx_sprite_tint(SPR_ISAAC_HEAD, head, x, y - 7 + bob, hflags, tint, amount, alpha);
+ gfx_sprite_tint(head, hf, x, y - 7 + bob, hflags, tint, amount, alpha);
/* Brimstone and Chocolate Milk charge in a bar over his head */
- if ((pl.has[118] || pl.has[69] || pl.has[114]) && pl.charge > 0) {
+ if ((pl.has[118] || pl.has[69] || pl.has[114] || pl.character == CH_AZAZEL) && pl.charge > 0) {
float max = pl.has[114] ? 40 : pl.tear_delay;
int w = (int)(14 * pl.charge / max);
gfx_rect(x - 8, y - 34, 16, 4, C_BLACK, 24);
diff --git a/games/isaac/src/save.c b/games/isaac/src/save.c
index d80b2eba..251d36cb 100644
--- a/games/isaac/src/save.c
+++ b/games/isaac/src/save.c
@@ -241,7 +241,7 @@ typedef struct {
} Progress;
void save_progress(void) {
- Progress p = {PROGRESS_MAGIC, g_runs, g_deaths, g_wins, g_best_stage, {g_swap, 0}};
+ Progress p = {PROGRESS_MAGIC, g_runs, g_deaths, g_wins, g_best_stage, {g_swap, g_last_char}};
plat_save(PROGRESS_NAME, &p, sizeof p);
copy_write();
}
@@ -254,4 +254,5 @@ void load_progress(void) {
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_swap = p.pad[0] & 1;
+ g_last_char = p.pad[1] < CH_COUNT ? p.pad[1] : 0;
}
diff --git a/games/isaac/src/tears.c b/games/isaac/src/tears.c
index b85b91dd..9331a96d 100644
--- a/games/isaac/src/tears.c
+++ b/games/isaac/src/tears.c
@@ -259,12 +259,17 @@ static void laser_box(const Laser *l, float *x0, float *y0, float *x1, float *y1
return;
}
float fy = l->y + 10; /* (its floor line: the head is 10 over the feet) */
+ float len = l->len > 0 ? l->len : 400;
switch (l->dir) {
- case DIR_UP: *x0 = l->x - hw, *x1 = l->x + hw, *y0 = 0, *y1 = fy; break;
- case DIR_DOWN: *x0 = l->x - hw, *x1 = l->x + hw, *y0 = fy, *y1 = SCREEN_H; break;
- case DIR_LEFT: *x0 = 0, *x1 = l->x, *y0 = fy - hw, *y1 = fy + hw; break;
- default: *x0 = l->x, *x1 = SCREEN_W, *y0 = fy - hw, *y1 = fy + hw; break;
+ case DIR_UP: *x0 = l->x - hw, *x1 = l->x + hw, *y0 = fy - len, *y1 = fy; break;
+ case DIR_DOWN: *x0 = l->x - hw, *x1 = l->x + hw, *y0 = fy, *y1 = fy + len; break;
+ case DIR_LEFT: *x0 = l->x - len, *x1 = l->x, *y0 = fy - hw, *y1 = fy + hw; break;
+ default: *x0 = l->x, *x1 = l->x + len, *y0 = fy - hw, *y1 = fy + hw; break;
}
+ if (*y0 < 0) *y0 = 0;
+ if (*x0 < 0) *x0 = 0;
+ if (*y1 > SCREEN_H) *y1 = SCREEN_H;
+ if (*x1 > SCREEN_W) *x1 = SCREEN_W;
}
void lasers_update(void) {
diff --git a/games/isaac/tests/check.py b/games/isaac/tests/check.py
index 2acee993..c050d323 100644
--- a/games/isaac/tests/check.py
+++ b/games/isaac/tests/check.py
@@ -58,7 +58,7 @@ def expect(cond, 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")
+st = run(["--frames", "130", "--keys", "5:ok,15:ok,25:right,30:left,35: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})")
@@ -76,6 +76,11 @@ st = run(["--frames", "60", "--keys", "5:ok,15:ok"], "continue from the copy", s
expect(st and st["mode"] == MODE_PLAY, f"continue from the copy: not playing ({st})")
shutil.rmtree(saves, ignore_errors=True)
+# ---- each character, a while with the bot
+for ch in range(8):
+ st = run(["--run", "--char", str(ch), "--bot", "--god", "--frames", "1500", "--seed", str(ch)], f"character {ch}")
+ expect(st is not None, f"character {ch}")
+
# ---- 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}")
diff --git a/games/isaac/tests/play.c b/games/isaac/tests/play.c
index 14f4d390..9e456ce6 100644
--- a/games/isaac/tests/play.c
+++ b/games/isaac/tests/play.c
@@ -2,7 +2,7 @@
*
* 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]
+ * [--pocket KIND,ID] [--char CH]
*
* 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).
@@ -148,7 +148,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, immortal = false;
- int boss = -1, gokind = -1, pocket_kind = 0, pocket = 0;
+ int boss = -1, gokind = -1, pocket_kind = 0, pocket = 0, character = 0;
for (int i = 1; i < argc; i++) {
const char *a = argv[i];
const char *v = i + 1 < argc ? argv[i + 1] : "";
@@ -166,6 +166,7 @@ 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, "--char")) character = 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;
@@ -182,7 +183,7 @@ int main(int argc, char **argv) {
game_init();
if (run) {
host_time = (uint32_t)seed * 7919u;
- game_new_run();
+ game_new_run(character);
if (stage > 1) {
while (fl.stage < stage) game_next_floor();
}
diff --git a/games/isaac/tools/pack.py b/games/isaac/tools/pack.py
index ef2089b8..30c7fa51 100644
--- a/games/isaac/tools/pack.py
+++ b/games/isaac/tools/pack.py
@@ -27,6 +27,7 @@ from PIL import Image, ImageDraw, ImageFont
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import art as A # noqa: E402
+import characters as CH # noqa: E402
import rooms as R # noqa: E402
OUT_BIN = os.path.join(HERE, "..", "src", "data.bin")
@@ -191,6 +192,10 @@ def sprites():
heads, bodies = A.isaac_frames()
add("ISAAC_HEAD", [Frame(scaled(h), round(14 * SCALE), round(23 * SCALE)) for h in heads])
add("ISAAC_BODY", [Frame(scaled(b), round(14 * SCALE), round(9 * SCALE)) for b in bodies])
+ for n in CH.CHARACTERS: # each character's head and body, in CH.CHARACTERS's order (src/player.c's CH_*)
+ h, b = CH.frames(n)
+ add("HEAD_" + n.upper(), [Frame(scaled(x), round(14 * SCALE), round(23 * SCALE)) for x in h])
+ add("BODY_" + n.upper(), [Frame(scaled(x), round(14 * SCALE), round(9 * SCALE)) for x in b])
# tears and shots
add("TEAR", centred(ent("2.0.0 - Tear"), 1))
add("BLOOD_TEAR", centred(ent("2.1.0 - Blood Tear"), 1))