import curses # Import my own libraries from state import State gamestate = State() gamestate.load() from render import Render # -- Initialize -- stdscr = curses.initscr() curses.noecho() curses.cbreak() stdscr.keypad(1) stdscr.notimeout(1) # Clear and refresh the screen for a blank canvas stdscr.clear() stdscr.refresh() height, width = stdscr.getmaxyx() curses.start_color() curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK) # Neutral Land curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK) # Neutral Sea curses.init_pair(3 , curses.COLOR_RED, curses.COLOR_BLACK) # Hostile curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_BLACK) # Outside of the map #stdscr = Render.renderScreen(stdscr, gamestate, 40, 12) stdscr = Render.renderScreen(stdscr, gamestate, 75, 25) k = 0 map_focus_x = round(gamestate.metadata['width']/2) map_focus_y = round(gamestate.metadata['height']/2) while (k != ord('q')): if k == curses.KEY_DOWN: map_focus_y = map_focus_y + 1 elif k == curses.KEY_UP: map_focus_y = map_focus_y - 1 elif k == curses.KEY_RIGHT: map_focus_x = map_focus_x + 1 elif k == curses.KEY_LEFT: map_focus_x = map_focus_x - 1 map_focus_x = max(0, map_focus_x) map_focus_x = min(gamestate.metadata['width'], map_focus_x) map_focus_y = max(0, map_focus_y) map_focus_y = min(gamestate.metadata['height'], map_focus_y) stdscr = Render.renderScreen(stdscr, gamestate, map_focus_x, map_focus_y) k = stdscr.getch() stdscr.keypad(0) curses.echo() curses.nocbreak() curses.endwin()