frommathimport*fromcmathimport*fromkandinskyimport*fromkandinskyimportfill_rectasFfromrandomimport*fromrandomimportrandintasRfromionimport*fromtimeimport*gx=0gy=210gw=322gh=20gc=choice([(30,0,0),(60,0,0),(80,0,0)])box_x=0box_y=gy-50box_w=50box_h=50box_c=(100,50,20)defdraw_box():globalbox_x,box_y,box_w,box_h,box_cF(box_x,box_y,3,box_h,box_c)F(box_x+box_w-3,box_y,3,box_h,box_c)F(box_x,box_y,box_w,3,box_c)F(box_x,box_y+box_h-3,box_w,3,box_c)edir_timer=0echase=Falseeshooting=Falseeshoot_timer=0edir=0ex=R(200,322)ey=R(0,50)ew=12eh=14ec="black"defdraw_enemy():globalechase,edir,ex,ey,ew,eh,ecF(ex,ey,ew,eh,ec)F(ex+round(ew/5),ey+round(eh/6),round(ew/3),round(ew/5),"red")F(ex,ey,1,eh,(120,0,0))F(ex+ew-1,ey,1,eh,(120,0,0))F(ex,ey,ew,1,(120,0,0))F(ex,ey+eh-1,ew,1,(120,0,0))defmove_enemy():globalechase,edir_timer,edir,ex,ey,ew,eh,ec,bg# edir=choice([0,0,0,1,2,3,4])
edir_timer+=0.01ifedir_timer>=R(1,3):edir_timer=0echase=choice([True,False])ifechase:ifpx<ex:edir=1ifpx>ex:edir=2ifpy<ey:edir=3ifpy>ex:edir=4ifedir==1:ex-=3F(ex+ew,ey,3,eh,bg)eshooting=Trueifedir==2:ex+=3F(ex-3,ey,3,eh,bg)eshooting=Trueifedir==3:ey-=3F(ex,ey+eh,ew,3,bg)ifedir==4:ey+=3F(ex,ey-3,ew,3,bg)defcontain_enemy():globalechase,edir_timer,edir,ex,ey,ew,eh,ec,bg,box_x,box_y,box_w,box_hifex<0:ex=0ifex+ew>322:ex=322-ewifey+eh<=0:ey=0edir=1ifey+eh>gy:ey=gy-ehedir=2ifex<=box_x+box_wandey+eh>=160:ex=box_x+50defspawn_new_enemy():globalechase,edir_timer,edir,ex,ey,ew,eh,ec,bgechase=Falseedir_timer=0edir=0ex=R(0,310)ey=R(0,190)ew=R(10,18)eh=R(7,18)ec=(R(0,100),R(0,100),R(0,100))#////////////////////////
sleep(0.2)bonus_points=R(50,200)px=R(5,250)py=185pw=12ph=18pc="black"pfaces_left=Falsepfaces_right=Truebg="black"#start screen
F(0,0,322,222,bg)F(0,0,3,222,"blue")F(318,0,3,222,"blue")F(0,0,322,4,"blue")F(0,218,322,4,"blue")F(3,3,318,3,"white")F(3,30,318,3,"white")F(3,35,318,2,"white")F(R(260,280),0,R(8,45),222,(R(100,255),R(0,25),R(0,15)))F(0,200,322,5,"cyan")F(px,py,pw,ph,pc)F(px,py,pw,ph,pc)F(px,py-1,pw,1,bg)F(px,py,1,ph,"white")F(px+pw-1,py,1,ph,"white")F(px,py,pw,1,"white")F(px,py+ph,pw,1,"white")whilenotkeydown(KEY_OK)andnotkeydown(KEY_EXE):draw_string("RECTNINJA",100,10,"white",bg)draw_string("key [UP] = Float",100,60,(R(0,255),R(0,255),R(0,255)),bg)draw_string("key [Backspace] = Pause",15,80,"white",bg)draw_string("Key [Arrows] = Move",15,110,"cyan",bg)draw_string("Press [OK/EXE] key to Start",10,140,"orange",bg)F(0,200,322,3,"gray")gx=0gy=210gw=322gh=20gc=choice([(30,0,0),(60,0,0),(80,0,0)])defdraw_ground():globalgx,gy,gw,gh,gcF(gx,gy,gw,gh,gc)gravty=Truegame=Truehave_key=Falseshield_on=Falselevel_complete=Falsejump=Falsebg=(R(0,255),R(0,255),R(0,255))fall_speed=1jump_max=1jump_time=0level=1plife=3px=20py=20pw=12ph=18pc=(R(0,90),R(0,90),R(0,90))psc=0shield_time=R(3,6)shield_x=R(2,310)shield_y=R(-200,-50)shield_w=10shield_h=10shield_c=(R(0,255),R(0,255),R(0,255))floating_board_x=25floating_board_y=R(50,150)floating_board_w=R(10,70)floating_board_h=R(6,40)floating_board_c=(R(0,255),R(0,255),R(0,255))floating_board_2_x=0floating_board_2_y=R(30,160)floating_board_2_w=R(10,70)floating_board_2_h=R(6,45)floating_board_2_c=(R(0,255),R(0,255),R(0,255))floating_board_3_x=320-105floating_board_3_y=R(30,160)floating_board_3_w=R(10,70)floating_board_3_h=R(6,30)floating_board_3_c=(R(0,255),R(0,255),R(0,255))key_x=R(2,300)key_y=R(2,190)door_x=R(2,310)door_y=R(2,180)door_w=15door_h=22door_c=(R(0,255),R(0,255),R(0,255))key_amount=2key_1_obtained=Falsekey_1_x=R(2,310)key_1_y=R(2,200)key_1_w=6key_1_h=12key_1_c=choice([(R(175,255),R(175,255),R(175,255)),"yellow","orange","red","blue","cyan","pink","white","black","magenta"])key_2_obtained=Falsekey_2_x=R(5,310)key_2_y=R(5,200)key_2_w=6key_2_h=12key_2_c=choice([(R(175,255),R(175,255),R(175,255)),"yellow","orange","red","blue","cyan","pink","white","black","magenta"])key_3_obtained=Falsekey_3_x=R(5,310)key_3_y=R(5,200)key_3_w=6key_3_h=12key_3_c=choice([(R(175,255),R(175,255),R(175,255)),"yellow","orange","red","blue","cyan","pink","white","black","magenta"])fill_rect(0,0,322,222,bg)whilegame:gravty=Truepsc+=0.01shield_c=(R(0,255),R(0,255),R(0,255))ifshield_on==Falseandhave_key==False:shield_y+=choice([0,0,1])F(px,py,pw,ph,pc)F(px,py-2,pw,2,bg)F(px,py,1,ph,"gray")F(px+pw-1,py,1,ph,"gray")F(px,py,pw,1,"gray")F(px,py+ph-1,pw,1,"gray")F(shield_x,shield_y,shield_w,shield_h,shield_c)F(shield_x,shield_y-1,shield_w,1,bg)F(shield_x,shield_y,2,shield_h,"white")F(shield_x+shield_w-2,shield_y,2,shield_h,"white")F(shield_x,shield_y,shield_w,2,"white")F(shield_x,shield_y+shield_h-2,shield_w,2,"white")F(key_1_x,key_1_y,key_1_w,key_1_h,key_1_c)F(key_1_x,key_1_y,1,key_1_h,"blue")F(key_1_x+key_1_w-1,key_1_y,1,key_1_h,"blue")F(key_1_x,key_1_y,key_1_w,1,"blue")F(key_1_x,key_1_y+key_1_h-1,key_1_w,1,"blue")ifkeydown(KEY_LEFT):pfaces_left=Truepfaces_right=Falsepx-=1F(px+pw,py,2,ph,bg)ifkeydown(KEY_RIGHT):pfaces_right=Truepfaces_left=Falsepx+=1F(px-1,py,1,ph,bg)ifpx+pw<0:px=322ifpx>322:px=0ifgravty:py+=choice([0,1])ifhave_key:F(door_x,door_y,door_w,door_h,choice(["black","cyan","white"]))F(door_x,door_y,2,door_h,"cyan")F(door_x+door_w-2,door_y,2,door_h,"cyan")F(door_x,door_y,door_w,2,"cyan")F(door_x,door_y+door_h-2,door_w,2,"black")ifpx+pw>=key_1_xandpx<=key_1_x+key_1_wandpy+ph>=key_1_yandpy<=key_1_y+key_1_h:F(key_1_x,key_1_y,key_1_w,key_1_h,bg)F(px+1,py+1,pw-1,ph-1,choice(["green","white","cyan"]))have_key=Trueifhave_key:key_1_x=px+2key_1_y=py+3ifpx+pw>=door_xandpx<=door_x+door_wandpy+ph>=door_yandpy<=door_y+key_1_handhave_key:F(0,0,322,222,"black")level+=1plife+=1psc+=bonus_pointswhilenotkeydown(KEY_OK):draw_string("Level complete.!",20,10,"cyan","black")draw_string("Bonus Points: "+str(bonus_points),20,55,"white","black")draw_string("Score:"+str(round(psc)),20,85,"yellow","black")draw_string("life: "+str(round(plife)),20,120,"purple","black")draw_string("Press [OK] to continue to",40,160,"magenta","black")draw_string("the next level.",40,190,"blue","black")bonus_points=R(100,500)bg=(R(0,255),R(0,255),R(0,255))F(0,0,322,222,bg)draw_ground()door_x=R(2,300)door_y=R(2,200)door_c=(R(0,255),R(0,255),R(0,255))key_1_x=R(2,300)key_1_y=R(2,200)key_1_c=(R(0,255),R(0,255),R(0,255))floating_board_x=R(300,400)floating_board_y=R(60,150)floating_board_w=R(70,120)floating_board_h=R(6,10)floating_board_c=(R(0,255),R(0,255),R(0,255))floating_board_2_x=R(0,50)floating_board_2_y=R(60,150)floating_board_2_w=R(50,85)floating_board_2_h=R(6,10)floating_board_2_c=(R(0,255),R(0,255),R(0,255))floating_board_3_x=R(225,280)floating_board_3_y=R(60,150)floating_board_3_w=R(40,70)floating_board_3_h=R(6,10)floating_board_3_c=(R(0,255),R(0,255),R(0,255))px=8py=20shield_time=0shield_on=Falsehave_key=Falsespawn_new_enemy()ifshield_on:shield_time-=0.0025F(px,py,pw,ph,(R(0,255),R(0,255),R(0,255)))draw_string("Shield: "+str(round(shield_time)),2,2,"cyan","black")ifshield_time<0:shield_on=Falseshield_time=5draw_string("",2,2,bg,bg)#game over when plife<1
ifplife<1:game=False# simple Pause/Resume code
ifkeydown(KEY_BACKSPACE):whilenotkeydown(KEY_TOOLBOX):draw_string("( PAUSED )",110,60,"blue","cyan")draw_string("(PRESS [TOOLBOX] KEY TO RESUME)",5,140)draw_string("",110,60,bg,bg)draw_string("(PRESS [TOOLBOX] KEY TO RESUME)",5,140,bg,bg)F(px+2,py+3,9,7,"white")ifshield_y+shield_h>=gy:shield_y=gy-shield_hifpx+pw>=shield_xandpx<=shield_x+shield_wandpy+ph>=shield_yandpy<shield_y+shield_h:F(shield_x,shield_y,shield_w,shield_h,bg)shield_on=Trueshield_x=R(2,310)shield_y=R(-400,-250)F(floating_board_x,floating_board_y,floating_board_w,floating_board_h,floating_board_c)F(floating_board_x,floating_board_y,2,floating_board_h,"white")F(floating_board_x+floating_board_w-2,floating_board_y,2,floating_board_h,"white")F(floating_board_x,floating_board_y,floating_board_w,2,"white")F(floating_board_x,floating_board_y+floating_board_h-2,floating_board_w,2,"white")F(floating_board_x+floating_board_w,floating_board_y,1,floating_board_h,bg)#****************************
F(floating_board_2_x,floating_board_2_y,floating_board_2_w,floating_board_2_h,floating_board_2_c)F(floating_board_3_x,floating_board_3_y,floating_board_3_w,floating_board_3_h,floating_board_3_c)F(floating_board_2_x,floating_board_2_y,2,floating_board_2_h,"white")F(floating_board_2_x+floating_board_2_w-2,floating_board_2_y,2,floating_board_2_h,"white")F(floating_board_2_x,floating_board_2_y,floating_board_2_w,2,"white")F(floating_board_2_x,floating_board_2_y+floating_board_2_h-2,floating_board_2_w,2,"white")F(floating_board_3_x,floating_board_3_y,2,floating_board_3_h,"white")F(floating_board_3_x+floating_board_3_w-2,floating_board_3_y,2,floating_board_3_h,"white")F(floating_board_3_x,floating_board_3_y,floating_board_3_w,2,"white")F(floating_board_3_x,floating_board_3_y+floating_board_3_h-2,floating_board_3_w,2,"white")iffloating_board_x+floating_board_w<-10:floating_board_x=R(600,900)floating_board_y=R(50,100)#player lands on platforms
#middle bottom board
floating_board_x-=choice([0,1])ifpx+pw>=floating_board_xandpx<=floating_board_x+floating_board_wandpy+ph>=floating_board_yandpy<=floating_board_y:gravty=Falsepy=floating_board_y-phpx-=choice([0,1])F(px+pw,py,1,ph,bg)#left board
ifpx+pw>=floating_board_2_xandpx<=floating_board_2_x+floating_board_2_wandpy+ph>=floating_board_2_yandpy<=floating_board_2_y:gravty=Falsepy=floating_board_2_y-ph#right board
ifpx+pw>=floating_board_3_xandpx<=floating_board_3_x+floating_board_3_wandpy+ph>=floating_board_3_yandpy<=floating_board_3_y:gravty=Falsepy=floating_board_3_y-ph#gy is ground
ifpy+ph>=gy:py=gy-phfloating_board_2_y+=choice([0,0,0,1])iffloating_board_x+floating_board_w<-5:floating_board_x=322floating_board_w=R(10,70)floating_board_h=R(6,45)floating_board_c=(R(0,255),R(0,255),R(0,255))iffloating_board_2_y>200:F(floating_board_2_x,floating_board_2_y-1,floating_board_2_w,floating_board_2_h,bg)floating_board_2_y=0floating_board_2_w=R(10,70)floating_board_2_h=R(6,40)floating_board_2_c=(R(0,255),R(0,255),R(0,255))iffloating_board_3_y+floating_board_3_h<0:floating_board_3_y=200floating_board_3_w=R(10,75)floating_board_3_h=R(6,30)floating_board_3_c=(R(0,255),R(0,255),R(0,255))F(floating_board_2_x,floating_board_2_y-1,floating_board_2_w,1,bg)F(floating_board_3_x,floating_board_3_y+floating_board_3_h,floating_board_3_w,1,bg)ifjump:py-=R(1,2)F(px,py+ph,pw,2,bg)jump_max-=0.1ifjump_max<0:jump=Falsejump_max=1ifpy<=1:py=1ifkeydown(KEY_UP):py-=1F(px,py+ph,pw,2,bg)draw_ground()draw_enemy()draw_box()move_enemy()contain_enemy()ifpx+pw>=box_xandpx<=box_x+box_wandpy<=box_y+2andpy>=box_y+2:py=box_y+2gravty=Falseifpx+pw>=box_xandpx<=box_x+box_wandpy+ph>=box_yandpy<=box_y:gravty=Falsepy=box_y-phifkeydown(KEY_OK)andshield_onandpfaces_right:F(px+pw,py+4,322-px,2,"red")F(px+4,py+3,8,6,"red")sleep(0.01)F(px+pw,py+4,322-px,2,bg)ifkeydown(KEY_OK)andshield_onandpfaces_left:F(0,py+4,px,2,"red")F(px,py+3,8,6,"red")sleep(0.01)F(0,py+4,px,2,bg)#game over
sleep(1)F(0,0,322,222,"black")draw_string("GAME OVER",100,90,"red","black")sleep(1)draw_string("SCORE:",100,140,"white","black")sleep(1.1)draw_string(str(round(psc)),170,140,"cyan","black")
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.