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.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
NumBlocks: sneaking and walking at once works on a bridge (bridging)
Mason Chen4c7ea30362fd
diff --git a/games/numblocks/src/player.c b/games/numblocks/src/player.cindex 11425c47..a722d315 100644--- a/games/numblocks/src/player.c+++ b/games/numblocks/src/player.c@@ -26,19 +26,27 @@ static void move(float dx, float dy, float dz) {float a[6];box_of(pl.x, pl.y, pl.z, a);float ody = dy, odx = dx, odz = dz;- /* sneaking on the ground: no walking off edges */+ /* sneaking on the ground: no walking off edges (Entity.moveEntity: the box moved down 1 must still+ * touch a block, the one under the feet included, so sneaking along a one-block bridge works) */if (pl.on_ground && pl.sneaking) {float t[6];- for (; dx != 0; dx = fabsf(dx) < 0.05f ? 0 : dx - (dx > 0 ? 0.05f : -0.05f)) {+#define STEP(v) (fabsf(v) < 0.05f ? 0 : (v) - ((v) > 0 ? 0.05f : -0.05f))+ for (; dx != 0; dx = STEP(dx)) {memcpy(t, a, sizeof t);- t[0] += dx, t[3] += dx, t[1] -= 1, t[4] = t[1] + 1;- if (phys_clip(t, 1, -0.01f) > -0.01f) break; /* something under */+ t[0] += dx, t[3] += dx, t[1] -= 1, t[4] -= 1;+ if (!phys_free(t)) break; /* something under */}- for (; dz != 0; dz = fabsf(dz) < 0.05f ? 0 : dz - (dz > 0 ? 0.05f : -0.05f)) {+ for (; dz != 0; dz = STEP(dz)) {memcpy(t, a, sizeof t);- t[2] += dz, t[5] += dz, t[1] -= 1, t[4] = t[1] + 1;- if (phys_clip(t, 1, -0.01f) > -0.01f) break;+ t[2] += dz, t[5] += dz, t[1] -= 1, t[4] -= 1;+ if (!phys_free(t)) break;}+ for (; dx != 0 && dz != 0; dx = STEP(dx), dz = STEP(dz)) { /* (both at once: a corner) */+ memcpy(t, a, sizeof t);+ t[0] += dx, t[3] += dx, t[2] += dz, t[5] += dz, t[1] -= 1, t[4] -= 1;+ if (!phys_free(t)) break;+ }+#undef STEPodx = dx, odz = dz;}float mdy = phys_clip(a, 1, dy);diff --git a/games/numblocks/tests/unit.c b/games/numblocks/tests/unit.cindex 0a42e06f..2a2d6b9a 100644--- a/games/numblocks/tests/unit.c+++ b/games/numblocks/tests/unit.c@@ -588,6 +588,26 @@ int main(void) {delete_world(3);plat_remove_prefix("numblocks_saves.py");}+ /* sneaking along a one-block bridge over the void: it walks to the end and stops there (bridging);+ * not sneaking, it walks off */+ for (int sneak = 1; sneak >= 0; sneak--) {+ world_new(0, "ut4");+ world_follow(8, 70, 8);+ int y = 70;+ for (int z = 0; z <= 20; z++)+ for (int x = 0; x <= 16; x++)+ for (int k = -6; k < 4; k++) world_set(x, y + k, z, B_AIR);+ for (int z = 8; z <= 12; z++) world_set(8, y - 1, z, B_COBBLESTONE);+ memset(ents, 0, sizeof ents);+ pl.mode = 0, pl.dead = false, pl.health = 20, pl.flying = false;+ pl.x = 8.5f, pl.y = (float)y, pl.z = 8.5f, pl.vx = pl.vy = pl.vz = 0, pl.yaw = 0, pl.pitch = 0;+ pl.on_ground = true;+ uint32_t k = K_FWD | (sneak ? K_SNEAK : 0);+ for (int t = 0; t < 100; t++) player_tick(k, t ? 0 : k);+ if (sneak) CHECK(pl.y == (float)y && pl.z > 12.9f && pl.z < 13.31f);+ else CHECK(pl.y < (float)y - 1);+ plat_remove_prefix("ut4");+ }{/* keys saved as they first were (Back mining, OK placing) become OK mining, Back placing; set ones stay */keys_reset();