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.

Subway Surfers: taller tunnels, screenshots, GIFs and thumbnail

Mason36303a5bf5e2f47
diff --git a/docs/media/gallery/subway.gif b/docs/media/gallery/subway.gif
new file mode 100644
index 00000000..7c30b583
Binary files /dev/null and b/docs/media/gallery/subway.gif differ
diff --git a/docs/media/subway.gif b/docs/media/subway.gif
new file mode 100644
index 00000000..6a367f34
Binary files /dev/null and b/docs/media/subway.gif differ
diff --git a/docs/media/thumb_subway.png b/docs/media/thumb_subway.png
new file mode 100644
index 00000000..b31c497a
Binary files /dev/null and b/docs/media/thumb_subway.png differ
diff --git a/games/subway/docs/jetpack.png b/games/subway/docs/jetpack.png
new file mode 100644
index 00000000..2b50f7e0
Binary files /dev/null and b/games/subway/docs/jetpack.png differ
diff --git a/games/subway/docs/roofs.png b/games/subway/docs/roofs.png
new file mode 100644
index 00000000..81486e0f
Binary files /dev/null and b/games/subway/docs/roofs.png differ
diff --git a/games/subway/docs/run.png b/games/subway/docs/run.png
new file mode 100644
index 00000000..887eb787
Binary files /dev/null and b/games/subway/docs/run.png differ
diff --git a/games/subway/docs/shop.png b/games/subway/docs/shop.png
new file mode 100644
index 00000000..28a9314c
Binary files /dev/null and b/games/subway/docs/shop.png differ
diff --git a/games/subway/docs/title.png b/games/subway/docs/title.png
new file mode 100644
index 00000000..a26e6b88
Binary files /dev/null and b/games/subway/docs/title.png differ
diff --git a/games/subway/docs/tunnel.png b/games/subway/docs/tunnel.png
new file mode 100644
index 00000000..132d2da6
Binary files /dev/null and b/games/subway/docs/tunnel.png differ
diff --git a/games/subway/src/app.c b/games/subway/src/app.c
index 6874f921..afc6b036 100644
--- a/games/subway/src/app.c
+++ b/games/subway/src/app.c
@@ -165,6 +165,8 @@ static void shop_buy(void) {
static void camera_follow(void) {
float tx = pl.x * 0.75f, ty = CAM_Y + pl.ground * 0.85f + (pl.y - pl.ground) * 0.35f;
if (pl.fly > 0) ty = CAM_Y + pl.y * 0.8f;
+ /* under a tunnel's ceiling */
+ if ((world_tunnel(pl.z - CAM_BACK) || world_tunnel(pl.z + 4)) && ty > 7.9f) ty = 7.9f;
cam_x += (tx - cam_x) * 0.18f;
cam_y += (ty - cam_y) * 0.12f;
}
diff --git a/games/subway/src/game.c b/games/subway/src/game.c
index 67044997..9acb5171 100644
--- a/games/subway/src/game.c
+++ b/games/subway/src/game.c
@@ -12,6 +12,7 @@
#define STAND_H 1.75f
#define ROLL_H 0.85f
#define FLY_Y 8.0f
+#define FLY_LOW 5.0f /* (in a tunnel) */
#define PW 0.32f /* the runner's half width */
Runner pl;
@@ -415,7 +416,7 @@ void run_step(uint32_t keys, uint32_t pressed) {
/* up and down */
bool super = pl.power[PW_SNEAKERS] > 0 || (pl.hover > 0 && pg.board == 1);
if (pl.fly > 0) {
- float target = pl.fly;
+ float target = world_tunnel(pl.z + 12) || world_tunnel(pl.z) ? FLY_LOW : pl.fly;
pl.y += (target - pl.y) * 0.08f;
pl.vy = 0;
pl.state = ST_AIR;
diff --git a/games/subway/src/scene.c b/games/subway/src/scene.c
index 474df70b..e4597de7 100644
--- a/games/subway/src/scene.c
+++ b/games/subway/src/scene.c
@@ -16,6 +16,7 @@
#define SLEEPER_W 0.26f
#define WALL_X 5.8f
#define BLOCK 24.0f
+#define ROOF 8.5f /* a tunnel's ceiling */
enum { G_NONE, G_SLEEPER, G_MIX, G_KINDS };
static uint16_t ground[2][G_KINDS][GROUND_W * 2]; /* outside and in tunnels; levels one after the other */
@@ -426,23 +427,23 @@ static void open_block(int b, float z0, float dist) {
static void tunnel_block(float z0, float dist) {
bool first = !world_tunnel(z0 - 1);
uint32_t wall = 0x5A5F66, dark = 0x3A3E44;
- side(-WALL_X, 1, z0, z0 + BLOCK, 0, 7.2f, scene_lit(wall, z0), 0);
- side(WALL_X, -1, z0, z0 + BLOCK, 0, 7.2f, scene_lit(wall, z0), 0);
- ceiling(7.2f, -WALL_X, WALL_X, z0, z0 + BLOCK, scene_lit(dark, z0));
+ side(-WALL_X, 1, z0, z0 + BLOCK, 0, ROOF, scene_lit(wall, z0), 0);
+ side(WALL_X, -1, z0, z0 + BLOCK, 0, ROOF, scene_lit(wall, z0), 0);
+ ceiling(ROOF, -WALL_X, WALL_X, z0, z0 + BLOCK, scene_lit(dark, z0));
if (dist < 120)
for (int k = 0; k < 3; k++) {
float lz = z0 + 4 + (float)k * 8;
- side(-WALL_X + 0.01f, 1, lz, lz + 1.2f, 4.6f, 5.0f, 0xFFF2B0, P_DECAL | P_NOHAZE);
- side(WALL_X - 0.01f, -1, lz, lz + 1.2f, 4.6f, 5.0f, 0xFFF2B0, P_DECAL | P_NOHAZE);
- side(-WALL_X + 0.01f, 1, lz - 2, lz - 1.6f, 0, 7.2f, scene_lit(dark, z0), P_DECAL);
- side(WALL_X - 0.01f, -1, lz - 2, lz - 1.6f, 0, 7.2f, scene_lit(dark, z0), P_DECAL);
+ side(-WALL_X + 0.01f, 1, lz, lz + 1.2f, 5.6f, 6.0f, 0xFFF2B0, P_DECAL | P_NOHAZE);
+ side(WALL_X - 0.01f, -1, lz, lz + 1.2f, 5.6f, 6.0f, 0xFFF2B0, P_DECAL | P_NOHAZE);
+ side(-WALL_X + 0.01f, 1, lz - 2, lz - 1.6f, 0, ROOF, scene_lit(dark, z0), P_DECAL);
+ side(WALL_X - 0.01f, -1, lz - 2, lz - 1.6f, 0, ROOF, scene_lit(dark, z0), P_DECAL);
}
if (first) {
/* the way in: a big face of brick round the opening, with a frame */
uint32_t brick = 0x9A5A44, trim = 0x6E6A64, line = 0x84493A, top = 0x6E3E30;
- front(z0, -60, -WALL_X, 0, 13, brick, 0);
- front(z0, WALL_X, 60, 0, 13, brick, 0);
- front(z0, -WALL_X, WALL_X, 7.2f, 13, brick, 0);
+ front(z0, -60, -WALL_X, 0, 14, brick, 0);
+ front(z0, WALL_X, 60, 0, 14, brick, 0);
+ front(z0, -WALL_X, WALL_X, ROOF, 14, brick, 0);
/* courses of brick, a darker band on top, a frame round the opening */
if (dist < 110) {
for (int i = 1; i <= 4; i++) {
@@ -450,16 +451,16 @@ static void tunnel_block(float z0, float dist) {
front(z0, -60, -WALL_X - 0.9f, y, y + 0.12f, line, P_DECAL);
front(z0, WALL_X + 0.9f, 60, y, y + 0.12f, line, P_DECAL);
}
- front(z0, -60, 60, 10.9f, 11.02f, line, P_DECAL);
+ front(z0, -60, 60, 12.0f, 12.12f, line, P_DECAL);
}
- front(z0, -60, 60, 11.6f, 13, top, P_DECAL);
- front(z0, -WALL_X - 0.9f, -WALL_X, 0, 8.1f, trim, P_DECAL);
- front(z0, WALL_X, WALL_X + 0.9f, 0, 8.1f, trim, P_DECAL);
- front(z0, -WALL_X - 0.9f, WALL_X + 0.9f, 7.2f, 8.1f, trim, P_DECAL);
+ front(z0, -60, 60, 12.6f, 14, top, P_DECAL);
+ front(z0, -WALL_X - 0.9f, -WALL_X, 0, ROOF + 0.9f, trim, P_DECAL);
+ front(z0, WALL_X, WALL_X + 0.9f, 0, ROOF + 0.9f, trim, P_DECAL);
+ front(z0, -WALL_X - 0.9f, WALL_X + 0.9f, ROOF, ROOF + 0.9f, trim, P_DECAL);
/* the subway's sign over it */
- front(z0, -3.0f, 3.0f, 8.5f, 10.5f, 0x1A1A22, P_DECAL);
- front(z0, -2.8f, 2.8f, 8.7f, 10.3f, 0x2E5FA8, P_DECAL2);
- for (int i = 0; i < 3; i++) front(z0, -2.2f + 1.6f * (float)i, -1.2f + 1.6f * (float)i, 9.1f, 9.9f, 0xF4F4F4, P_DECAL3);
+ front(z0, -3.0f, 3.0f, 9.8f, 11.8f, 0x1A1A22, P_DECAL);
+ front(z0, -2.8f, 2.8f, 10.0f, 11.6f, 0x2E5FA8, P_DECAL2);
+ for (int i = 0; i < 3; i++) front(z0, -2.2f + 1.6f * (float)i, -1.2f + 1.6f * (float)i, 10.4f, 11.2f, 0xF4F4F4, P_DECAL3);
}
}
diff --git a/games/subway/src/world.c b/games/subway/src/world.c
index e9f79a0a..c49f86ea 100644
--- a/games/subway/src/world.c
+++ b/games/subway/src/world.c
@@ -307,7 +307,7 @@ void world_clear(float z0, float z1) {
nobs = k;
k = 0;
for (int i = 0; i < nitems; i++)
- if (items[i].z < z0 || items[i].z > z1 || items[i].y < 2.5f || items[i].y > 6) items[k++] = items[i];
+ if (items[i].z < z0 || items[i].z > z1 || items[i].y < 2.5f || items[i].y > 5.5f) items[k++] = items[i];
nitems = k;
if (gen_z < z1) gen_z = z1;
}
@@ -315,7 +315,7 @@ void world_clear(float z0, float z1) {
void world_sky_coins(float z0, float z1) {
int lane = rn(3);
for (float z = z0; z < z1 && nitems < MAXITEMS - 2; z += 1.6f) {
- item(I_COIN, LANE_X(lane), 8.6f, z);
+ item(I_COIN, LANE_X(lane), world_tunnel(z) || world_tunnel(z + 12) ? 5.6f : 8.6f, z);
if (rn(14) == 0) lane = lane == 1 ? rn(2) * 2 : 1;
}
}
diff --git a/games/subway/tests/play.c b/games/subway/tests/play.c
index 1755aa08..0511c740 100644
--- a/games/subway/tests/play.c
+++ b/games/subway/tests/play.c
@@ -1,7 +1,7 @@
/* Plays Subway Surfers on a computer, with scripted keys, and saves frames.
*
* play [--frames N] [--keys "10-40:right,50:ok,..."] [--shots 30,60|all] [--out DIR] [--saves DIR]
- * [--seed N] [--bot FROM] [--coins N] [--keys-owned N] [--draw-every N] [--power FRAME:KIND] [--god] [--stats]
+ * [--seed N] [--bot FROM] [--coins N] [--keys-owned N] [--draw-every N] [--power FRAME:KIND] [--god] [--when roof|tunnel] [--stats]
*
* Keys: left right up down ok back one three home. "a-b:key" holds the key from frame a to b, "a:key" for one
* frame (frames are the game's steps, 60 a second). --bot plays the run from frame FROM on: it reads the
@@ -136,7 +136,8 @@ int main(int argc, char **argv) {
const char *out = "build/shots", *shots = "", *saves = "build/host-saves";
long coins = -1, keys_owned = -1;
bool stats = false, god = false;
- const char *raw = NULL;
+ const char *raw = NULL, *when = NULL; /* when: a screenshot the first time the runner is on a roof, in a tunnel */
+ int when_n = 0;
int raw_from = 0, raw_to = -1; /* god: nothing hurts (long runs for tests) */
for (int i = 1; i < argc; i++) {
const char *a = argv[i], *v = i + 1 < argc ? argv[i + 1] : "";
@@ -152,6 +153,7 @@ int main(int argc, char **argv) {
else if (!strcmp(a, "--draw-every")) draw_every = atoi(v), i++;
else if (!strcmp(a, "--stats")) stats = true;
else if (!strcmp(a, "--god")) god = true;
+ else if (!strcmp(a, "--when")) when = v, i++;
else if (!strcmp(a, "--raw")) {
static char dir[256];
snprintf(dir, sizeof dir, "%s", v);
@@ -210,6 +212,11 @@ int main(int argc, char **argv) {
char list[8192];
snprintf(list, sizeof list, ",%s,", shots);
bool shot = all || strstr(list, name);
+ if (when && !pl.dead) {
+ bool now = (!strcmp(when, "roof") && pl.on_roof) || (!strcmp(when, "tunnel") && world_tunnel(pl.z - 2) && world_tunnel(pl.z + 30));
+ when_n = now ? when_n + 1 : 0;
+ if (when_n == 25) shot = true;
+ }
bool keep = raw && f >= raw_from && f <= raw_to && f % 4 == 0; /* (15 frames a second) */
if (shot || keep || f % draw_every == 0) {
app_draw();