bug fix: program should no longer crash when list is longer than terminal window
This commit is contained in:
36
test.py
36
test.py
@@ -20,24 +20,30 @@ king = Kinggotchi()
|
||||
for n in range(0, 10):
|
||||
king.add_village(Mayorgotchi(make_list(startnr)))
|
||||
|
||||
screen = curses.initscr()
|
||||
stdscr = curses.initscr()
|
||||
curses.noecho()
|
||||
curses.curs_set(0)
|
||||
screen.keypad(1)
|
||||
screen.nodelay(1)
|
||||
stdscr.keypad(1)
|
||||
stdscr.nodelay(1)
|
||||
|
||||
height,width = stdscr.getmaxyx()
|
||||
win = curses.newpad(16383, width)
|
||||
|
||||
while True:
|
||||
screen.move(0,0)
|
||||
screen.addstr('Simulation running. Press [q] to exit.\n')
|
||||
screen.addstr('----------------------After '+str(ticks)+' ticks------------------------------\n')
|
||||
screen.addstr(king.show_kingdom())
|
||||
king.step()
|
||||
ticks += 1
|
||||
win.move(0,0)
|
||||
win.addstr(0,0,'Simulation running. Press [q] to exit.\n')
|
||||
win.addstr(1,0,'----------------------After '+str(ticks)+' ticks------------------------------\n')
|
||||
win.addstr(3,0,king.show_kingdom())
|
||||
king.step()
|
||||
ticks += 1
|
||||
win.clrtoeol()
|
||||
win.clrtobot()
|
||||
win.refresh(0, 0, 0, 0, height-1, width-1)
|
||||
|
||||
key = stdscr.getch()
|
||||
if key == ord('q'):
|
||||
break
|
||||
elif key < 0:
|
||||
time.sleep(ticklenght)
|
||||
|
||||
screen.clrtobot()
|
||||
key = screen.getch()
|
||||
if key == ord('q'):
|
||||
break
|
||||
elif key < 0:
|
||||
time.sleep(ticklenght)
|
||||
curses.endwin()
|
||||
|
||||
Reference in New Issue
Block a user