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.

4 Players: each game's key under the countdown, and fair starts

Mason363bd7e8b6a5dea
diff --git a/docs/media/gallery/fourplayer.gif b/docs/media/gallery/fourplayer.gif
index 9a1b581b..40981503 100644
Binary files a/docs/media/gallery/fourplayer.gif and b/docs/media/gallery/fourplayer.gif differ
diff --git a/games/fourplayer/docs/racing.png b/games/fourplayer/docs/racing.png
index 168168b7..d15f40cf 100644
Binary files a/games/fourplayer/docs/racing.png and b/games/fourplayer/docs/racing.png differ
diff --git a/games/fourplayer/docs/tanks.png b/games/fourplayer/docs/tanks.png
index 33fb4d36..870e6cb5 100644
Binary files a/games/fourplayer/docs/tanks.png and b/games/fourplayer/docs/tanks.png differ
diff --git a/games/fourplayer/src/app.c b/games/fourplayer/src/app.c
index 7edef087..661b14b7 100644
--- a/games/fourplayer/src/app.c
+++ b/games/fourplayer/src/app.c
@@ -365,6 +365,9 @@ static void countdown(int32_t left) { /* 3, 2, 1 */
int k = (int)(left % 667);
disc_a(160, 128, 34, INK, 200);
say(&np_font_title, 160, 136, s, k > 560 ? GOLD : WHITE);
+ int w = gfx_text_width(&np_font_body, G()->hint) + 24;
+ gfx_rrect(160 - w / 2, 170, w, 22, 11, INK, 210);
+ gfx_text_center(&np_font_body, 160, 185, G()->hint, WHITE, 256);
}
static void pips(int x, int y, int s, bool pop) { /* a side's rounds: won ones filled */
diff --git a/games/fourplayer/src/fp.h b/games/fourplayer/src/fp.h
index aad7b3e5..ebbf3418 100644
--- a/games/fourplayer/src/fp.h
+++ b/games/fourplayer/src/fp.h
@@ -81,7 +81,7 @@ char *num(char *o, uint32_t v);
/* ---- the minigames */
typedef struct {
- const char *name, *shortname, *rules;
+ const char *name, *shortname, *hint, *rules; /* hint: its key, under the countdown */
uint8_t last; /* the last side standing takes the round */
void (*start)(void);
void (*step)(void);
diff --git a/games/fourplayer/src/g_balloon.c b/games/fourplayer/src/g_balloon.c
index 7ad873a9..9de2406a 100644
--- a/games/fourplayer/src/g_balloon.c
+++ b/games/fourplayer/src/g_balloon.c
@@ -109,7 +109,7 @@ static int bot(int p) {
}
#endif
-const game_t g_balloon = {"Balloons", "Balloons",
+const game_t g_balloon = {"Balloons", "Balloons", "Tap pump",
"Tap your key to pump. Each balloon bursts at its own size, and nobody knows which. After 10 "
"seconds the biggest balloon still whole takes the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_birds.c b/games/fourplayer/src/g_birds.c
index 589bae7d..16b904eb 100644
--- a/games/fourplayer/src/g_birds.c
+++ b/games/fourplayer/src/g_birds.c
@@ -103,7 +103,7 @@ static int bot(int p) {
}
#endif
-const game_t g_birds = {"Birds", "Birds",
+const game_t g_birds = {"Birds", "Birds", "Tap flap",
"Every tap of your key is a flap. Fly through the gaps: touch a column or the ground and "
"you're out. The last bird flying takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_clock.c b/games/fourplayer/src/g_clock.c
index 8718ab31..e080cbea 100644
--- a/games/fourplayer/src/g_clock.c
+++ b/games/fourplayer/src/g_clock.c
@@ -102,7 +102,7 @@ static int bot(int p) {
}
#endif
-const game_t g_clock = {"Stop the Clock", "Clock",
+const game_t g_clock = {"Stop the Clock", "Clock", "Tap stop",
"The stopwatch hides after two seconds. Tap your key when you think it shows the time asked. "
"The closest takes the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_fish.c b/games/fourplayer/src/g_fish.c
index 99410ae1..e026c0b1 100644
--- a/games/fourplayer/src/g_fish.c
+++ b/games/fourplayer/src/g_fish.c
@@ -156,7 +156,7 @@ static int bot(int p) {
}
#endif
-const game_t g_fish = {"Grab the Fish", "Fish",
+const game_t g_fish = {"Grab the Fish", "Fish", "Tap swipe",
"Things jump out of the pond. Tap your key to swipe: the first paw on a goldfish keeps it. Swipe "
"at anything else and you're dizzy. Three goldfish take the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_frog.c b/games/fourplayer/src/g_frog.c
index c4b87fbc..d9529d79 100644
--- a/games/fourplayer/src/g_frog.c
+++ b/games/fourplayer/src/g_frog.c
@@ -131,7 +131,7 @@ static int bot(int p) {
}
#endif
-const game_t g_frog = {"Frog Jump", "Frogs",
+const game_t g_frog = {"Frog Jump", "Frogs", "Hold gather Let go jump",
"Hold your key to gather a jump: the ring shows where you'll land. Let go to jump. Miss the "
"lily pads and you swim back. The first frog across takes the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_gravity.c b/games/fourplayer/src/g_gravity.c
index e5c44d29..227434b2 100644
--- a/games/fourplayer/src/g_gravity.c
+++ b/games/fourplayer/src/g_gravity.c
@@ -127,7 +127,7 @@ static int bot(int p) {
}
#endif
-const game_t g_gravity = {"Gravity Run", "Gravity",
+const game_t g_gravity = {"Gravity Run", "Gravity", "Tap flip",
"You run on your own. Tap your key to flip your gravity, from the floor to the ceiling and "
"back. Fall through a hole and you're out: the last runner left takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_paint.c b/games/fourplayer/src/g_paint.c
index ba672074..e49df85f 100644
--- a/games/fourplayer/src/g_paint.c
+++ b/games/fourplayer/src/g_paint.c
@@ -118,7 +118,7 @@ static int bot(int p) {
}
#endif
-const game_t g_paint = {"Paint", "Paint",
+const game_t g_paint = {"Paint", "Paint", "Tap curve the other way",
"Your roller never stops and always curves. Tap your key to curve the other way. After 30 "
"seconds, the most floor in your colour takes the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_race.c b/games/fourplayer/src/g_race.c
index 01ad997e..2483b17a 100644
--- a/games/fourplayer/src/g_race.c
+++ b/games/fourplayer/src/g_race.c
@@ -40,8 +40,8 @@ static void start(void) {
for (int i = 0, k = 0; i < 3; i++)
if (i != skip) oil[k][0] = SPOT[i][0] + rr(-30, 30) * (i == 0), oil[k][1] = SPOT[i][1] + rr(-22, 22) * (i > 0), k++;
for (int p = 0; p < np; p++) {
- int row = p / 3, lane = p % 3, lanes = np < 3 ? np : 3;
- c[p].x = 148 - row * 22 - lane * 3, c[p].y = 212 + (lane - (lanes - 1) / 2.0f) * 16;
+ int lanes = np <= 3 ? np : (np + 1) / 2, row = p / lanes, lane = p % lanes; /* (two rows from 4 cars) */
+ c[p].x = 148 - row * 22 - lane * 3, c[p].y = 212 + (lane - (lanes - 1) / 2.0f) * 17;
c[p].h = c[p].va = 0, c[p].s = 0, c[p].oil_t = -10000, c[p].bump_t = -10000;
c[p].last_a = fatan2(c[p].y - MY, c[p].x - MX), c[p].prog = PI / 2 - c[p].last_a;
}
@@ -144,7 +144,7 @@ static void draw(void) {
float h = c[p].h;
if (rt - c[p].oil_t < 550) h += (rt - c[p].oil_t) * 0.012f; /* a spin on the oil */
car(p, c[p].x, c[p].y, h);
- tag_by(p, c[p].x - 6, c[p].y, -1);
+ tag_by(p, c[p].x + (c[p].x > 140 ? 6 : -6), c[p].y, c[p].x > 140 ? 1 : -1); /* (the front row's ahead of it) */
}
}
@@ -164,7 +164,7 @@ static int bot(int p) {
}
#endif
-const game_t g_race = {"Racing", "Racing",
+const game_t g_race = {"Racing", "Racing", "Hold turn left",
"Your car drives itself. Hold your key to turn left: every bend turns left. Grass slows you, oil "
"spins you. Three laps: the first one home takes the round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_rope.c b/games/fourplayer/src/g_rope.c
index b1cbf195..61a3e33f 100644
--- a/games/fourplayer/src/g_rope.c
+++ b/games/fourplayer/src/g_rope.c
@@ -107,7 +107,7 @@ static int bot(int p) {
}
#endif
-const game_t g_rope = {"Jump Rope", "Rope",
+const game_t g_rope = {"Jump Rope", "Rope", "Tap jump",
"A bar sweeps round the platform. Tap your key to jump over it. Caught on the ground, you're "
"thrown off. The last one standing takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_skate.c b/games/fourplayer/src/g_skate.c
index 017a9c67..a42427dd 100644
--- a/games/fourplayer/src/g_skate.c
+++ b/games/fourplayer/src/g_skate.c
@@ -86,7 +86,7 @@ static int bot(int p) {
}
#endif
-const game_t g_skate = {"Skate Race", "Skate",
+const game_t g_skate = {"Skate Race", "Skate", "Tap kick",
"Every tap of your key is a kick. Tap as fast as you can: the first over the line takes the "
"round.",
0, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_snakes.c b/games/fourplayer/src/g_snakes.c
index e4fbff87..b104c94f 100644
--- a/games/fourplayer/src/g_snakes.c
+++ b/games/fourplayer/src/g_snakes.c
@@ -174,7 +174,7 @@ static int bot(int p) {
}
#endif
-const game_t g_snakes = {"Snakes", "Snakes",
+const game_t g_snakes = {"Snakes", "Snakes", "Tap turn right",
"Your snake never stops. Tap your key to turn right. Stars make you longer. Hit a wall or a "
"snake, yours too, and you're out: the last snake left takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_soccer.c b/games/fourplayer/src/g_soccer.c
index 2fc18613..5b4e829d 100644
--- a/games/fourplayer/src/g_soccer.c
+++ b/games/fourplayer/src/g_soccer.c
@@ -193,7 +193,7 @@ static int bot(int p) {
}
#endif
-const game_t g_soccer = {"Soccer", "Soccer",
+const game_t g_soccer = {"Soccer", "Soccer", "Tap dash",
"Your arrow spins. Tap your key to dash where it points and hit the ball. Two sides: the first "
"goal takes the round. With three or four, let one in and you're out.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_sumo.c b/games/fourplayer/src/g_sumo.c
index 9a2e6400..a22e4802 100644
--- a/games/fourplayer/src/g_sumo.c
+++ b/games/fourplayer/src/g_sumo.c
@@ -120,7 +120,7 @@ static int bot(int p) {
}
#endif
-const game_t g_sumo = {"Sumo", "Sumo",
+const game_t g_sumo = {"Sumo", "Sumo", "Tap dash",
"Your arrow spins. Tap your key to dash where it points: the spin turns the other way. Push the "
"others into the sea. The last one on the ice takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/src/g_tanks.c b/games/fourplayer/src/g_tanks.c
index d43230ca..8cbe110c 100644
--- a/games/fourplayer/src/g_tanks.c
+++ b/games/fourplayer/src/g_tanks.c
@@ -13,9 +13,9 @@ typedef struct {
int16_t x, y, w, h;
} rect_t;
static const rect_t LAYOUT[3][7] = {
- {{152, 86, 16, 90}, {115, 123, 90, 16}, {70, 72, 26, 14}, {224, 72, 26, 14}, {70, 190, 26, 14}, {224, 190, 26, 14}},
- {{100, 62, 14, 48}, {206, 62, 14, 48}, {100, 154, 14, 48}, {206, 154, 14, 48}, {145, 116, 30, 30}},
- {{80, 70, 18, 18}, {151, 70, 18, 18}, {222, 70, 18, 18}, {80, 174, 18, 18}, {151, 174, 18, 18}, {222, 174, 18, 18},
+ {{152, 86, 16, 90}, {115, 123, 90, 16}, {84, 76, 26, 14}, {210, 76, 26, 14}, {84, 172, 26, 14}, {210, 172, 26, 14}},
+ {{112, 66, 14, 44}, {194, 66, 14, 44}, {112, 152, 14, 44}, {194, 152, 14, 44}, {145, 116, 30, 30}},
+ {{92, 74, 18, 18}, {151, 70, 18, 18}, {210, 74, 18, 18}, {92, 170, 18, 18}, {151, 174, 18, 18}, {210, 170, 18, 18},
{120, 122, 80, 18}},
};
static const rect_t *map;
@@ -31,6 +31,7 @@ static struct {
int32_t born;
} sh[NSH];
+static void push_out(body_t *b);
static void start(void) {
int k = rn(3);
map = LAYOUT[k], nmap = 0;
@@ -39,6 +40,7 @@ static void start(void) {
float s = seat(p);
t[p].b = (body_t){160 + fcos(s) * 122, 131 + fsin(s) * 82, 0, 0};
if (np == 3 && p == 2) t[p].b.y = 214;
+ push_out(&t[p].b);
t[p].a = fatan2(131 - t[p].b.y, 160 - t[p].b.x), t[p].shot_t = -10000, t[p].dead_t = -1;
}
for (int i = 0; i < NSH; i++) sh[i].own = -1;
@@ -194,7 +196,7 @@ static int bot(int p) {
}
#endif
-const game_t g_tanks = {"Tanks", "Tanks",
+const game_t g_tanks = {"Tanks", "Tanks", "Hold drive Let go fire",
"Your tank turns on the spot. Hold your key to drive, let go to fire. Shells bounce off the "
"walls. One hit and you're out: the last tank left takes the round.",
1, start, step, draw, icon BOT(bot)};
diff --git a/games/fourplayer/tests/rules/tanks.c b/games/fourplayer/tests/rules/tanks.c
index 1e38c79d..24b859c5 100644
--- a/games/fourplayer/tests/rules/tanks.c
+++ b/games/fourplayer/tests/rules/tanks.c
@@ -61,6 +61,21 @@ void rules_tanks(void) {
run(0, 100);
CHECK(gone[0] && WINNER == 1, "tanks: your own shell can hit you");
+ bool clear = true; /* every layout, every mode: nobody starts against a wall */
+ for (int m = 0; m < 5; m++)
+ for (int k = 0; k < 30; k++) {
+ app_test_round(m, G_TANKS);
+ for (int p = 0; p < np; p++) {
+ body_t b = t[p].b;
+ push_out(&b);
+ clear &= b.x == t[p].b.x && b.y == t[p].b.y;
+ for (int i = 0; i < nmap; i++)
+ clear &= !(t[p].b.x > map[i].x - TR - 2 && t[p].b.x < map[i].x + map[i].w + TR + 2 &&
+ t[p].b.y > map[i].y - TR - 2 && t[p].b.y < map[i].y + map[i].h + TR + 2);
+ }
+ }
+ CHECK(clear, "tanks: no tank starts against a wall");
+
app_test_round(M2, G_TANKS); /* the walls */
t[0].b = (body_t){map[0].x + map[0].w / 2.0f, map[0].y + map[0].h / 2.0f, 0, 0};
app_test_step(0);