# The Walrus Game

The story of a girl teaching her pet walrus to unlock doors.

Basically, the player have to steer a walrus with blocks towards a door that only opens according to certain conditions. Every block the walrus steps on have special properties, such as changing its direction, managing a FIFO stack of 8-bit integers, and writing to a display. Therefore, this game is theorically Turing-complete.

## Level design

### Special layer class names

Some layers have special properties, the others are drawn, but ignored. The funge spritesheet should be the first one in the list.

| | |
|-|-|
|`level`| The tile layer the player and the walrus can interact with and should only use funge sprites. The rest are decorative layers and can contain anything.
|`player`| The layer the player is drawn on.
|`walrus`| The layer the walrus is drawn on.
|`collide`| The blocks can collide with this layer.

## Walfunge

Walfunge is the interpreter that powers the walrus. It resembles and is inspired from Befunge. Each block sprite occupying a space on the grid corresponds to an opcode in the interpreter, executed when the walrus steps on it. By default, a block moves the walrus one space forward, but it can also make it change directions, stop until the block is moved away, or jump to another space. It can also modify and do math on a stack, and push characters on a display.

Some special considerations:

* The level has a start point (spawn) and an end point (exit). The spawn point is directional, and is removed from play once the level starts, while the exit can be opened or closed according to a win condition. While closed, the exit acts as an empty space. Open, it warps to the next level.
* Blocks can be locked in place, or be movable by the player. They can also collide with other blocks and objects.
* Some blocks can make the walrus stop until the player moves the block away.
* If the interpreter encounters an error, such as a division by zero, the opcode will not execute and the walrus will stop, as if it encountered a stop block.
* If the walrus moves outside of the level, it will reappear on the other side.
* If the stack or the display reaches its maximum capacity, the interpreter may drop the item at the bottom of the stack to make room for the top.
* Display uses code page 863

### Errors

* Underflow
  - The opcode is going to pop more items than what's available in the stack
* Division by zero
* Out of memory
  - The stack does not currently have a max capacity, so in the unlikely case you somehow leave the game running on an infinite loop and your OS can't take it anymore it can crash