# firegw.py

Created by schraf

Created on July 06, 2022

1.73 KB

D’autres jeux pour la NUMWORKS sur ma chaine Youtube : Rubika, solitaire, Mission missile, démineur, carré magique, TRON, défis de blanche…

Explications en vidéo

```from kandinsky import *
from time import *
from random import *
from ion import *

JX = [60,140,214]
PX = [0,25,44,53,58,67,78,82,92,107,123,129,134,147,158,163,180,200,207,221,237,256,268]
PY = [40,40,85,110,136,160,134,110,82,64,82,110,135,160,136,105,80,106,133,160,134,116,136]
RO, VE, BL, NR, BE = (255,0,0), (70,160,70), (255,255,255), (70,70,70), (120,160,250)
MAXVIES, DELAI = 10, 0.3
BAS, DRT = max(PY), max(PX)
fr, aff = fill_rect, draw_string

def dep_sauveurs(j, d):
aff("   ", JX[j], 174,BL,BE)
j += d
aff("o_o", JX[j], 174,BL,BE)
sleep(0.1)
return j

def dep_pers(p):
aff(" ", PX[p], PY[p],BL,BE)
p += 1
aff("P", PX[p], PY[p],BL,BE)
return p

def decors():
fr(0,0,320,220,BE)
fr(0,60,20,200,NR)
for i in range(4):
fr(20,60+40*i,20,20,NR)
fr(260,155,50,50,NR)
fr(0,200,320,30,VE)

def go():
decors()
score, vies = 0, MAXVIES
t = monotonic()
j = dep_sauveurs(0, randint(0,2))
pp = []
rebond = []
while vies >= 0:
if monotonic() - t > DELAI:
futur = []
for (i, p) in enumerate(pp):
if PY[p] == BAS and p not in rebond:
vies -= 1
aff("=", PX[p], PY[p])
aff("*"*(MAXVIES - vies), 0, 0, NR, RO)
else:
p = dep_pers(p)
if PX[p] == DRT:
score +=1
aff(str(score), 268, 135, NR, VE)
else: futur.append(p)
t = monotonic()
rebond = []
pp = futur
if random() < 0.1: pp.append(0)
if keydown(KEY_LEFT) and j > 0:
j = dep_sauveurs(j, -1)
if keydown(KEY_RIGHT) and j < 2:
j = dep_sauveurs(j, 1)
for p in pp:
if PY[p] == BAS and JX[j] == PX[p] - 7 and p not in rebond:
rebond.append(p)
aff("GAME OVER !", 100, 203, RO, NR)

go()```