def mainloop(): global ROWS, COLUMNS, lastROWS, lastCOLS while GAME_RUNNING: startTime=time.time() update() ROWS, COLUMNS = os.popen('stty size', 'r').read().split() ROWS = int(ROWS) COLUMNS = int(COLUMNS) if ROWS!=lastROWS or COLUMNS!=lastCOLS: #refresh screen for y in range(1, ROWS+1): for x in range(1, COLUMNS+1): method.printxy(x,y," ") lastROWS=ROWS lastCOLS=COLUMNS if ROWS<24 or COLUMNS<58: method.printxy(1,1,method.color("&RXYOUR SCREEN IS TOO SMALL!&XX")) else: method.refreshBuffer() draw() method.printBuffer(ROWS,COLUMNS) endTime=time.time() timeElapsed=endTime-startTime sleepTime=1.0/float(FRAMES_PER_SECOND)-float(timeElapsed) try: time.sleep(sleepTime) except Exception: pass
def drawnewmenu(): for i in range(0,len(NEW_LINES)): method.bufferxy(11, i+9,NEW_LINES[i][:-1]) def drawreturnmenu(seconds, gold): for i in range(0,len(RETURN_LINES)): method.bufferxy(10, i+9,RETURN_LINES[i][:-1]) m, s = divmod(seconds, 60) h, m = divmod(m, 60) method.bufferxy(14,11,"&MX" + str(h) + " hrs " + str(m) + " mins and " + str(s) + " secs&XX.&GX") method.bufferxy(34,13,"&YX" + method.dispBigNum(gold) + "&GX") #load GUI file. f=open("../resources/gui/gui.txt") GUI_LINES = [] for line in f: GUI_LINES.append(method.color(line)) f.close() #load title file. f=open("../resources/gui/title.txt") TITLE_LINES = [] for line in f: TITLE_LINES.append(method.color(line)) f.close() #load quitmenu file. f=open("../resources/gui/quitmenu.txt") QUIT_LINES = [] for line in f: QUIT_LINES.append(line) f.close()