Le but du jeu est simple : Battre le plus de vagues d’ennemis possible afin d’engranger le plus de points ! Les ennemis laisseront peut être derrières eux des potions susceptibles de :
Vous soigner,
Augmenter votre maximum de vie,
Augmenter vos munitions.
Mais attention, aux projectiles que ces monstres vous lanceront dessus.
OK pour tirer,
les flèches pour se déplacer.
Kojiverse Productions
## Growners - Kojiverse Productions from math import * from kandinsky import * from ion import * from random import * from time import * fl = fill_rect dr = draw_string k = keydown def logo(): fl(0,0,333,222,(0,)*3) fl(110,50,100,10,(255,)*3) fl(145,50,10,100,(255,)*3) fl(110,140,100,10,(255,)*3) fl(120,95,70,10,(255,)*3) fl(180,95,10,50,(255,)*3) dr("- Kojiverse -",95,150,(255,)*3,(0,)*3) sleep(3) class Data: def is_omega(): try: from os import * return True except: return False def load_score(): with open("growners.sav","r") as f: score=f.readline() return score f.close() def save_score(score): with open("growners.sav","w") as f: f.truncate(0) f.write("%s"%score) f.close() def check_collid(rect1,rect2): x1, y1, w1, h1 = rect1 x2, y2, w2, h2 = rect2 w1,h1 = w1+x1,h1+y1 w2,h2 = w2+x2,h2+y2 return (x1<w2 and w1>x2 and y1<h2 and h1>y2) class Player: """ Player class for project (move,shot,...) """ def __init__(self): self.x,self.y = 320//2,140 self.size = 10 self.waves = 0 self.hp = 5 self.max_hp = self.hp self.bullets = [] self.bullet_lim = 0 self.bullet_size = (8,20) self.score = 0 def move(self): if k(KEY_UP) and self.y>0: self.y -= self.size//2 elif k(KEY_DOWN) and self.y<220-self.size: self.y += self.size//2 if k(KEY_RIGHT) and self.x<320-self.size: self.x += self.size//2 elif k(KEY_LEFT) and self.x>0: self.x -= self.size//2 if k(KEY_OK) and len(self.bullets)<=self.bullet_lim: self.bullets.append([True,self.x+1,self.y-self.bullet_size[1],(0,255,255)]) def bullet_move(self): for bullet in self.bullets: bullet[2] -= self.bullet_size[1] if bullet[2]<0: bullet[0] = False self.update_bullets() def update_bullets(self): self.bullets = [bullet for bullet in self.bullets if bullet[0]] def render_excl(self): x,y = self.x,self.y fl(x-5,y+8,20,2,(0,0,255)) fl(x-3,y+6,16,2,(0,0,255)) fl(x-1,y+4,12,2,(0,0,255)) fl(x,y,10,10,(255,0,0)) fl(x+2,y-1,6,6,(0,0,255)) fl(x+1,y+12,8,3,(255,255,15)) fl(x+3,y+15,4,3,(255,255,15)) def render(self): self.render_excl() wav = "Waves : %s"%self.waves dr(wav,310-len(wav)*10,0,(255,)*3,(22,)*3) dr("HP : %s"%self.hp,10,0,(255,)*3,(22,)*3) dr(str(self.score),320//2-(len(str(self.score))*5),0,(255,)*3,(22,)*3) for bullet in self.bullets: fl(bullet[1],bullet[2],self.bullet_size[0],self.bullet_size[1],bullet[-1]) fl(bullet[1]+1,bullet[2]-1,self.bullet_size[0]-2,self.bullet_size[1]+2,bullet[-1]) def globall(self): self.move() self.bullet_move() self.render() class Obamabee: """ Enemy class for project (attack,move,...) """ def __init__(self): self.powers = [] self.colors = [(0,0,255),(0,255,0),(255,0,255),(255,0,0)] self.bees = [] self.curr_dir = 1 self.curr_move = 0 self.nb_move = 20 self.size = 20 self.bullets = [] self.bullet_size = ((10,10),(30,30)) def move(self): if not len(self.bees): self.spawn() self.curr_move+=1 if self.curr_move >= self.nb_move: self.curr_move = 0 self.curr_dir *= -1 for bee in self.bees: bee[2] += 3+((player.waves-1)//3) if randint(1,100)//(91-player.waves): self.bee_shooting(bee) for bee in self.bees: bee[1] += self.curr_dir self.check_bee_collid() self.update_bees() self.bullet_move() def bee_shooting(self,bee): self.bullets.append([True,bee[1],bee[2],randint(1,100)//(91-player.waves)]) def check_bee_collid(self): for bee in self.bees: if check_collid((bee[1],bee[2],self.size,self.size),(player.x,player.y,player.size,player.size)): player.hp -= 1 player.y += 3*player.size for bullet in player.bullets: r1 = (bee[1],bee[2],self.size,self.size) r2 = (bullet[1],bullet[2],player.bullet_size[0],player.bullet_size[1]) if check_collid(r1,r2): bullet[0] = False bee[0] = False player.score+=10 if randint(1,100)//(90+player.waves//5): self.powers.append([True,bullet[1],bullet[2],choice([1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,3])]) def power(self): for power in self.powers: if check_collid((power[1],power[2],20,20),(player.x,player.y,player.size,player.size)): if power[-1]==1: player.score+=100 power[0]=False player.hp += 3 if player.hp > player.max_hp: player.hp = player.max_hp elif power[-1]==2: player.score+=200 power[0]=False player.max_hp+=2 player.hp+=2 else: player.score+=500 power[0]=False player.bullet_lim+=1 cl = (255,0,0) if power[-1]==1 else (0,255,0) if power[-1]==2 else (0,0,255) x,y = power[1],power[2] fl(x+1,y+9,18,12,(95,200,245)) fl(x-1,y+11,22,8,(95,200,245)) fl(x+6,y,8,20,(95,200,245)) fl(x+2,y+13,16,5,cl) fl(x+3,y+13,14,6,cl) self.powers = [power for power in self.powers if power[0]] def update_bees(self): self.bees = [bee for bee in self.bees if bee[0]] def bullet_move(self): for bullet in self.bullets: bullet[2] += self.bullet_size[0][1]//2+((player.waves-1)//5) if bullet[2]>220: bullet[0] = False if check_collid((player.x,player.y,player.size,player.size),(bullet[1],bullet[2],self.bullet_size[bullet[-1]][0],self.bullet_size[bullet[-1]][1])): player.hp -= 1 if not bullet[-1] else 3 bullet[0] = False self.update_bullets() def update_bullets(self): self.bullets = [bullet for bullet in self.bullets if bullet[0]] def render(self): for bee in self.bees: x,y = bee[1],bee[2] fl(x,y,20,20,bee[-1]) fl(x-10,y+8,40,4,bee[-1]) fl(x-6,y+12,32,4,bee[-1]) fl(x-12,y+4,44,4,bee[-1]) fl(x+3,y+3,4,4,(0,)*3) fl(x+20-3,y+3,-4,4,(0,)*3) fl(x+8,y+10,4,6,(0,)*3) for bullet in self.bullets: if not bullet[-1]: fl(bullet[1]+3,bullet[2],4,10,(255,255,0)) fl(bullet[1],bullet[2]+3,10,4,(255,255,0)) else: x,y = bullet[1],bullet[2] fl(x+1,y-1,28,32,(250, 110, 10)) fl(x-1,y+1,32,28,(250, 110, 10)) fl(x+6,y-8,18,20,(250, 110, 10)) fl(x+5,y-7,20,18,(250, 110, 10)) fl(x+10,y-15,8,10,(250, 110, 10)) fl(x+9,y-14,10,8,(250, 110, 10)) def spawn(self): x_,y_ = 5+player.waves//10,2+player.waves//10//3 if y_>4:y_= 4 if x_>10:x_ = 10 [[self.bees.append([True,20+x*(300//x_),10+y*40,choice(self.colors)]) for x in range(x_)] for y in range(y_)] player.waves += 1 def globall(self): self.power() self.move() self.render() def game_over(): fl(0,0,333,222,(22,)*3) txt = "Game Over" dr(txt,320//2-(len(txt)*5),50,(250,0,0),(22,)*3) txt = "Score : %s"%player.score dr(txt,320//2-(len(txt)*4),80,(250,0,0),(22,)*3,1) if Data.is_omega(): try: high_score = Data.load_score() except: high_score = player.score print(high_score) if int(high_score)<=player.score: Data.save_score(str(player.score)) high_score = player.score txt = "High score : %s"%high_score dr(txt,320//2-(len(txt)*4),100,(250,0,0),(22,)*3,1) player.x,player.y = 20,30;player.render_excl() player.x,player.y = 250,100;player.render_excl() player.x,player.y = 100,180;player.render_excl() while not k(KEY_OK):pass sleep(1) def lunch(): logo() fl(0,0,333,222,(22,)*3) txt = "-] G R O W N E R S [-" dr(txt,320//2-(len(txt)*5),60,(255,0,0),(22,)*3) txt = "-[press OK]-" dr(txt,320//2-(len(txt)*5),90,(255,0,0),(22,)*3) p2 = Player() p2.x,p2.y = 320//2,140 p2.render_excl() while not k(KEY_OK): pass del p2 sleep(0.2) launch = True running = True lunch() while launch: ## init class player = Player() obama = Obamabee() while running: fl(0,0,333,222,(22,)*3) # updating background player.globall() obama.globall() if player.hp <= 0: break sleep(0.03) game_over()