from math import * from random import * from random import randint as RAND from kandinsky import * from kandinsky import fill_rect as F from ion import keydown as KP from kandinsky import draw_string as STR from ion import * from time import * prologue=""" Egor woke up to find himself in chaos... *[UP],[BACKSPACE] = float (Jump) *[Toolbox] = Menu, Pause *[Arrows] = MOVE """ SW=322 SH=222 red="red" green="green" blue="blue" yellow="yellow" brown="brown" cyan="cyan" pink="pink" orange="orange" purple="purple" black="black" white="white" bg=(75,0,0) F(0,0,322,222,bg) x,y=0,160 while y>-80 and not KP(KEY_OK): sleep(0.01) y-=RAND(0,1) STR(str(prologue),x,y,white,bg) if y<-380: y=190 sleep(1) while not KP(KEY_OK): STR(" PRESS OK ",0,140,red,black) MAPX=0 MAPY=0 GAME_OVER=False float_energy=20 score=0 life=3 energy=30 x=100 y=221-22 w=12 h=22 c=(RAND(0,255),RAND(0,255),RAND(0,255)) direc=["left","right","up","down"] DIR=direc[1] bg = (51,18,23) level_1=[ #area=0 [[0, 64, 148, 170, black], [105, 127, 114, 136, black], [162, 181, 28, 40, black], [30, 43, 28, 28, black], [51, 25, 54, 64, black], [37, 184, 42, 40, (189, 25, 51)], [13, 100, 24, 28, (45, 138, 186)]], #area=1 [[51, 212, 232, 10, black], [129, 210, 70, 12, red]], #area=2 [[40, 176, 50, 46, black], [168, 134, 154, 88, black], [202, 86, 120, 88, black], [246, 44, 76, 88, black], [90, 206, 76, 16, red]], #area=3 [[58, 182, 52, 40, black], [172, 144, 24, 78, black], [253, 208, 32, 14, black], [196, 208, 60, 14, red], [109, 208, 64, 14, red]], #area=4 [[61, 212, 50, 10, black], [91, 170, 66, 52, black], [121, 118, 66, 104, black], [268, 178, 54, 16, black], [186, 206, 136, 16, red]], #area=5 [[97, 122, 132, 100, black], [106, 132, 112, 90, red], [265, 124, 32, 42, red], [64, 212, 32, 8, red], [79, 182, 24, 8, red], [142, 122, 42, 12, red]], #area=6 [[82, 86, 18, 136, black],[190, 86, 18, 136, black],[262, 110, 60, 16, black],[98, 182, 96, 40, red],[0, 128, 40, 8, black],[51, 170, 40, 8, black]], #area=7 [[0, 175, 50, 10, black], [78, 143, 78, 10, black], [201, 114, 34, 108, black], [201, 0, 30, 62, red], [0, 214, 202, 8, red], [105, 142, 20, 6, red]], #area=8 [[52, 212, 50, 10, black], [97, 161, 50, 10, black], [196, 203, 18, 10, black], [158, 0, 164, 50, black], [260, 132, 62, 90, black], [104, 216, 156, 6, red]], #area=9 [[0, 162, 50, 100, black], [105, 172, 50, 50, black], [118, 27, 204, 98, black], [54, 210, 194, 12, red], [114, 0, 6, 126, red]], #area=10 [[40, 212, 322, 10, red], [0, 0, 322, 94, black], [90, 156, 36, 58, black], [192, 156, 10, 58, black], [264, 204, 58, 8, black], [0, 202, 34, 20, black]], #area=11 [[0, 212, 50, 10, black], [48, 154, 232, 68, black], [66, 91, 188, 68, black], [81, 91, 162, 128, red], [124, 57, 18, 14, black], [256, 0, 18, 40, black]], #area=12 [[86, 212, 236, 10, red], [68, 140, 18, 82, black], [143, 188, 14, 6, black], [230, 128, 14, 6, black], [246, 62, 76, 6, black]], #area=13 [[0, 68, 48, 154, black], [99, 126, 6, 96, black], [180, 126, 6, 96, black], [244, 0, 78, 168, black], [241, 0, 8, 168, red ], [48, 208, 136, 14, red ]], #area=14 [[80, 100, 162, 122, black], [87, 93, 26, 8, red ], [153, 93, 26, 8, red ], [216, 93, 26, 8, red ], [51, 154, 184, 8, black], [82, 140, 6, 82, red ]], #area=15 [[0, 160, 50, 10, black],[67, 96, 166, 126, black], [97, 96, 40, 40, red ], [172, 96, 40, 40, red ], [280, 78, 40, 40, red ], [63, 106, 4, 116, red ]], #area=16 [[0, 148, 50, 10, black], [99, 100, 10, 122, black], [96, 94, 34, 24, black], [102, 100, 22, 12, (15, 56, 15)], [0, 0, 322, 32, red ], [112, 206, 158, 16, red ]], #area=17 [[90, 194, 232, 28, black],[114, 15, 20, 24, black],[120, 21, 2, 4, red ],[126, 21, 2, 4, red ],[249, 210, 2, 4, red ],[255, 210, 2, 4, red ]], #area=18 [[82, 42, 18, 180, black], [242, 122, 80, 100, black], [47, 119, 88, 8, black], [156, 3, 166, 44, red ], [102, 178, 140, 44, red ]] ] health=energy tools=[] def drawmenu(): global life,energy,tools F(0,0,SW,SH,BLACK) panel=[ [50, 50, 254, 166, black], [6, 9, 236, 148, (243, 223, 225)] ] for i in panel: F(*i) while not KP(KEY_LEFT): STR("Life: "+str(life),20,20) STR("Energy: "+str(energy),20,50) STR("Tools: "+str(tools),20,80) STR("PRESS LEFT TO RESUME JOURNEY",6,200,orange,black) F(0,0,322,222,bg) #starting point area=0 for i in level_1[area]: F(*i) def refresh_level(): F(0,0,SW,SH,bg) for i in level_1[area]: F(*i) fireball_dir="still" fireball_x=0 fireball_y=0 fireball_w=16 fireball_h=16 fireball_c=red fireball_dir=choice(["up","down"]) fireball_x=150 fireball_y=20 fireball_w=16 fireball_h=16 fireball_c=red def move_fireball(): global fireball_dir,fireball_x,fireball_y if fireball_dir=="up": F(fireball_x,fireball_y+fireball_h+1,fireball_w,1,bg) fireball_y-=1 if fireball_dir=="down": F(fireball_x,fireball_y-1,fireball_w,1,bg) fireball_y+=1 if fireball_y<0: fireball_y=0 fireball_dir="down" if fireball_y+fireball_h>222: fireball_y=222-fireball_h fireball_dir="up" fireball_dir=choice(["up","down"]) while not GAME_OVER: F(x,y,w,h,c) if area>1: move_fireball() F(fireball_x,fireball_y,fireball_w,fireball_h,fireball_c) F(fireball_x+2,fireball_y+2,fireball_w-4,fireball_h-4,(RAND(0,255),0,0)) F(x+3,y+3,4,3,black) F(x+9,y+3,4,3,black) if KP(KEY_LEFT): x-=1 F(x+w+1,y,1,h,bg) if KP(KEY_RIGHT): x+=1 F(x-1,y,1,h,bg) if KP(KEY_UP) and float_energy>0 or keydown(KEY_BACKSPACE) and float_energy>0: y-=2 F(x+w+1,y,1,h,bg) float_energy-=0.3 F(x,y+h+1,w,1,bg) for i in level_1[area]: if x+w>i[0] and x<i[0]+i[2] and y+h>i[1] and y<i[1]+i[3] and i[-1]==red: sleep(0.2) F(x,y,w,h,bg) life-=1 x=40 y=30 float_energy=40 for i in level_1[area]: if x+w>i[0] and x<i[0]+i[2] and y+h>i[1] and y+h<i[1]+2: float_energy=0 y-=1 float_energy=40 for i in level_1[area]: if x+w>i[0] and x<i[0]+i[2] and y+h>i[1] and y+h<i[1]+i[3]: for i in level_1[area]: F(*i) if get_pixel(x,y+h) != black and get_pixel(x+w,y+h) != black or get_pixel(x,y+h) != white and get_pixel(x+w,y+h) != white: sleep(0.001) y+=1 F(x-1,y-1,w+2,1,bg) if get_pixel(x,y+h) == black and get_pixel(x+w,y+h) == black: float_energy=20 if y+h>222: float_energy=20 y=222-h if x>321: sleep(0.2) score+=RAND(50,100) fill_rect(0,0,322,222,black) sleep(0.1) fill_rect(0,0,322,222,bg) area+=1 x=0 if area>1: fireball_x=RAND(50,300) fireball_y=RAND(0,170) fireball_w=fireball_h=RAND(12,20) for i in level_1[area]: F(*i) if life<1: sleep(0.4) for i in range(0,322,3): for j in range(0,222,3): sleep(0.00051) F(i,j,10,10,(RAND(0,255),0,0)) sleep(1) F(0,0,322,222,black) sleep(1) draw_string("GAME OVER",100,80,(255,0,0),black) sleep(1) draw_string("SCORE: "+str(score),100,140,white,black) GAME_OVER=True if x<0: x=0 if y<0: y=0 if KP(KEY_TOOLBOX): drawmenu() refresh_level() for i in level_1[area]: if fireball_x+fireball_w>i[0] and fireball_x<i[0]+i[2] and fireball_y+fireball_h>i[1] and fireball_y<i[1]+i[3]: fireball_dir=choice(["up","down"]) if x+w>fireball_x and x<fireball_x+fireball_w and y+h>fireball_y and y<fireball_y+fireball_h: sleep(0.2) F(x,y,w,h,bg) life-=1 x=40 y=30 float_energy=40 F(fireball_x,fireball_y,fireball_w,fireball_h,fireball_c) F(fireball_x+2,fireball_y+2,fireball_w-4,fireball_h-4,(RAND(0,255),0,0)) if KP(KEY_DOWN): sleep(0.02) y+=2 F(x,y-2,w,2,bg)