ID:277533
 
I already know how to draw graphics and create a map in Python using pygame, but I cannot figure out how to draw a nice little map made of text on the screen for the life of me!

The closest thing I could get was:
dungeon =  ["###########################################################",
"#...........#.............................................#",
"#...........#........#....................................#",
"#.....................#...................................#",
"#....####..............#..................................#",
"#.......#.......................#####################.....#",
"#.......#...........................................#.....#",
"#.......#...........##..............................#.....#",
"#####........#......##..........##################..#.....#",
"#...#...........................#................#..#.....#",
"#...#............#..............#................#..#.....#",
"#...............................#..###############..#.....#",
"#...............................#...................#.....#",
"#...............................#...................#.....#",
"#.....YOUJUSTLOSTTHEGAME........#####################.....#",
"#.........................................................#",
"#.........................................................#",
"###########################################################"]
for i in range(0,len(dungeon)):print dungeon[i]



Which obviously wouldn't work since the terminal would have to be flushed every time there was an update.

Is it possible to create something similar to BYOND's text-mode in Python? I just need to know how to draw the text on screen and be able to update it. Hopefully a tutorial or something.

You'd figure this would be easy to do, but I can't figure it out for the life of me. Especially with so many tutorials going around for creating graphics with Pygame!
Wouldn't you just have to redraw the "dungeon" on every frame? I've not messed with pyGames as much as I would like to, but what I do know is that graphics have to be redrawn every frame.
http://www.pygame.org/pcr/bitmap_font/index.php
http://flangy.com/dev/python/curses/

I don't know if bitmap_font supports background color or anything, but if you're using Pygame, that's probably your best bet. If you don't need to use pygame, you could use the Curses engine, or you could try to implement Curses into Pygame.
In response to CaptFalcon33035 (#2)
Danial.Beta wrote:
Wouldn't you just have to redraw the "dungeon" on every frame? I've not messed with pyGames as much as I would like to, but what I do know is that graphics have to be redrawn every frame.




No. :(

I'm printing to the terminal and not drawing them on screen. Thanks for the help, though!




CaptFalcon33035 wrote:
http://www.pygame.org/pcr/bitmap_font/index.php
http://flangy.com/dev/python/curses/

I don't know if bitmap_font supports background color or anything, but if you're using Pygame, that's probably your best bet. If you don't need to use pygame, you could use the Curses engine, or you could try to implement Curses into Pygame.




Thanks! I'll read up on those in a bit.

[edit]Oh, drat. Is it possible to get curses for Linux?
In response to Ol' Yeller (#3)
There might be an alternative, but an actual Curses linux build? Nope.
In response to CaptFalcon33035 (#4)
NCurses.
In response to Ol' Yeller (#3)
Ol' Yeller wrote:
[edit]Oh, drat. Is it possible to get curses for Linux?
You make Flame happy :)