RETURN TO GAMES
In July 2019, I coded a version of Lumberjack for the CHIP-8 in OCTO.
You are a lumberjack cutting down an incredibly tall tree, you can either cut from the left side or the right side to remove a chunk of the tree. Branches attached to the tree will come down as you cut. Choose your side to avoid colliding with a branch, which will cause a game over. But be careful as your time is limited, the slower you cut, the faster your time will deplete. Axe the tree as much as you can to get a high score in the limited time.
On the title screen, press A or D to start the game. Press A to cut the tree on the left side and press D to cut the tree on the right side. The top left corner shows your score, and below it is your time. When that fully depletes, it causes a game over. If you collide with a branch while chopping, that causes a game over. The game over screen will display your score. To restart the game, reload the page (you might then need to click the game window to focus on it).
Play the game!CHIP-8 is a programming language from the 1970s that is very limited in what it can do. It has 1-bit monochrome graphics and only has 15 useable registers for variables, making it a challenge to code for. CHIP-8 is most famous for being a very simple language to write an emulator for. It allows 16 hexadecimal keys from 1 to F for input, which are mapped onto a modern keyboard as follows:
1 | 2 | 3 | C |
---|---|---|---|
4 | 5 | 6 | D |
7 | 8 | 9 | E |
A | 0 | B | F |
1 | 2 | 3 | 4 |
---|---|---|---|
q | w | e | r |
a | s | d | f |
z | x | c | v |
I made a game for the CHIP-8 because of the amazing tool called OCTO, which is a modern IDE for CHIP-8 development made by John Earnest, and it makes it very easy to start programming for the CHIP-8.
This excellent website made me very excited to make my own game for the CHIP-8, and so that summer, as I was in Italy and did not have much else to do, I committed to learning just enough of OCTO assembly language to make a simple game, which is Lumberjack.
Lumberjack as a game already existed on other platforms, since at least 2016. I believe the game originated in this homebrew Commodore 64 game, but since then, it has been ported to many other platforms including the Amiga and a phone port. The specific version that inspired my CHIP-8 port is this Homebrew Gameboy implementation, which I think is an especially good implementation. What is good about this version is how crunchy each chop feels, with the screen fully shaking. Given the limitations of CHIP-8, my version could not have this level of responsiveness.
There were a few interesting quirks about the CHIP-8 that made programming for it interesting. The first is that given that its graphics are only 1-bit, each pixel is either on or off. Drawing pixels to the screen applies it as an XOR map, so 0 will keep the pixel the same, and 1 will flip the pixel, instead of overwriting its current value.
The screen is also not cleared every frame, this means that if you want to remove a sprite from the screen, you must call its draw function again in the same place, and it will undo that sprite.
This can be advantageous if there are lots of pixels that don’t need to be updated, as it means you don’t have to repeatedly draw the pixels to the screen every frame, but instead you can just draw it once. I did this with the surrounding two trees, which remain in the same place for the entire game. When animating the lumberjack swing his axe, it meant that before I could print the other frame, I first had to draw the first frame again to remove the old frame.
CHIP-8 sprites can only be 8 pixels high and 8 pixels wide, which means graphics larger than that must be split up into multiple individual sprites. The title image, which is 72x32 pixels had to be split up into 10 different sprites, and the game over graphic, which used a custom font, also had to be split up into 8 different sprites.
Another quirk of CHIP-8 is that all its registers are 8-bit, meaning that the largest number it can store is 255, and it cannot store fractions or negative numbers. This means that the highest unique possible score for this game is 255, and after reaching 255, the score count will loop back to 0. Of course, this does not mean it is not possible to score higher than 255, but it does mean that if you were to score higher than 255, a simple screenshot would no longer be sufficient proof, as you could have just as easily got that score without going through a loop.
Personally, I have never got to a looping score counter though. The highest score I have got in this game is 158, which must be the highest score anyone has won in this implementation of Lumberjack. If you score higher than me, I will certainly be impressed.
One feature I would add if I strongly felt like it, would be to allow the player to click any key after a game over to restart to the title. I think this would make the game far more convenient as you do not have to reload the entire game just to have another go. I would implement this, but since I made this game, I have completely forgotten OCTO assembly language (I wrote this game when I was 13), and I do not feel like relearning it just for this small tweak.
I have had no success running this game on any other CHIP-8 emulator, and I am not sure why.
If you are interested, here is the source code for this game, and here is the CHIP-8 file and its cartridge:
See if you can get a higher score than me. If you are at all interested in programming, I would certainly recommend making a game in CHIP-8 with OCTO, it was a very fun experience.