Reputation: 21
I'm new to curses but I have some experience. I'm trying to make a top-down style game in python with ncurses, but I don't even know where to start. I'm wanting the character to be centered on the screen and move around the map, but the environment to not all be visible on the screen at once. Is this possible? I would like to know before I get started.
Upvotes: 0
Views: 225
Reputation: 35
For the background, if it's text-based, you could draw the map using 2-layer list or tuple that gets printed using loops and slices with window.addstr(x,y,string)
example, with stdscr
as the name of the window:
map_tiles = [['a','1','+'],['b','2','-'],['c','3','=']]
inx = 0
iny = 0
range = 1
def scroll(bx,by):
stdscr.clear()
for y, x_line in enumerate(map_tiles[by : by+range]):
for x, tile in enumerate(x_line[bx : bx+range]):
stdscr.addstr(y, x, f'{tile}')
then, by calling scroll(inx.iny)
the tiles within range of the slices map_tiles[by : by+range]
and x_line[bx : bx+range]
will get printed in the terminal.
You can then bind keys to add increments to inx
and iny
to change the visible tiles.
Upvotes: 1