Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs

Xonitix - all the action you can get on a single line of a terminal

A topic by wildgaru created Nov 11, 2018 Views: 79
Viewing posts 1 to 1
Submitted (1 edit) (+1)

Hi Jammers! I'm new to itch.io so apologies in advance if this is not the preferred way to do things, but I was inspired by @yangamedev's posts and decided to give it a go, too. Hope you enjoy it :)

When I first heard of the Terminal Jam I got really excited. I usually spend a lot of my working hours looking at terminals, so switching contexts and thinking about what sort of game would I be able to design on that limited space got me out of the autopilot and started changing the way I thought about the command prompt. So much so that I decided to follow the "create an ASCII game" description to the letter and limit myself to actual 7-bit ASCII characters. No colors, no ncurses, not even the 128-255 so called "extended ASCII" characters.

I started thinking about classic terminal games like robots, Zork and, of course, MUDs. My first idea was to make something story-driven. It makes a lot of sense for ASCII-based terminal games, and I'm a huge fan of RPGs, but it would take a lot of time to make something good and unfortunately I only had a few hours to spare. Besides, the more I thought about it, the more I wanted to push the limits of my own personal challenge and move even further away from my comfort zone. What if I made an action game? An actual action game, on the terminal, without any special libraries and using only ASCII characters. Would that even be possible?

I kept some ideas cooking in the back of my mind. To be as true to the "terminal" as possible, I decided the game should be playable without clearing the entire screen, to pass a feeling that it was just another terminal command like "cd". You called it, played it, then moved on to the next command. But to make an action game I would probably need to refresh the screen somehow, and the only way (that I know of) to do it without clearing the screen is to carriage-return and replace a single line. So, to recap: action game, running on the terminal, ASCII only, and all the action must happen in just one line. Felt like I was sabotaging  myself by making it too hard.

Then inspiration came.

I remembered playing Xonix when I was a kid (yup, I'm that old, in case you haven't realized it from the other references). Now that was a fun, addictive and action packed terminal game! But it was too graphical, and I didn't want to clone it anyway. What if I could grab the essence of what made Xonix great in a single line? The concept was simple enough: fill up space to score points, and don't let the "enemies" hit you while doing it.

A fired up my editor, cooked up a simple game loop in C++ and tried to make a small dot bounce around a line on the terminal. After a couple of glitches (like having to hide the cursor) I finally got it working, and it looked promising. Then I put a small "_" to represent the player, and mapped the arrow keys so the player could move its character around. Like Xonix, the character would slide instead of moving a single space on every keypress, to keep players on their toes. But I also made the down key stop the character from moving, to allow some fine grained play as well.

Ok, but how would the player claim the space on the level? Contrary to Xonix where you move on a 2d space leaving a trail, I had just 1 dimension to play with, so I had to think of another way to capture the moving dots. I picked the spacebar to create a barrier of "|" on the line that would make the enemies bounce. In the spirit of conquering space, every time you place two barriers on the screen without any dots between them, all that area fills up, giving you more points. And whenever you fill more than 50% of the screen with barriers, you go to the next level, with the same horizontal space but with one extra moving dot to deal with. And if you tried placing a barrier right where the dot is, well, it's game over for you.

Thus, Xonitix was born \o/


Looks simple, but it's fun and it gets really hard really fast - specially if you don't maximize your window ;)

Now that I had a working game, it was time to make it portable in order to reach as many players as possible. To port Xonitix from OSX to Linux I had to change exactly zero lines of code, but Windows is a whole different beast and I had a lot of fun doing it, specially since I'd never written a terminal game for Windows before.


There are still some minor issues lurking around. For example, your score is related to the actual number of "|" on the screen, not the percentage of the line you filled, so a bigger terminal window means a bigger score. Also, if you make your terminal smaller while playing you'll likely break the game, because it relies on the "carriage return" ("\r") character to keep printing on the same line and if it wraps to 2 or more lines the carriage return just won't go back to where it was supposed to.  Maybe I'll fix those in a future version, or maybe I'll just leave it like that as a homage to all the other glitchy terminal games of the past ;)

Anyway, that's Xonitix, my entry for the 2018 Terminal Jam. I hope you like it and have fun with it. If you do, please jump to Xonitix game page and leave a comment!