Guide:_
Awesome and fun Game! Avoid the hot lava below. Avoid enemy contact. Shoot Enemy to progress to the next, random world. ******************** =====[ Keys ]=====
[Arrow] keys = Move around. [OK] key = Pause / Unpause [Toolbox] key ( The key below the [OK] key ) = Shoot Laser [Backspace] key ( The key below the [Back] key ) = Jump / Float ********************
Sincerely,
Wilson
# GAME BY: WILSON from math import * from random import * from kandinsky import * from ion import * from time import * from kandinsky import fill_rect as F from random import randint as R from ion import keydown as K #i use this for rgb H=255 CYAN=(0,H,H) RED=(H,0,0) DARKRED=(135,0,0) DARKGREEN=(0,135,0) WHITE=(H,)*3 BLACK=(0,)*3 GREEN=(0,H,0) BLUE=(0,0,H) #screen width and height SW=322 SH=222 SA=SW*SH #3 different platforms GX=0 GY=R(120,160) GW=R(40,100) GH=30 GC=(R(0,H),R(0,H),R(0,H)) GX2=R(40,150) GY2=R(50,170) GW2=R(50,140) GH2=R(10,30) GC2=(R(0,H),R(0,H),R(0,H)) GX3=R(200,290) GY3=R(40,190) GW3=R(20,140) GH3=300 GC3=(R(0,H),R(0,H),R(0,H)) nx=R(20,220) ny=R(42,80) area=1 world=1 game=True #back bg=(R(0,70),R(0,20),R(0,70)) #player psc=0 pe=9 plife=3 ph=15 px=8 py=20 pw=10 pc=BLUE edash=False edash_timer=0 eattacks=False eruns=False edefeated=False dooropen=False etimer=0 echase=False edir=0 #enemys energy ex=R(180,280) ey=R(40,100) ew=R(10,24) eh=R(8,20) ee=0.5*ew*eh ec=(R(0,H),R(0,H),R(0,H)) fballdir=R(3,4) fballx=70 fbally=120 fballw=fballh=R(4,12) fballc=RED #player faces left or right facingleft=False facingright=True doorx=-10 doory=-10 doorw=16 doorh=200 doorc=BLACK vel=1 xVel=0 jumping=False jumpCount=0 maxJump=25 falling=True def pause(): draw_string("(PAUSED)",110,100,(randint(0,255),randint(0,255),randint(0,255)),bg) while K(KEY_OK): pass while not K(KEY_OK): pass while K(KEY_OK): draw_string(" ",110,100,bg,bg) pass F(0,22,SW,SH,bg) F(0,0,SW,20,BLACK) F(0,210,SW,50,(R(0,H),R(0,55),R(0,25))) wx=R(10,280) wy=R(30,180) while game: etimer+=0.1 draw_string("World:"+str(world),100,0,"yellow",BLACK) draw_string(":["+str(round(plife)),16,0,WHITE,BLACK) draw_string("Score:"+str(psc),220,0,CYAN,BLACK) F(2,3,pw-2,ph-2,pc) F(4,5,5,5,CYAN) if etimer>R(6,10): etimer=0 edir=R(0,4) echase=choice([False,True]) #enemy chases player if echase: if ex<px: for i in range(3): edir=2 if ex>px: edir=1 if ey<py: edir=4 if ey>py: edir=3 if dooropen: F(doorx,doory,doorw,doorh,(randint(0,255),randint(0,255),randint(0,255))) F(doorx,doory+doorh,doorw,2,WHITE) # 3 platforms F(GX,GY,GW,GH,GC) F(GX2,GY2,GW2,GH2,GC2) F(GX3,GY3,GW3,GH3,GC3) #draw player & enemy F(px,py,pw,ph,pc) F(px+2,py+2,7,5,CYAN) F(ex,ey,ew,eh,ec) F(ex+2,ey+4,8,4,choice([BLACK,WHITE,DARKGREEN])) if K(KEY_LEFT): px += -vel F(px+pw,py,1,ph,bg) facingleft=True facingright=False if K(KEY_RIGHT): px += vel F(px-1,py,1,ph,bg) facingright=True facingleft=False if K(KEY_BACKSPACE) and jumping==False and falling==False: jumping=True jumpCount=1 if jumping: jumpCount+=1 py-=3 F(px,py+ph+1,pw,3,bg) #leave this in jumping scope if jumpCount==maxJump: jumping=False falling=True elif falling: if py+ph<=GY and py+ph>=GY: falling=False else: falling=True #careful with code here! if px+pw>=GX and px<=GX+GW and py+ph>=GY: falling=False else: falling=True if py+ph>=GY+GH: falling=True if px+pw>=GX2 and px<=GX2+GW2 and py+ph>=GY2: falling=False if py+ph>=GY2+GH2: falling=True if px+pw>=GX3 and px<=GX3+GW3 and py+ph>=GY3: falling=False if py+ph>=GY3+GH3: falling=True if falling: sleep(0.0001) py+=vel F(px,py-1,pw,1,bg) #player teleports to new world if px>doorx and px+pw<doorx+doorw and py+ph>=doory and py<=doory+doorh and edefeated==True: py-=2 falling=False if py+ph<0 and edefeated==True: px=8 bg=(R(0,80),R(0,20),R(0,80)) ex=R(180,280) ey=R(40,100) ew=R(10,24) eh=R(8,20) ee=0.5*ew*eh fballw=R(5,15) fballh=fballw world+=1 edefeated=False ec=(R(0,H),R(0,H),R(0,H)) dooropen=False pe+=0.4 psc+=R(5,10) F(0,22,SW,SH,bg) F(0,210,SW,50,(H,0,0)) py=20 GX=R(0,10) GY=R(20,190) GW=R(20,140) GH=300 GC=(R(0,55),R(0,55),R(0,55)) GX2=R(80,180) GY2=R(20,190) GW2=R(20,140) GH2=300 GC2=(R(0,25),R(0,25),R(0,25)) GX3=R(200,280) GY3=R(40,190) GW3=R(20,140) GH3=300 GC3=(R(0,10),R(0,10),R(0,10)) if K(KEY_OK): pause() if K(KEY_TOOLBOX) and facingleft: F(0,py+4,px,3,(R(0,H),R(0,H),R(0,H))) sleep(0.0015) F(0,py+4,px,3,bg) if K(KEY_TOOLBOX) and facingright: F(px+pw,py+4,SW-px,3,(randint(150,255),randint(0,25),randint(0,25))) sleep(0.0015) F(px+pw,py+4,SW-px,3,bg) if facingleft: F(px+1,py+7,1,3,WHITE) facingright=False if facingright: F(px+pw-3,py+7,1,3,WHITE) facingleft=False #enemy is hit if K(KEY_TOOLBOX) and facingleft and ex<=px and py+4>=ey and py+4<=ey+eh: F(ex,ey,ew,eh,RED) ee-=0.2 pe+=0.01 if K(KEY_TOOLBOX) and facingright and ex>=px and py+4>=ey and py+4<=ey+eh: F(ex,ey,ew,eh,RED) F(259,6,60,10,BLACK) ee-=0.2 psc+=1 pe+=0.05 #enemy destroyed if ee<1: edefeated=True ee=0 doorx=GX3+4 doory=GY3-doorh dooropen=True for i in range(5): for j in range(5): i=R(ex,ex+ew) j=R(ey,ey+eh) F(i,j,R(2,5),R(2,5),choice([BLACK,DARKRED,RED])) dooropen=True if dooropen: F(doorx,doory,doorw,doorh,(randint(0,255),randint(0,255),randint(0,255))) eattacks=False echase=False etimer=0 edir=0 if ex<1: ex=1 edir=choice([2,3,4]) if ex+ew>322: ex=322-ew edir=choice([1,3,4]) if ey<=24: ey=24 if ey+eh>SH: ey=SH-eh edir=choice([1,2,3]) #enemy moves if edir==1: ex-=1 F(ex+ew,ey,1,eh,bg) if edir==2: ex+=1 F(ex-1,ey,1,eh,bg) if edir==3: ey-=1 F(ex,ey+eh,ew,1,bg) if edir==4: ey+=1 F(ex,ey-1,ew,1,bg) if ey+eh>210: ey=210-eh ee-=0.01 F(ex,ey,ew,eh,RED) #boundaries if px+pw<0: px=321 if px>322: px=1 if py<20 and edefeated==False: py=20 #on lava if py+ph>210: falling=False py=210-ph F(px,py,pw,ph,RED) pe-=0.2 #player energy loss if px+pw>=ex and px<=ex+ew and py+ph>=ey and py<=ey+eh and edefeated==False: F(px,py,pw,ph,RED) sleep(0.001) pe-=0.001*ew*eh ee+=0.1 edir=R(1,4) if plife<2: F(px,py,pw,ph,bg) if ee<50: F(ex,ey,ew,eh,"gray") if pe<1: pe=9 plife-=1 if pe>9: pe=1 plife+=1 if px+pw>ex and px<ex+ew and py+ph>ey and py+ph<ey+eh: pe-=0.1 ee-=0.2 py-=2 if fbally<22: fbally=22 fballdir=4 if fbally+fballh>SH: fbally=SH-fballh fballdir=3 fballw=fballh=R(4,10) F(fballx,fbally,fballw,fballh,bg) fballx=R(0,SW) F(fballx,fbally,fballw,fballh,(R(50,255),0,R(0,55))) if fballdir==3: fbally-=1 F(fballx,fbally+fballh,fballw,1,bg) if fballdir==4: fbally+=1 F(fballx,fbally-1,fballw,1,bg) if px+pw>=fballx and px<=fballx+fballw and py+ph>=fbally and py<=fbally+fballh: F(px,py,pw,ph,RED) pe-=0.2 if ex+ew>=fballx and ex<=fballx+fballw and ey+eh>=fbally and ey<=fbally+fballh: F(ex,ey,ew,eh,RED) ee-=0.2 wy+=1 if wy>SH: wy=R(-600,-300) wx=R(15,305) draw_string("\u0024",wx,wy+R(1,3),"black",(0,R(120,255),0)) if plife<1: game=False F(GX,GY-2,GW,2,"magenta") F(GX2,GY2-2,GW2,2,"white") F(GX3,GY3-2,GW3,2,"pink") draw_string("GAME OVER",100,100,WHITE,bg) draw_string("SCORE:"+str(psc),100,140,CYAN,bg)