diff --git a/projects/mazegame/emul/rom/mazegame.rom b/projects/mazegame/emul/rom/mazegame.rom index 992573c..0165761 100644 Binary files a/projects/mazegame/emul/rom/mazegame.rom and b/projects/mazegame/emul/rom/mazegame.rom differ diff --git a/projects/mazegame/mazegame.c b/projects/mazegame/mazegame.c index 42a69a3..a041ae7 100644 --- a/projects/mazegame/mazegame.c +++ b/projects/mazegame/mazegame.c @@ -1109,9 +1109,19 @@ void main(void) !IS_KEY_PRESSED(row5, KEY_S) && JOY_GET_DIR(g_Joy) == 0 && !IS_JOY_PRESSED(g_Joy, JOY_INPUT_TRIGGER_A)); - // C: teleport to exit + // C: teleport to one move away from the exit (the final step is left + // to the player). The exit (g_EX, MAZE_H-1) is a normal maze cell, so + // at least one of its up/left/right neighbours has an open passage to + // it; drop the player on the first such neighbour. if (IS_KEY_PRESSED(row3, KEY_C)) { - g_MX = g_EX; g_MY = MAZE_H - 1; + u8 ey = MAZE_H - 1; + if (g_DW[g_EX][ey-1] == 0) { // open above -> step down + g_MX = g_EX; g_MY = ey - 1; + } else if (g_EX > 0 && g_RW[g_EX-1][ey] == 0) { // open left -> step right + g_MX = g_EX - 1; g_MY = ey; + } else { // open right -> step left + g_MX = g_EX + 1; g_MY = ey; + } DrawFull(); row8 = 0xFF; continue;