ASCII game - a compromise of authenticity and convenience

Hello everyone! While developing a game stylized as a text mode, I came to the expected contradiction. On the one hand, the game should be saturated with the spirit of the text mode, because for this I like it and, I hope, fans of retro games will like it. On the other hand, I want the gameplay to be as enjoyable and modern as possible. In this article I will describe five points on which I deviated from the true text mode. Did I manage to keep the tube alphanumeric mood in the game? I ask to express an opinion!



1. Character Set


Absolutely all the graphics in the game are made using the characters that are typed on the keyboard. To be more precise, the characters from the ASCII table from the 32nd to the 126th character are used.



However, the texts in the game are localized in several languages. Now I support Russian and English in parallel, but I want to add a few more, including Chinese. Characters from ASCII tables, even extended ones, are clearly not enough for these purposes.



Dialogs in the game may contain characters not from the authentic range. However, these characters are not involved in the design. Graphics are ASCII only.

2. Sub-character precision


Unlike text modes, ASCIIDENT uses pixel precision for moving text layers and moving sprites.



In text mode, sprite shifting by one position looks like a noticeable jump. For such a dynamic game as ASCIIDENT - this is unacceptable from the point of view of modern gaming experience. Therefore, for individual sprites and text layers, which will be discussed later, I made a smooth movement.

To maintain authenticity, I adhere to the following rule. Inside one text layer, all static objects are clearly aligned on the character grid. Moreover, each sprite consists of characters also aligned on a character grid.

Relative to each other, layers and moving objects can be located at a sub-symbolic distance. This ensures a smooth movement and, accordingly, a comfortable gameplay. This is such a compromise.

3. Parallax


The game has several text layers that move at different speeds, realizing the parallax effect. The symbols of the upper layers overlap the symbols of the lower ones. With sub-character precision, the overlap criterion is an overlay of more than 50% of the width and / or height of the text cell. Using a simple z-buffer, this overlap is easy to implement.



Parallax with smooth movement of layers is a very expressive graphic technique. Yes, it may greatly violate the authenticity of the text mode. However, I decided to use parallax. It turns out very beautifully.

4. Animation


Animation of individual sprites in the game "honest", made strictly in text mode. The position of each character is aligned on the text grid. Animations are obtained by replacing characters in cells.



I found it very important to maintain the integrity of sprite animations. This is probably the main thing that makes the game so retro-attractive. Moreover, with this type of animation, it becomes technically very simple to create and edit animated ASCII sprites. I could not resist and made a built-in ASCII editor in the game. At any time, any graphic element can be loaded into it and changed. You can, for example, edit the chest by adding animation frames, and after saving all the chests in all places of the game will become new. Any player can do this, thereby creating his own mod of the game.


However, sometimes you need smooth animation! For example, in the game there is such a place where biological optical fiber is grown. A drone flies above the beds, which irrigates the optical fiber with a toxic liquid. The liquid should drip smoothly, otherwise ugly. To implement such effects, I made sprite generators and their binding to any other sprites in the game world. Technically, every drop is a separate sprite that can move with subpixel accuracy. A reasonable compromise again.

5. Light, color and font


Many people to whom I show the game make the remark that there are too many colors in my game. In text modes there was no such richness of shades. The fact is that I implemented a full-screen lightmap that calculates any number of light sources. At the same time, the color of each character is 24-bit (16,777,216 different colors). Sometimes the picture looks colorful.



To emulate retro color modes, I made seven additional options: three monochrome modes, two 16-color modes (DOS / Mac), 2-bit and Game Boy mode. LED font mode is also available. In this mode, each pixel of each character is separated from neighboring ones. The video below shows all the modes - how they affect the picture.


The color conversion algorithm for monochrome modes made this. First, I calculate the color brightness (R, G, B):

V = 0.3 * R + 0.59 * G + 0.11 * B

Monochrome retro monitors have different color tones for different symbol brightness. Therefore, the shade must also change. I use such linear interpolation:

RR = sqrt (V) * (monoR1 * (1 - V) + monoR2 * V)

GG = sqrt (V) * (monoG1 * (1 - V) + monoG2 * V)

BB = sqrt (V ) * (monoB1 * (1 - V) + monoB2 * V)

Final color (RR, GG, BB)

For 16-color modes, I use a different algorithm. For each color (R, G, B) I am looking for the closest color in the palette. That's all.

2-bit and Game Boy mode has only four colors in the palette. A simple search for the nearest color gives a very dark picture. Therefore, before looking for a color in the palette, I do the normalization:

d = 1 / max (R, G, B)

normR = d * R, normG = d * G, normB = d * B

Formulas are schematic. Checks for division by zero did not mention. I hope that everyone who decides to play ASCIIDENT will be able to choose for themselves a color scheme that will maximally warm his or her retro soul.

6. Console with an honest text mode


In the process of creating the game, the idea came to put computer terminals with an honest text mode into the game world. You can approach them, connect and work / play.

If the game itself is stylized as an 80x25 text mode with smooth scrolling and parallax of text layers, then the built-in terminal screen has a resolution of 72x20 characters without any possibility to go beyond this grid.

All applications for embedded terminals (including the bootloader) are written in the DUHASM programming language. This language is similar to Assembler, but has dynamic variables and arrays. Here, for example, is a piece of Pi-astre Hanter game code:



A fun feature is that loops are implemented as part of conditional constructs, where LOOP is placed instead of END.

At launch, the game loads applications from * .duhasm files and compiles them into byte code. When a player activates the console, an honest interpreter is launched.

At the moment, I have written two games on DUHASM, which are already available in the current version. There is a plan to write a code editor (also on DUHASM of course) so that each player can try to create an application / game that all other players will see.


I hope that I have not in vain spent a lot of effort and time to implement this feature and there will be people who like it. The DUHASM language certainly needs some refinement. I don’t really like how, for example, functions are called with arguments. According to the history of the game, the DUHASM language came up with a semi-sensible cyborg who escaped from the laboratory of space pirates. Surprisingly, this programming language has taken root on the outskirts of the inhabited part of the universe.

CONCLUSION


Well, there were a lot of compromises - a set of characters, sub-character precision, animation, colors. But also to maintain a sense of authenticity to the text mode, I have undertaken a lot over these more than two years of development. To get more feedback and understand whether I’m moving in the right direction, I decided to start the game on early access in Steam . There is something magically attractive in text modes. When any picture can be typed with characters on the keyboard, it is sometimes difficult to resist and not start the game with the built-in ASCII editor, and even not draw a prototype of a new mini-game, which then will be implemented in the DUHASM language.



Thanks to all! Till!

All Articles