def enter_roll_mode(): global scr global mode global form mode='roll' f.change_mode('window') f.wipe() f.frame('Roll your character') f.selector.wipe() f.text(20,50,'Choose your race:',fg='green',size=12) race_choice=f.selector(['human','orc','dwarf','elf','half-troll'],race_choice_agent) race_choice.activate(20,75) race_choice.focus(0) map=w.load_map() c=[rand(0,31),rand(0,31)] form['coord']=c #f.inform('Your coordinates are: '+str(c)) while (map[c[0]][c[1]]<40)|(map[c[0]][c[1]]>90): c=[rand(0,31),rand(0,31)] f.text(220,50,'Starting location:',fg='blue',size=12) f.text(240,80,'('+str(c[0])+','+str(c[1])+')',size=12) f.text(50,f.HEIGHT-50,"Press 's' to start...",fg='yellow',size=12) if map[c[0]][c[1]]<60: f.symbol(230//f.charsize,70//f.charsize+1,'+',color='green') else: f.symbol(230//f.charsize,70//f.charsize+1,'v',color='brown')
def enter_battle_mode(): f.change_mode('symbols') f.wipe() global mode global hero global M M=e.Karte.generate_map() mode='battle' hero.glob_coord=form['coord'] x,y=0,0 z=0 while M.get(x,y,z).mat!='air': z+=1 hero.coord=(x,y,z) for x in range(f.W): for y in range(f.H): f.symbol(x,y,M.get(x+camera[0],y+camera[0],hero.coord[2]-1).sym) f.symbol(20,20,'@')
def move_hero(d): global hero,M,T if d==KEY['left']: hero.coord=(hero.coord[0]-1,hero.coord[1],hero.coord[2]) elif d==KEY['right']: hero.coord=(hero.coord[0]+1,hero.coord[1],hero.coord[2]) elif d==KEY['up']: hero.coord=(hero.coord[0],hero.coord[1]-1,hero.coord[2]) elif d==KEY['down']: hero.coord=(hero.coord[0],hero.coord[1]+1,hero.coord[2]) elif d==KEY['upz']: hero.coord=(hero.coord[0],hero.coord[1],hero.coord[2]+1) elif d==KEY['downz']: hero.coord=(hero.coord[0],hero.coord[1],hero.coord[2]-1) f.inform('Hero coords are: '+str(hero.coord)) T.go(1000) #f.scr.place(x=0,y=0) for x in range(f.W): for y in range(f.H): f.symbol(x,y,M.get(x+camera[0]+hero.coord[0],y+camera[1]+hero.coord[1],hero.coord[2]-1).sym) f.symbol(f.W//2,f.H//2,'@')
def enter_worldgen_mode(): global mode mode='worldgen' f.change_mode('symbols') f.wipe() w.generate(512) w.export() map=w.load_map(charnum=min(f.W,f.H)) for y in range(len(map)): for x in range(len(map[y])): c=map[x][y] if c>90: f.symbol(x,y,'^',color='white') elif c<40: f.symbol(x,y,'~',color='blue') elif c>60: f.symbol(x,y,'v',color='brown') else: f.symbol(x,y,'+',color='green')
def main_menu_agent(option): global mode if option=='Quit': exit() elif option=='New game': enter_roll_mode() #alert('Roll your character!') elif option=='Continue game': f.fill(' ') for i in range(10,21): f.symbol(i,10,'#') f.symbol(i,20,'#') f.symbol(10,i,'#') f.symbol(20,i,'#') for i in range(11,20): for j in range(11,20): f.symbol(i,j,'+') f.symbol(15,15,'@') mode='battle' elif option=='Create new world': enter_worldgen_mode() elif option=='Credits': f.frame(title='Credits menu') f.text(100,200,'All hail Andrei Pago!') mode='credits'