Skip to main content
GameDev.net gamedev.net
🔒 Locked

ASCII Games

Started by KittyRa Feb 27, 2006 at 5:34 PM 8 replies 9.9k views
Original Post
KittyRa
KittyRa
Does anyone know any good tutorials about making ascii games? I want to make an ascii game with color and all that stuff. I'm using C++. Thanks.
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
Thevenin
Thevenin
High performance ascii games tend to flicker too much. Have a look at capn's 3H-GDC (Three Hour Game Dev Contest), you'll notice that most of them made mockery console windows powered by their favorite graphics API (DirectX/OpenGL/SDL/etc).

The .NET console class provides all the functionality you need to design a spiffy console game (Although, easier done with C# then C++); but if your designing anything graphic intensive you'll either need to use the Conio (SCL) and bare with the flickering, or do what they all did and make a mockery console.

btw... why are you using C++ as your beginner language? Your chances of succeeding are now virtually nil.

(Artist conception of GD.Net the Dungeon scroller.)


Edit: Oh wow, I went to reply 40 minutes ago, and only finished it now. xD
capn_midnight
capn_midnight
Actually, most people from the contest did not emulate the console window in a graphics API, most of them used the Win32 console API. Benryves provides a tutorial on using the Win32 console API on his website, to which there is a link in the pages of the contest thread. If you implement a custom double buffering system that only changes dirty characters, then you can elliminate the flickering, even with the .NET 2.0 console API (which is not exactly as complete as the Win32 API).

After that, the only problem then with the .NET 2.0 console API is the slow framerate. This isn't really a concern, though, as most ASCII games don't run that fast anyway.

Edit: Here's Ben's link
Extrarius
Extrarius
You don't even need to do 'dirty rectangles' to prevent flickering, just store a single buffer in memory and use WriteConsoleOutput when you're done updating the buffer (aka basic double buffering).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Lode
Lode
Quote:
Original post by Extrarius
You don't even need to do 'dirty rectangles' to prevent flickering, just store a single buffer in memory and use WriteConsoleOutput when you're done updating the buffer (aka basic double buffering).


That's how I made a submission for TMDC once.
KittyRa
KittyRa
Quote:
Original post by Theveninbtw... why are you using C++ as your beginner language? Your chances of succeeding are now virtually nil.
I've been programming in C++ for a while now and have been learning DirectX. I just wanted to go back and learn how to make ascii games.

Thanks for the link(s) capn_midnight should be useful.
everyone ++ratings
F-R-E-D F-R-E-D-B-U-R...G-E-R! - Yes!
benryves
benryves
Quote:
Original post by Extrarius
You don't even need to do 'dirty rectangles' to prevent flickering, just store a single buffer in memory and use WriteConsoleOutput when you're done updating the buffer (aka basic double buffering).
This flickers in windowed mode. In full-screen, it's flicker free though.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
Thevenin
Thevenin
Quote:
Original post by capn_midnight
Actually, most people from the contest did not emulate the console window in a graphics API, most of them used the Win32 console API. Benryves provides a tutorial on using the Win32 console API on his website, to which there is a link in the pages of the contest thread. If you implement a custom double buffering system that only changes dirty characters, then you can elliminate the flickering, even with the .NET 2.0 console API (which is not exactly as complete as the Win32 API).

After that, the only problem then with the .NET 2.0 console API is the slow framerate. This isn't really a concern, though, as most ASCII games don't run that fast anyway.


Hum.... yes, I was quite wrong about the amount of people who emulated the console; probably due to me playing that jumping star game more than any of the others (And it was emulated). 9 submissions; 3 emulated, 6 pure console.

Nevertheless though, the performace of the .NET 2.0 Console Class is a concern. The cost of SetCursorPosition seems to be incredibly high (Reducing your writes by only drawing parts that have changed can be just as costly as redrawing the entire screen (And I'm not referring to % > 50)).

Filling an 80x50 window with periodic colors.
(AMD Athlon 64 Processor, 3000+ (2.01GHz, 1.50GB of RAM))



using System;using System.Collections.Generic;using System.Text;using System.Media;using System.Drawing;using System.Windows.Forms;public partial class cMain{    public ConsoleColor MyLastColor;    int x = 0;    /* No touch. */    static void Main(string[] args)    {        cMain TheGame = new cMain();        TheGame.sLoad();    }    /* Load procedure; also main game loop. */    public void sLoad()    {        /* Configure the console window. */        Console.WindowWidth = 80;        Console.WindowHeight = 50;        Console.Title = "Performance Testing.Net Console Class (Thevenin) [C#]";        /* Game loop. */        int TheCurrentTickCount = Environment.TickCount;        int TheLastTickCount;        int TheLoop = 0;        while(TheLoop != 30)        {            for (int TheX = 0; TheX < 80; TheX++)                for (int TheY = 0; TheY < 50; TheY++)                {                    sRandomColor();                    Console.BackgroundColor = MyLastColor;                    Console.Write(" ");                }            Console.SetCursorPosition(0, 0);            TheLoop++;        }        TheLastTickCount = Environment.TickCount;        Console.Title += "(Avg Period: " + (TheLastTickCount - TheCurrentTickCount)/30 + "ms )";        Console.ReadLine();    }    public void sRandomColor()    {        switch (x)        {            case 0:                MyLastColor = ConsoleColor.Blue; break;             case 1:                MyLastColor = ConsoleColor.Red; break;             case 2:                MyLastColor = ConsoleColor.Green; break;             case 3:                MyLastColor = ConsoleColor.DarkBlue; break;            case 4:                MyLastColor = ConsoleColor.DarkGray; break;            case 5:                x = -1; break;        }        x++;    }}


Also, have a look at the source code I posted on the 3H-GDC thread. There it only redraws small changes in the stars, but it only gets about 9-11FPS.
Extrarius
Extrarius
Quote:
Original post by benryves
Quote:
Original post by Extrarius
You don't even need to do 'dirty rectangles' to prevent flickering, just store a single buffer in memory and use WriteConsoleOutput when you're done updating the buffer (aka basic double buffering).
This flickers in windowed mode. In full-screen, it's flicker free though.
Not for me. Things blur together since my implementation never got far enough to be time-based, but there was no flicker.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.