from math import * from random import * from random import randint as R from kandinsky import * from kandinsky import fill_rect as F from ion import * from time import * game=True gravity=True jump=False p_on_platform=True jump_height=24 bg=(200,255,255) gx=0 gy=210 gw=10**4 gh=12 gc="pink" area=1 #player p_energy=35 p_score=0 px=35 py=gy-24 pw=16 ph=24 pc="blue" p_right=True p_left=False """ food_x=R(400,500) food_y=gy-12 food_w=10 food_h=12 food_c=choice(['green','brown','pink']) """ rectx=gx+R(300,500) recty=gy-R(140,200) rectw=R(70,120) recth=R(12,18) rectc=choice(['blue','red','green','yellow','brown','white','pink','orange','purple','gray']) rect_2_x=gx+R(320,400) rect_2_y=R(100,150) rect_2_w=R(40,80) rect_2_h=R(20,50) rect_2_c=choice(['blue','red','green','yellow','brown','white','pink','orange','purple','gray']) rect_3_x=gx+R(600,700) rect_3_y=R(140,180) rect_3_w=R(25,50) rect_3_h=R(40,100) rect_3_c=(R(0,255),R(0,255),R(0,255)) rope_x=rect_2_x #gx+rect_3_x+rect_3_w rope_y=rect_3_y+20 rope_w=200 rope_h=2 rope_c=(40,52,14) lavax=gx+R(600,800) lavay=gy lavaw=R(200,400) lavah=gh lavac="red" def PrintData(): global p_energy,p_score,area draw_string("Energy:",2,0) F(75,4,round(p_energy),10,"red") F(75+round(p_energy),4,1,10,bg) draw_string(chr(36)+str(p_score),160,0,(0,55,0)) draw_string("Area:"+str(area),250,0) F(0,0,322,222,bg) F(gx,gy-2,gw,2,(R(0,255),R(0,255),R(0,255))) while 1: #wall F(gx-200,0,10,222,"black") F(gx-195,0,5,222,"cyan") if px+pw>=lavax and px<=lavax+lavaw and py+ph>=lavay-3: energy-=0.025 F(px,py,pw,ph,"red") PrintData() if keydown(KEY_LEFT): gx+=1 p_left=True p_right=False if keydown(KEY_RIGHT): gx-=1 p_left=False p_right=True #player F(px,py,pw,ph,"blue") F(px+3,py+5,10,6,"cyan") if py+ph>=gy-ph: F(px,gy-2,pw,2,"black") F(px,py,2,ph,"black") F(px+pw-2,py,2,ph,"black") F(px,py,pw,2,"black") F(px,py+ph-2,pw,2,"black") #ground F(gx,gy,gw,gh,gc) #rect F(gx+rectx,gy-recty,rectw,recth,rectc) #rect Border F(gx+rectx,gy-recty,3,recth,"black") F(gx+rectx+rectw-3,gy-recty,3,recth,"black") F(gx+rectx,gy-recty,rectw,3,"black") F(gx+rectx,gy-recty+recth-3,rectw,3,"black") #rect erase trail F(gx+rectx+rectw,gy-recty,1,recth,bg) F(gx+rectx-1,gy-recty,1,recth,bg) F(gx+lavax,lavay,lavaw,lavah,lavac) #rect 2 F(gx+rect_2_x,gy-rect_2_y,rect_2_w,rect_2_h,rect_2_c) #rect 2 Border F(gx+rect_2_x,gy-rect_2_y,3,rect_2_h,"black") F(gx+rect_2_x+rect_2_w-3,gy-rect_2_y,3,rect_2_h,"black") F(gx+rect_2_x,gy-rect_2_y,rect_2_w,3,"black") F(gx+rect_2_x,gy-rect_2_y+rect_2_h-3,rect_2_w,3,"black") #rect 2, erase trail F(gx+rect_2_x+rect_2_w,gy-rect_2_y,1,rect_2_h,bg) F(gx+rect_2_x-1,gy-rect_2_y,1,rect_2_h,bg) #rect 3 F(gx+rect_3_x,gy-rect_3_y,rect_3_w,rect_3_h,rect_3_c) #rect 2 Border F(gx+rect_3_x,gy-rect_3_y,3,rect_3_h,"black") F(gx+rect_3_x+rect_3_w-3,gy-rect_3_y,3,rect_3_h,"black") F(gx+rect_3_x,gy-rect_3_y,rect_3_w,3,"black") F(gx+rect_3_x,gy-rect_3_y+rect_3_h-3,rect_3_w,3,"black") #rect 3, erase trail F(gx+rect_3_x+rect_3_w,gy-rect_3_y,1,rect_3_h,bg) F(gx+rect_3_x-1,gy-rect_3_y,1,rect_3_h,bg) F(rope_x,rope_y,rope_w,rope_h,rope_c) if keydown(KEY_BACKSPACE) and jump_height<=7 and p_on_platform: jump=True p_score+=R(1,3) if jump: p_on_platform=False gravity=False py-=3 F(px,py+ph,pw,3,bg) jump_height+=1 if jump_height>=24: jump_height=0 jump=False if jump==False: gravity=True if gravity: py+=choice([0,0,1,2]) F(px,py-2,pw,2,bg) if py+ph>gy: py=gy-ph p_on_platform=True if px+pw>=gx+rectx and px<=gx+rectx+rectw and py+ph>=gy-recty and py+ph<=gy-recty+1: p_on_platform=True py=gy-recty-ph-1 if px+pw>=gx+rect_2_x and px<=gx+rect_2_x+rect_2_w and py+ph>=gy-rect_2_y and py+ph<=gy-rect_2_y+1: p_on_platform=True py=gy-rect_2_y-ph-1 if px+pw>=gx+rect_3_x and px<=gx+rect_3_x+rect_3_w and py+ph>=gy-rect_3_y and py+ph<=gy-rect_3_y+1: p_on_platform=True py=gy-rect_3_y-ph-1