Potentially a fun game. Save the princess.
will improve eventually…maybe.
from math import * from random import * from kandinsky import * from ion import * from time import * from random import randint as R from kandinsky import fill_rect as F from kandinsky import draw_string as STR game=True bg=(R(0,255),R(0,255),R(0,255)) bg_2=(R(0,255),R(0,255),R(0,255)) MAP_X=0 MAP_Y=0 p_has_weapon=False p_energy=30 p_money=5 p_x=MAP_X-170 p_y=MAP_Y+652 p_c="brown" p_char_num=34 #player needs weapon w_x=MAP_X+R(-200,500) w_y=MAP_Y-R(200,500) w_c="gray" w_char="=*" #player needs to eat f_x=MAP_X+R(400,600) f_y=MAP_Y-R(200,500) f_c="brown" f_char="0" #queen q_x=MAP_X+300 q_y=MAP_Y-50 q_c="cyan" q_char="Q" #left border b_left_x=MAP_X-100 b_left_y=MAP_Y-100 #right border b_right_x=MAP_X+422 b_right_y=MAP_Y-100 #top border b_left_x=MAP_X-100 b_left_y=MAP_Y-100 #bottom border b_left_x=MAP_X-100 b_left_y=MAP_Y+322 e_x=MAP_X+R(250,400) e_y=MAP_Y+R(0,50) e_c="black" e_eyes_c="cyan" e_dir=choice(["left","right","up","down"]) e_dir_timer=0 #///////[You decide]///// e_is_home=False e_is_heading_home=False e_goes_out=False e_energy=30 e_chasing=False e_is_running=False e_is_resting=False e_is_happy=False e_is_angry=False e_is_sad=False e_is_worried=False e_is_sad=False e_is_hungry=False e_is_hunting_for_food=False e_likes_you=False e_is_home_with_girlfriend=False e_respects_you=False e_respects_you_amount=0 e_name="garmetro" e_char_num=42 greek_s={ "delta":"\u0394", "omega":"\u03A9", "pi":"\u03C0", "theta":"\u03F4", "lamda":"\u03BB", "cap_lamda":"\u039B" } while game: e_dir_timer+=0.001 #///player sprite///// if p_char_num==34: STR(chr(p_char_num),p_x,p_y,"black","orange") #////player outline F(p_x,p_y,1,16,"black") F(p_x+9,p_y,1,16,"black") F(p_x,p_y,10,1,"black") F(p_x,p_y+16,10,2,"black") #////player hat////// F(p_x,p_y,10,2,"blue") if p_char_num==35: STR(chr(p_char_num),p_x,p_y,"red","black") if p_char_num==36: STR(chr(p_char_num),p_x,p_y,"black",(0,120,0)) if p_char_num<=31: STR(chr(p_char_num),p_x,p_y,"black","brown") if p_char_num>40: STR(chr(p_char_num),p_x,p_y,"black","red") #////enemy sprite//////// STR(chr(e_char_num),e_x,e_y,e_eyes_c,e_c) #////Border//////// #left border line F(MAP_X-100,MAP_Y-100,3,422,"blue") #erase left line trail. F(MAP_X-103,MAP_Y-100,3,422,bg) F(MAP_X-96,MAP_Y-100,2,422,"white") #right border line F(MAP_X+422,MAP_Y-100,3,422,"blue") #erase right line trail. F(MAP_X+420,MAP_Y-100,2,422,"white") F(MAP_X+425,MAP_Y-100,2,422,bg) #top border line F(MAP_X-100,MAP_Y-100,522,3,"blue") #erase top line trail. F(MAP_X-100,MAP_Y-102,522,2,bg) F(MAP_X-100,MAP_Y-97,522,2,"white") #bottom border line F(MAP_X-100,MAP_Y+322,522,3,"blue") #erase bottom line trail. F(MAP_X-100,MAP_Y+320,522,2,"white") F(MAP_X-100,MAP_Y+325,522,2,bg) #player morphs if keydown(KEY_BACKSPACE): sleep(0.2) p_char_num+=1 if keydown(KEY_TOOLBOX): sleep(0.2) p_char_num-=1 if keydown(KEY_LEFT): p_x-=2 F(p_x,p_y+15,9,2,"black") F(p_x+10,p_y,2,18,"white") if keydown(KEY_RIGHT): p_x+=2 F(p_x,p_y+15,9,2,"black") F(p_x-2,p_y,2,18,"white") if keydown(KEY_UP): p_y-=2 F(p_x,p_y+15,9,2,"black") F(p_x,p_y+17,9,3,"white") if keydown(KEY_DOWN): p_y+=2 F(p_x,p_y+15,9,2,"black") F(p_x,p_y-2,9,2,"white") if p_x>252: p_x=252 MAP_X-=2 if p_x<70: p_x=70 MAP_X+=2 if p_y>152: p_y=152 MAP_Y-=2 if p_y<70: p_y=70 MAP_Y+=2 #////restrict enemy////// if e_x<MAP_X-100: e_x=MAP_X-100 if e_x>MAP_X+412: e_x=MAP_X+412 if e_y<MAP_Y-100: e_y=MAP_Y-100 if e_y+16>MAP_Y+322: e_y=MAP_Y+322-16 if e_dir=="left": e_x-=R(-1,4) if e_dir=="right": e_x+=R(-1,4) if e_dir=="up": e_y-=R(-1,4) if e_dir=="down": e_y+=R(-1,4) if e_dir_timer>R(1,2): e_dir_timer=0 e_dir=choice(["left","right","up","down"]) e_chasing=False if e_dir_timer==0: e_chasing=choice([True,False]) #////enemy eyes red//// if e_chasing: F(e_x+2,e_y+7,8,3,"red") if e_chasing and p_char_num==34: if p_x<e_x: e_dir="left" if p_x>e_x: e_dir="right" if p_y<e_y: e_dir="up" if p_y>e_y: e_dir="down" if p_char_num<=31: e_is_worried if e_is_worried: STR("It is worried!",220,2) e_chasing=choice([False]) e_is_running=choice([True]) if e_is_running: STR(chr(e_char_num)+" is running!",200,1) if p_x<e_x: e_dir="right" if p_x>e_x: e_dir="left" if p_y<e_y: e_dir="down" if p_y>e_y: e_dir="up" if e_energy<10: e_chasing=False e_is_heading_home=True if e_x>=MAP_X+400 and e_y<=MAP_Y-100: e_is_home=True e_is_heading_home=False e_is_resting=True e_chasing=False e_energy+=0.03 if e_is_heading_home: if e_x<MAP_X+400: e_dir="right" if e_y>MAP_Y-100: e_dir="up" #///player energy loss//// if e_x+9>=p_x and e_x<=p_x+9 and e_y+16>=p_y and e_y<=p_y+16: STR(str(round(p_energy)),250,2) F(p_x+R(-2,12),p_y+R(16,18),2,2,"red") p_energy-=0.3 if p_energy<0: game=False F(e_x-3,e_y,3,16,"white") F(e_x+11,e_y,3,16,"white") F(e_x,e_y-3,10,3,"white") F(e_x,e_y+16,10,3,"white") #/// prevent enemy from #/// getting lost if e_x<MAP_X-1000: e_x=MAP_X-1000 e_dir="right" if e_x>MAP_X+1322: e_x=MAP_X+1322-10 e_dir="left" if e_y<MAP_Y-1000: e_y=MAP_Y-1000 e_dir="down" if e_y+16>MAP_Y+1222: e_y=MAP_Y+1222-16 e_dir="up" if e_x<MAP_X-400 and e_energy<10: e_x=MAP_X-400 e_dir="right" if e_x>MAP_X+722 and e_energy<10: e_x=MAP_X+722-10 e_dir="left" if e_y<MAP_Y-400 and e_energy<10: e_y=MAP_Y-400 e_dir="down" if e_y+16>MAP_Y+622 and e_energy<10: e_y=MAP_Y+622-16 e_dir="up" #// restrict player and prevent #// from going off the grid. if p_x<MAP_X-1000: p_x=MAP_X-1000 F(p_x-2,0,2,222,"cyan") STR("X:-1000",100,140,"blue") STR("Are you lost?",100,100) if p_x>MAP_X+1322: p_x=MAP_X+1322-10 F(p_x+10,0,2,222,"cyan") STR("X:1322",100,140,"blue") STR("Are you lost?",100,100) if p_y<MAP_Y-1000: p_y=MAP_Y-1000 F(0,p_y-2,322,2,"cyan") STR("Y:-1000",100,140,"blue") STR("Are you lost?",100,100) if p_y+16>MAP_Y+1222: p_y=MAP_Y+1222-16 F(0,p_y+16,322,2,"cyan") STR("Y:1222",100,140,"blue") STR("Are you lost?",100,100) if p_char_num==35: e_chasing=False if keydown(KEY_OK): cl_1=(R(20,150),R(20,150),R(20,150)) cl_2=(R(50,200),R(50,200),R(50,200)) while not keydown(KEY_VAR): STR("PAUSED",110,40,cl_1) STR("Press [VAR] to resume",50,65,cl_2) STR(" ",110,40) STR(" ",50,65) STR(chr(p_char_num)+":"+"char("+str(p_char_num)+")",2,1) STR("|"+chr(e_char_num)+"|:"+str(round(e_energy)),250,204) if e_energy>10: e_chasing=True if e_is_home==False: e_energy-=0.02 if not keydown(KEY_LEFT) and not keydown(KEY_RIGHT) and not keydown(KEY_UP) and not keydown(KEY_DOWN): p_energy+=0.006 STR(str(round(p_energy)),2,204,"blue") if p_energy<10: F(p_x,p_y,9,16,"red") F(p_x+R(-2,12),p_y+R(16,18),2,2,"red") if e_energy<choice([8,10,14]) and e_is_home==False: e_is_heading_home=choice([True,False]) F(e_x+choice([0,5,9]),e_y+R(15,16),2,2,"green") STR(str(p_x-MAP_X)+","+str(p_y-MAP_Y),150,204) #/// THE QUEEN! /// STR(q_char,MAP_X+q_x,MAP_Y-q_y,"black",q_c) F(MAP_X+q_x,MAP_Y-q_y,1,16,"black") F(MAP_X+q_x+9,MAP_Y-q_y,1,16,"black") F(MAP_X+q_x,MAP_Y-q_y,10,1,"black") F(MAP_X+q_x,MAP_Y-q_y+15,10,1,"black") #erase her trail F(MAP_X+q_x-3,MAP_Y-q_y,2,16,"white") F(MAP_X+q_x+11,MAP_Y-q_y,2,16,"white") F(MAP_X+q_x,MAP_Y-q_y-2,10,2,"white") F(MAP_X+q_x,MAP_Y-q_y+16,10,2,"white") if p_x>=MAP_X+q_x-50 or p_y<MAP_Y+q_y+50: STR("HELP!!",MAP_X+q_x-20,MAP_Y-q_y-20) #////prison F(MAP_X+q_x-50,MAP_Y-q_y-50,2,116,"black") F(MAP_X+q_x+60,MAP_Y-q_y-50,2,116,"black") F(MAP_X+q_x-50,MAP_Y-q_y-50,110,2,"black") F(MAP_X+q_x-50,MAP_Y-q_y+65,110,2,"black") F(MAP_X+q_x-52,MAP_Y-q_y-50,2,116,"white") F(MAP_X+q_x+61,MAP_Y-q_y-50,2,116,"white") F(MAP_X+q_x-50,MAP_Y-q_y-52,110,2,"white") F(MAP_X+q_x-50,MAP_Y-q_y+66,110,2,"white") F(MAP_X+q_x-48,MAP_Y-q_y-50,2,116,"white") F(MAP_X+q_x+61,MAP_Y-q_y-50,2,116,"white") F(0,0,322,222,(0,0,0)) STR("GAME OVER",100,100,(R(150,255),R(150,255),R(150,255)),(0,0,0))