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.

NumBlocks: a new picture, with the pickaxe held as in the game

Mason Chenbbb5c1d8e844
diff --git a/games/numblocks/docs/shot.png b/games/numblocks/docs/shot.png
index b37376db..2d1bf708 100644
Binary files a/games/numblocks/docs/shot.png and b/games/numblocks/docs/shot.png differ
diff --git a/games/numblocks/tests/play.c b/games/numblocks/tests/play.c
index c5b6e741..e1ccda17 100644
--- a/games/numblocks/tests/play.c
+++ b/games/numblocks/tests/play.c
@@ -2,8 +2,10 @@
*
* play [--frames N] [--ms-per-frame M] [--keys "10-40:fwd,50:use,..."] [--shots 30,60] [--out DIR]
* [--showcase] (the hotbar of the README's GIF: TNT, flint and steel, water and lava, blocks)
+ * [--animals] (a sheep, a cow, a pig and a chicken ahead, on the ground where they stand)
*
* Keys: left right up down fwd back sleft sright jump use attack inv sneak sprint pause 1..9. */
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -34,7 +36,7 @@ static uint32_t key_bit(const char *s) {
int main(int argc, char **argv) {
const char *out = "build/play", *shots = "";
- int give = 0, showcase = 0, title_screen = 0, mobs = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0, rain = 0;
+ int give = 0, showcase = 0, title_screen = 0, mobs = 0, animals = 0, start_time = -1, torches = 0, water = 0, creative = 0, build = 0, rain = 0;
float hurt = 0;
int frames = 60, mspf = 50;
for (int i = 1; i < argc; i++) {
@@ -46,6 +48,7 @@ int main(int argc, char **argv) {
else if (!strcmp(argv[i], "--showcase")) showcase = 1;
else if (!strcmp(argv[i], "--title")) title_screen = 1;
else if (!strcmp(argv[i], "--mobs")) mobs = 1;
+ else if (!strcmp(argv[i], "--animals")) animals = 1;
else if (!strcmp(argv[i], "--torches")) torches = 1;
else if (!strcmp(argv[i], "--water")) water = 1;
else if (!strcmp(argv[i], "--creative")) creative = 1;
@@ -148,6 +151,23 @@ int main(int argc, char **argv) {
if (e) e->health = 20, e->yaw = 180, e->gx = e->x, e->gz = e->z;
}
}
+ if (animals) {
+ /* a few animals ahead of the player (forward f, right r blocks), each on the first solid ground under it, facing
+ * the player */
+ float a = pl.yaw * 3.14159265f / 180, fx = -sinf(a), fz = cosf(a), rx = -cosf(a), rz = -sinf(a);
+ static const struct { int type; float f, r; } herd[] = {
+ {E_SHEEP, 5.2f, -1.7f}, {E_COW, 7.5f, 1.2f}, {E_PIG, 4.6f, 1.9f}, {E_CHICKEN, 3.6f, -0.6f}};
+ for (unsigned k = 0; k < sizeof herd / sizeof herd[0]; k++) {
+ float x = pl.x + fx * herd[k].f + rx * herd[k].r, z = pl.z + fz * herd[k].f + rz * herd[k].r;
+ for (int y = (int)pl.y + 8; y > (int)pl.y - 12; y--) {
+ float box[6] = {x - 0.3f, y - 0.5f, z - 0.3f, x + 0.3f, y - 0.01f, z + 0.3f};
+ if (phys_free(box)) continue;
+ Entity *e = ent_new(herd[k].type, x, (float)y, z);
+ if (e) e->health = 10, e->yaw = pl.yaw + 180 + (float)(k * 37 % 60) - 30, e->gx = e->x, e->gz = e->z;
+ break;
+ }
+ }
+ }
if (torches) {
/* torches around, for the night */
int fy = (int)pl.y;