Destroy oncoming Rectangles or Squares.
Good luck!
Sincerely,
Wilson
# Game By: Wilson from math import * from random import * from kandinsky import * from ion import * from time import * bg=(0,0,0) fill_rect(0,0,322,222,bg) while not keydown(KEY_OK): fill_rect(0,10,322,3,"blue") fill_rect(0,50,322,3,"blue") draw_string("Pythagoras World",50,22,"white",bg) draw_string("Key [Backspace] = Pause/Unpause",5,110,"green",bg) draw_string("Use [ARROWS] to Avoid Rects",15,140,"cyan",bg) sleep(0.1) draw_string("( Press [OK] to START )",25,190,"white",bg) sleep(0.2) fill_rect(0,0,322,222,(0,0,0)) fill_rect(0,20,322,2,"gray") fill_rect(0,200,322,2,"gray") while not keydown(KEY_OK): draw_string("________TIPS:_______",40,50,"gray",(0,0,0)) draw_string("Rects with values higher",10,100,"white",(0,0,0)) draw_string("than [40] are hard to destroy.",10,130,"white",(0,0,0)) draw_string("Avoid the Dark Matter!",20,160,"cyan",(0,0,0)) game=True bg=(randint(0,255),randint(0,255),randint(0,255)) psc=0 pe=35 px=20 py=100 pw=10 ph=5 pc=(randint(200,255),randint(200,255),randint(200,255)) #pstep=1 rect_x=randint(300,500) rect_y=randint(20,200) rect_w=randint(20,60) rect_h=randint(20,60) rect_c=(randint(0,255),randint(0,255),randint(0,255)) rectmass=(rect_w*rect_h)/5 #rects can chase or change #shape dimension rect_t=0 rect_g=False rect_chase=False rect_v=0 # dark matter! darkm_x=randint(322,500) darkm_y=randint(22,200) darkm_w=randint(20,80) darkm_h=randint(20,80) darkm_c=(randint(0,25),randint(0,25),randint(0,25)) # move rect def move_Rect(): global rect_x,rect_y,rect_w,rect_h,rect_c rect_x-=1 fill_rect(rect_x+rect_w,rect_y,1,rect_h,bg) # move meteor def move_darkmatter(): global darkm_x,darkm_y,darkm_w,darkm_h darkm_x-=1 fill_rect(darkm_x+darkm_w,darkm_y,1,darkm_h,bg) #move player def move_Left(): global px,py,pw,ph,pc px-=1 fill_rect(px+pw,py,1,ph,bg) def move_Right(): global px,py,pw,ph,pc,bg px+=1 fill_rect(px-1,py,1,ph,bg) def move_Up(): global px,py,pw,ph,pc,bg py-=1 fill_rect(px,py+ph,pw,1,bg) def move_Down(): global px,py,pw,ph,pc,bg py+=1 fill_rect(px,py-1,pw,1,bg) # when keys pressed def keyListen(): if keydown(KEY_BACKSPACE): pause() if keydown(KEY_LEFT): move_Left() if keydown(KEY_RIGHT): move_Right() if keydown(KEY_UP): move_Up() if keydown(KEY_DOWN): move_Down() # game is paused/unpaused def pause(): if keydown(KEY_BACKSPACE): draw_string("(PAUSED)",110,100,(randint(0,255),randint(0,255),randint(0,255)),bg) while keydown(KEY_BACKSPACE): pass while not keydown(KEY_BACKSPACE): pass while keydown(KEY_BACKSPACE): draw_string(" ",110,100,bg,bg) pass # draw the main things def drawGame(): draw_string("Energy:"+str(int(pe)),12,0,"white",(0,0,0)) draw_string("Score:"+str(int(psc)),190,0,"cyan",(0,0,0)) fill_rect(0,0,4,222,"red") fill_rect(0,20,322,3,"gray") fill_rect(0,218,322,3,"gray") fill_rect(darkm_x,darkm_y,darkm_w,darkm_h,darkm_c) fill_rect(px,py,pw,ph,pc) fill_rect(rect_x,rect_y,rect_w,rect_h,rect_c) # Game over when pe is less # than zero. def gameEnd(): global bg,psc for i in range(100): for j in range(100): i=randint(0,321) j=randint(0,222) fill_rect(i,j,randint(2,5),randint(2,5),choice(["black","white","gray"])) draw_string("GAME OVER",100,90,(randint(0,255),randint(0,255),randint(200,255)),(0,0,0)) draw_string("SCORE: "+str(psc),100,120,(randint(200,255),randint(200,255),randint(200,255)),(0,0,0)) def rect_spawn(): global rect_x,rect_y,rect_w,rect_w,rect_c,bg,psc,pe,rectmass rect_x=randint(250,322) rect_y=randint(-40,210) rect_w=randint(20,150) rect_h=randint(40,210) rect_c=(randint(0,255),randint(0,255),randint(0,255)) pe-=randint(0,1) psc+=randint(15,35) # bg=(randint(0,60),randint(0,60),randint(0,60)) fill_rect(0,22,322,222,bg) rectmass=(rect_w*rect_h)/6 fill_rect(0,0,322,222,bg) #ceiling for i in range(0,322): i+=1 fill_rect(i,randint(20,25),randint(2,5),randint(5,15),choice([(125,0,0),(0,0,0),"red"])) #ground for i in range(0,322): i+=1 lava_y=randint(205,220) fill_rect(i,lava_y,randint(2,5),30,choice([(255,0,0),(120,0,0),(0,0,0)])) while game: # sometimes rect will follow rect_chase=choice([1,0,1,0,0,0]) drawGame() keyListen() move_Rect() move_darkmatter() # when rectangle reaches the # left wall if rect_x<0-rect_w-randint(10,25): rect_spawn() for i in range(0,322): i+=1 fill_rect(i,randint(20,25),randint(2,5),randint(5,15),choice([(125,0,0),(0,0,0),"red"])) for i in range(0,322): i+=1 lava_y=randint(205,220) fill_rect(i,lava_y,randint(2,5),30,choice([(255,0,0),(120,0,0),(0,0,0)])) # if player gets hit, energy # lost and push back if px+pw >= rect_x and px <= rect_x+rect_w and py+ph >= rect_y and py <= rect_y+rect_h: fill_rect(px,py,pw,ph,"red") pe-=0.1 fill_rect(2,0,122,20,bg) px-=1 # dark matter is powerful. if px+pw >= darkm_x and px <= darkm_x+darkm_w and py+ph >= darkm_y and py <= darkm_y+darkm_h: fill_rect(px,py,pw,ph,choice(["black","red"])) pe-=2 fill_rect(2,0,122,20,bg) if pe<1: game=False if rect_chase: if int(rect_y+rect_h/2) < py: rect_y+=1 fill_rect(rect_x,rect_y-1,rect_w,1,bg) if rect_y>py: rect_y-=1 fill_rect(rect_x,rect_y+rect_h,rect_w,1,bg) if py+ph > 218: py = 218-ph fill_rect(px,py,pw,ph,"gray") pe-=0.02 fill_rect(2,0,122,20,bg) if py < 23: py = 23 fill_rect(px,py,pw,ph,"gray") pe-=0.02 fill_rect(2,0,122,20,bg) # player touches lava on left if px < 3: px = 3 fill_rect(px,py,pw,ph,"red") pe -= 0.2 fill_rect(2,0,122,20,bg) if px+pw>322: px=322-pw if keydown(KEY_OK): fill_rect(px+3,py,322,4,(randint(0,255),randint(0,255),randint(0,255))) sleep(0.002) fill_rect(px+3,py,322,4,bg) # player or ship is low # on energy or fuel # ship is leaking. if pe<=20: fill_rect(px+randint(-3,3),py,randint(2,4),randint(2,4),"orange") fill_rect(px,py,pw,ph,choice(["red","black",bg])) fill_rect(px,py-1,pw,1,bg) draw_string("( WARNING:LOW ENERGY!! )",40,202,"green",(0,0,0)) py+=choice([0,0,1,0]) if darkm_x<0-darkm_w-randint(10,20): darkm_x=randint(500,800) darkm_y=randint(22,200) darkm_w=randint(40,100) darkm_h=randint(50,120) darkm_c=(randint(0,35),randint(0,35),randint(0,35)) # rects gets shot if keydown(KEY_OK) and py >= rect_y and py+ph <= rect_y+rect_h and px+pw<=rect_x+rect_w: fill_rect(px,py,pw,ph,"green") pe+=0.001 rectmass-=6 psc+=1 fill_rect(rect_x,rect_y,rect_w,rect_h,"cyan") fill_rect(rect_x,rect_y,rect_w,rect_h,bg) for i in range(randint(5,20)): for j in range(randint(5,20)): i=rect_x+randint(0,rect_w) j=rect_y+randint(0,rect_h) fill_rect(i,j,randint(2,5),randint(2,5),choice(["cyan","black",bg,rect_c,bg])) # rectmass reflects strengh # of rectangles #player crashes into ceiling if py<=9: py=9 pe-=2 fill_rect(76+int(pe/3),3,2,12,bg) fill_rect(px,py,pw,ph,(120,0,0)) for i in range(0,322): i+=1 #player crashes into ceiling if py<=36: py=randint(35,36) pe-=0.5 fill_rect(px,py,pw,ph,(120,0,0)) for i in range(0,322): i+=1 fill_rect(i,randint(20,25),randint(2,5),randint(5,15),choice([(125,0,0),(0,0,0),"red"])) #player crashes into ground if py>200: py=randint(199,200) pe-=0.5 fill_rect(px,py,pw,ph,(140,0,0)) for i in range(0,322): i+=1 lava_y=randint(205,220) fill_rect(i,lava_y,randint(2,5),30,choice([(255,0,0),(120,0,0),(0,0,0)])) #rectangle destroyed if rectmass<1: rect_x=randint(400,500) rect_y=randint(-40,210) rect_w=randint(20,150) rect_h=randint(40,210) rect_c=(randint(0,255),randint(0,255),randint(0,255)) rectmass=(rect_w*rect_h)/6 pe+=(rect_w*rect_h)*0.0005 bg=(randint(0,255),randint(0,255),randint(0,255)) fill_rect(0,0,322,222,bg) for i in range(0,322): i+=1 fill_rect(i,randint(20,25),randint(2,5),randint(5,15),choice([(125,0,0),(0,0,0),"red"])) for i in range(0,322): i+=1 lava_y=randint(205,220) fill_rect(i,lava_y,randint(2,5),30,choice([(255,0,0),(120,0,0),(0,0,0)])) draw_string(str(int(rectmass/30)),int(rect_x+(rect_w/7)),rect_y+2,(0,0,0),rect_c) fill_rect(int(rect_x+(rect_w/5)),int(rect_y+(rect_h/3)),int(rectmass/50),10,"red") gameEnd()