Old 04-12-2009, 11:09 PM   #1 (permalink)
Zuner
 
badmoodguy88's Avatar
 
Join Date: Jun 2008
Posts: 72
badmoodguy88 is on a distinguished road
Default [SOLVED] Text art problems

I thought it might be cool to make some game that uses ASCII Art like roguelikes.
But I ran into a problem. First off roguelikes use a number of Unicode character that I understand are just not part of the 95 printable ASCII characters. So I had some trouble displaying this
Code:
         ▄             ▄█▄ █▄       ▄
     ▄█▀█▓ ▄▓▀▀█▀ ▀▀▀█▓▀▀ ▀▀    ▄█▀█▓▀▀▀▀▀▓▄▀██▀▀
    ██  ██ ▀██▄▄ ▄█  ▀ ░▒ ░▒   ██  ██ ▄█▄ █▀ ██
    █▓▄▀██  ▄ ▀█▌▓█    ▒▓ ▒▓   █▓▄▀██ ▓█ ▀▄  █▓
    █▒  █▓ ██▄▓▀ ▀█▄▄█▄▓█ ▓█   █▒  █▓ ▒█  ▓█▄ ▒
        ▀▒           ▀  ▀ █▀       ▀▒  ▀  █▀  ░
I can live with that, though it does put a damper on things.

The real problem is that the strings are not mono spaced (all the characters take up the same amount of space)
even when you use a font that is supposed to be mono spaced like Courier New.

So This
Code:
.########.##.....##....###....##.....##.########..##.......########
.##........##...##....##.##...###...###.##.....##.##.......##......
.##.........##.##....##...##..####.####.##.....##.##.......##......
.######......###....##.....##.##.###.##.########..##.......######..
.##.........##.##...#########.##.....##.##........##.......##......
.##........##...##..##.....##.##.....##.##........##.......##......
.########.##.....##.##.....##.##.....##.##........########.########
Ends up looking like this-
.########.##.....##....###....##.....##.########.. ##.......########
.##........##...##....##.##...###...###.##.....##. ##.......##......
.##.........##.##....##...##..####.####.##.....##. ##.......##......
.######......###....##.....##.##.###.##.########.. ##.......######..
.##.........##.##...#########.##.....##.##........ ##.......##......
.##........##...##..##.....##.##.....##.##........ ##.......##......
.########.##.....##.##.....##.##.....##.##........ ########.########

Here is a work in progress that just displays some ASCII aret
textgame.rar

