A brainfuck game engine -- because life wasn't hard enough before
Switch branches/tags
Nothing to show
Clone or download
MatheusAvellar πŸš— UI update hurray
I gotta finish that Tic Tac Toe game, eh
Latest commit 6df84d4 Sep 23, 2017

README.md

Brainfuck Game Engine

A work in progress game engine built to make use solely of the brainfuck language.

Screenshots

Insert funny 'an image is worth a thousand words' joke here, or something.

Development

The game code is separated in two files: load.bf and update.bf. The first is run only once, as to load a state to the tape, while the latter runs on every frame.

User input

Whenever the interpreter finds a , (comma) in the code, it reads whatever value is on the current cell and replaces it with the state of the corresponding input.

Valid values are listed below:

0 = Left arrow             => (0 = unpressed, 1 = pressed)
1 = Up arrow               => (0 = unpressed, 1 = pressed)
2 = Right arrow            => (0 = unpressed, 1 = pressed)
3 = Down arrow             => (0 = unpressed, 1 = pressed)
4 = 'A' key                => (0 = unpressed, 1 = pressed)
5 = 'S' key                => (0 = unpressed, 1 = pressed)
6 = X coordinate of mouse  => (0 to 24)
7 = Y coordinate of mouse  => (0 to 18)
8 = Mouse click            => (0 = unpressed, 1 = pressed)

Output

The game screen is drawn according to the first 25 Γ— 19 = 475 cells in the program tape after the first cell. They are equivalent to a grid on the canvas, where each value corresponds to a color:

0 = No change (shows the background color)
1 = Black (#333)
2 = Gray  (#ccc)
3 = White (#fff)
4 = Red   (#c33)
5 = Green (#3c3)
6 = Blue  (#33c)

Values wrap around, so a value of 7 would be equivalent to a 0 (background color), a value of 8 would be equivalent to a 1 (black), and so on.

Eventually, I'll figure out a way to allow people to change the default background color.

Why

To quote intergalactically famous fictional scientist and inventor Rick Sanchez,

The reason anyone would do this, if they could (which they can't), would be because they could (which they can't)

Credits

As mentioned on the source code, full credits to copy for the initial code for the compiler, available online at https://copy.sh/brainfuck/. I highly recommend a visit to copy's GitHub, everything is awesome in there.

I will most likely finish replacing the compiler in the future with one fully built by myself. However, for the moment, this should do nicely.