<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>How to make an ASCII game in terminal?</title>
		<link>http://www.allegro.cc/forums/view/616108</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 21 Mar 2016 18:49:26 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would like to modify certain coordinates on the terminal screen for example.  How would I be able to draw, say, char <span class="source-code">c</span> at <span class="source-code">x</span>, <span class="source-code">y</span>?  All I know is that the terminal outputs chars and scrolls up like a typewriter.</p><p>I&#39;m talking about a graphics-based game that plays out on the terminal in all it&#39;s ASCII glory.  Do you have a big char buffer and just clear/write it?  How does something like that work?</p><p>Any help, thanks <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Wed, 09 Mar 2016 10:42:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think you typically use something like <a href="https://www.gnu.org/software/ncurses/">ncurses</a>. It literally has a <a href="http://pubs.opengroup.org/onlinepubs/7908799/xcurses/mvprintw.html">function</a> that allows you to print stuff at the location you want.</p><p>No idea how it actually works underneath the hood though <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 09 Mar 2016 11:16:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You will probably want to look into the <a href="https://en.wikipedia.org/wiki/Curses_(programming_library)">curses library family</a>... Generally there&#39;s the problem of different terminals speaking different &quot;control characters&quot; so you will certainly want a library to do it. In the general sense, control characters written as bytes to the terminal device (just as with any other data) are specially interpreted... Knowing that you can achieve dynamic content on supported terminals and emulators.</p><p><tt>/beaten</tt>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Wed, 09 Mar 2016 11:20:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In case you&#39;re curious, such library typically relies on the terminal&#39;s support of some character sequences, especially using the characters with codes in the 0-31 range.<br />For example in a MS-DOS or Linux/Unix console, printing the C string: <span class="source-code"><span class="s">"\x1B[10;12H"</span></span> would move the cursor to position 10, 12<br />( \x1B is the single character of ASCII code 27: &#39;ESC&#39;)<br /><a href="http://www.real-world-systems.com/docs/ANSIcode.html">http://www.real-world-systems.com/docs/ANSIcode.html</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Wed, 09 Mar 2016 15:15:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah, ANSI-codes are fun. Didn&#39;t work on Windows, though, last time I tried. <br />There might be old conio.h support on some Windows compilers, I believe there is also Windows API stuff to clear a terminal screen and to do other things. You can hack together some simple abstraction if you feel like it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Polybios)</author>
		<pubDate>Wed, 09 Mar 2016 20:25:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t think cmd.exe supports ANSI. At least, not colors... I have a Mercurial wrapper that toggles the color configuration setting so that paged things that are piped to less use &quot;ansi&quot; and unpaged things use &quot;win32&quot; codes, whatever that means, but I imagine it&#39;s custom...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (bamccaig)</author>
		<pubDate>Wed, 09 Mar 2016 20:30:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Reminds me of my time maintaining a MUD <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> Clients connected using telnet, color codes...<br />Nowadays there is a running &quot;Nyan cat&quot; server if you want to see how your telnet.exe supports the standards<br /><a href="http://nyancat.dakko.us/">http://nyancat.dakko.us/</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Audric)</author>
		<pubDate>Fri, 11 Mar 2016 01:58:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>conio.h would make the work too.  I don&#39;t know if any modern compiler still support it though.  Free Pascal has CRT units.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Niunio)</author>
		<pubDate>Thu, 17 Mar 2016 14:39:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ways to do it (links in Python):</p><ul><li><p><a href="https://docs.python.org/3/howto/curses.html#curses-howto">curses</a></p></li><li><p>Emacs Lisp (because <a href="http://catern.com/posts/terminal_quirks.html">terminals are weird</a>)</p></li><li><p><a href="http://www.clifford.at/stfl/">STFL</a></p></li><li><p><a href="http://urwid.org/">Urwid</a></p></li><li><p><a href="http://npyscreen.readthedocs.org/introduction.html">npyscreen</a></p></li></ul><p>