I suppose I could try to display a grid of char characters (I estimate it would take about 546 assuming 12 by 12 squares.
Because it says char displays Unicode character I guess I could use these
Box drawing characters - Wikipedia, the free encyclopedia
Code:
  	  	0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	A 	B 	C 	D 	E 	F
2500 	  	─ 	━ 	│ 	┃ 	┄ 	┅ 	┆ 	┇ 	┈ 	┉ 	┊ 	┋ 	┌ 	┍ 	┎ 	┏
2510 	  	┐ 	┑ 	┒ 	┓ 	└ 	┕ 	┖ 	┗ 	┘ 	┙ 	┚ 	┛ 	├ 	┝ 	┞ 	┟
2520 	  	┠ 	┡ 	┢ 	┣ 	┤ 	┥ 	┦ 	┧ 	┨ 	┩ 	┪ 	┫ 	┬ 	┭ 	┮ 	┯
2530 	  	┰ 	┱ 	┲ 	┳ 	┴ 	┵ 	┶ 	┷ 	┸ 	┹ 	┺ 	┻ 	┼ 	┽ 	┾ 	┿
2540 	  	╀ 	╁ 	╂ 	╃ 	╄ 	╅ 	╆ 	╇ 	╈ 	╉ 	╊ 	╋ 	╌ 	╍ 	╎ 	╏
2550 	  	═ 	║ 	╒ 	╓ 	╔ 	╕ 	╖ 	╗ 	╘ 	╙ 	╚ 	╛ 	╜ 	╝ 	╞ 	╟
2560 	  	╠ 	╡ 	╢ 	╣ 	╤ 	╥ 	╦ 	╧ 	╨ 	╩ 	╪ 	╫ 	╬ 	╭ 	╮ 	╯
2570 	  	╰ 	╱ 	╲ 	╳ 	╴ 	╵ 	╶ 	╷ 	╸ 	╹ 	╺ 	╻ 	╼ 	╽ 	╾ 	╿
Code:
  	  	0 	1 	2 	3 	4 	5 	6 	7 	8 	9 	A 	B 	C 	D 	E 	F
2580 	  	▀ 	▁ 	▃ 	▃ 	▄ 	▅ 	▆ 	▇ 	█ 	▉ 	▊ 	▋ 	▌ 	▍ 	▎ 	▏
2590 	  	▐ 	░ 	▒ 	▓ 	▔ 	▕ 	▖ 	▗ 	▘ 	▙ 	▚ 	▛ 	▜ 	▝ 	▞ 	▟
At that point I think it might be about as easy to just use tile sets. If I did not end up making all the tiles myself.
-----------------------------------------------------------
(Post made several hours latter)


I just spent a few hour figuring it out.

The extended ASCII codes (character code 128-255)
There are several different variations of the 8-bit ASCII table. The table below is according to ISO 8859-1, also called ISO Latin-1. Codes 129-159 contain the Microsoft® Windows Latin-1 extended characters.

ASCII Code - The extended ASCII table

This is not the extended ASCII you find on most table when you search "extended ASCII". Those seem to be an extended ASCII used in Dos.

What this means is the even when using unicode char it is still impossible to display Box drawing characters like these▐ ░ ▒ ▓.

This displays a number of one character strings in a grid so that they are mono spaced.
I tried to display some extended characters but that part is grayed off because it does not work in it's current state.

here is a second WIP It just displays some ascii 32-126
textgame (WIP)2.rar

Last edited by badmoodguy88; 04-13-2009 at 05:41 PM.



badmoodguy88 is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old 04-13-2009, 10:51 AM   #2 (permalink)
Experienced Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 806
Tiptup300 has disabled reputation
Default

Did you turn off AutoKerning?



Tiptup300 is offline   Reply With Quote
Old 04-13-2009, 04:58 PM   #3 (permalink)
Zuner
 
badmoodguy88's Avatar
 
Join Date: Jun 2008
Posts: 72
badmoodguy88 is on a distinguished road
Default

yeah it is off by default

but just for the heck of it i turned AutoKerning on
and for some reason it makes it work

BEFORE:
*image removed for passing filter*

I guess for mono spaced font the information about spacing everything evenly is Kerning data. Go figure.
It is good to know though.

Last edited by Bolt; 04-23-2009 at 06:22 PM. Reason: Deleted image



badmoodguy88 is offline   Reply With Quote
Old 04-18-2009, 11:40 PM   #4 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default

You can add the necessary code points as CharacterRegions in your spritefont file, along with any others that you need. XNA doesn't use ASCII or "extended ASCII" anywhere - everything is UTF-16.
__________________

signature by vettexl




itsnotabigtruck is offline   Reply With Quote
Old 04-21-2009, 12:18 AM   #5 (permalink)
Zuner
 
badmoodguy88's Avatar
 
Join Date: Jun 2008
Posts: 72
badmoodguy88 is on a distinguished road
Default

Thank you itsnotabigtruck!

I had tried making the chracter region 32-9631 but that was just way to many characters.

Anyway, I finally got what I was supposed to do.

Code:
    <CharacterRegions>
      <CharacterRegion>
        <Start>&# 32;</Start>
        <End>&# 32;</End>
      </CharacterRegion>
      <CharacterRegion>
        <Start>&# 9472</Start>
        <End>&# 9631</End>
      </CharacterRegion>
    </CharacterRegions>
  </Asset>
</XnaContent>
I I don't put a space between "&#" and a number it just prints that character in this message.

Last edited by badmoodguy88; 04-21-2009 at 12:22 AM.



badmoodguy88 is offline   Reply With Quote
Old 04-23-2009, 05:01 PM   #6 (permalink)
you lost the game.
zB Programmer
Moderator
Elite Zuner
 
itsnotabigtruck's Avatar
 
Join Date: May 2008
Posts: 2,434
itsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud ofitsnotabigtruck has much to be proud of
Default

Awesome.

Yeah, this forum software seems to handle XML character entities (like those in your code) quite oddly. :/
__________________

signature by vettexl




itsnotabigtruck is offline   Reply With Quote
Reply

Bookmarks

Thread Tools