Input is a key concept.  You wait for a character (not keypress) to appear.  Any notion of a key being held down is limited by users&#39; key repeat rates and your ability to hack around them.  Ｄｏｕｂｌｅ－ｗｉｄｔｈ　ｃｈａｒａｃｔｅｒｓ require extra care.  I have found developing within XTerm (maintained by the same maintainer as ncurses) has provided peace of mind, as XTerm is ubiquitous and goes hand in hand with ncurses.</p><p>Draw text the way the terminal does naturally--left to right, top to bottom.  Doing otherwise can slow down your program.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gideon Weems)</author>
		<pubDate>Sun, 20 Mar 2016 01:58:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you considered &quot;emulating&quot; terminal?</p><p>Terminal<br /> + Works over SSH / etc<br /> - Bandwidth issues<br /> - Features are only available per terminal software support<br /> - Portability problems (UNIX color codes on UNIX, Windows/UNIX both support different resolution sizes, as well as line ending encoding)</p><p>Emulated:<br /> + No need for users to have a terminal<br /> + Simulate any features as needed<br /> + Faster draw rate<br /> - No actual terminal support, so no cool SSHing</p><p>Remember Dwarf Fortress? They moved over to emulated terminal so that people could easily switch out text characters with graphic tilesets.</p><p>One thing I&#39;ve loved that most people never saw: You can edit font glyphs in real time in DOS. So you can actually draw &quot;graphics&quot; in text mode.</p><p>All of these are standard 16-color (&lt;- IIRC) text mode from the same game system:</p><p><span class="remote-thumbnail"><span class="json">{"name":"maxresdefault.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/a\/fa78507cc38ac3f6b2fadc282ed78f88.jpg","w":1920,"h":1080,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/a\/fa78507cc38ac3f6b2fadc282ed78f88"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/f/a/fa78507cc38ac3f6b2fadc282ed78f88-240.jpg" alt="maxresdefault.jpg" width="240" height="135" /></span></p><p><span class="remote-thumbnail"><span class="json">{"name":"320px-And.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9e2fbec0f4787576e8ed8441ae20fe5.png","w":320,"h":175,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/e\/9\/e9e2fbec0f4787576e8ed8441ae20fe5"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/e/9/e9e2fbec0f4787576e8ed8441ae20fe5-240.jpg" alt="320px-And.png" width="240" height="131" /></span></p><p><span class="remote-thumbnail"><span class="json">{"name":"glade03.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f450e5c723857228a8bafd4b07987eb.png","w":592,"h":322,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/f\/0f450e5c723857228a8bafd4b07987eb"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/0/f/0f450e5c723857228a8bafd4b07987eb-240.jpg" alt="glade03.png" width="240" height="130" /></span></p><p><span class="remote-thumbnail"><span class="json">{"name":"ejet2.gif","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/4\/a4585810b48b3964a7a5cdd6f9614de9.gif","w":640,"h":350,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/4\/a4585810b48b3964a7a5cdd6f9614de9"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/a/4/a4585810b48b3964a7a5cdd6f9614de9-240.jpg" alt="ejet2.gif" width="240" height="131" /></span></p><p>MegaZeux was a spiritual successor to ZZT and basically &quot;ZZT on crack&quot;. Some of my first games ever were made in MegaZeux.</p><p>I loved working within the constraints of 256 glyphs of ~16x8 bicolor, 16 colors total. You could do &quot;animations&quot; by changing glyphs--either replacing one character with another, or changing the glyph itself. (Like a bitmap version of palette swapping. Changing the glyph changed all characters using it.) You could do bigger characters by combining glyphs together.</p><p>People did INSANE stuff with Megazeux like doing actual animated cutscenes by spamming glyph and palette color changes each frame.</p><p>Megazeux also supported MODs/S3ms.</p><p><div class="media-player youtube"><div style="margin: 1em 2em; background: url(/images/movie.png); width: 180px; height: 100px; text-align: center;"><a href="http://www.allegro.cc//www.youtube.com/watch?v=v1B-W5tbtnk" target="_blank"><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/object/e/c/ecc92f55e53eb3e9ead118a8152885da.jpg" border="0" alt="video" title="Click to play video" /></a></div></div></p><p>This is text mode!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Sun, 20 Mar 2016 02:47:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616108/1021018#target">Chris Katko</a> said:</div><div class="quote"><p>Have you considered &quot;emulating&quot; terminal?</p></div></div><p>I have actually, but it&#39;s not something I&#39;m interested in. The purpose of this project would be to have a terminal window with graphical output alongside other programs in a multi-pane terminal session.</p><p>Emulating an ASCII-only display in, say, a Allegro is a bit overkill since I&#39;m actually going for &quot;underkill&quot; <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Sun, 20 Mar 2016 20:29:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I had never heard of MegaZeux until now.  Had it come along at the right time in my life, I would have fallen head over heels for it.  S3M support seals the deal.</p><p>Thanks for the history lesson.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Gideon Weems)</author>
		<pubDate>Mon, 21 Mar 2016 06:57:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Megazeux correction, it was VGA text mode so you have a 64-color (real-time adjustable) palette. This video explains the details of how the software works.</p><p><div class="media-player youtube"><div style="margin: 1em 2em; background: url(/images/movie.png); width: 180px; height: 100px; text-align: center;"><a href="http://www.allegro.cc//www.youtube.com/watch?v=XsvBIWN92Co" target="_blank"><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/object/5/f/5f01df7ddc30414e4142e93dc651e52c.jpg" border="0" alt="video" title="Click to play video" /></a></div></div>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Mon, 21 Mar 2016 18:49:26 +0000</pubDate>
	</item>
</rss>
