feu.py

Created by antarctus

Created on October 09, 2021

873 Bytes

Joli animation d’un feu


from math import *
from random import *
from kandinsky import *
from time import *

try:
  from kandinsky import get_keys
  color = (192, 53, 53)
except:
  color = (255, 183, 52)


map=[
[200,]*32,
]

for i in range(21):
  map+=[map[0][:],]

def draw():
  for y in range(22):
    for x in range(32):
      fill_rect(x*10,2+y*10,10,10,(map[y][x],0,0))
#int((map[y][x]/128)**8)

def decall():
  global map
  for x in range(32):
    for y in range(19):
      map[19][x]=(map[20][x-1]+map[20][x]+map[20][(x+1)%32]+map[21][x])//4.3
      map[20][x]=(map[21][x-1]+map[21][x]+map[21][(x+1)%32])//3.3
      map[y][x]=(map[y+1][x-1]+map[y+1][x]+map[y+1][(x+1)%32]+map[y+2][x]+map[y+3][x])//5.3

def addCouche():
  global map
  for x in range(32):
    map[-1][x]=randint(200,255)


fill_rect(0,0,320,2,color)

while True:
  decall()
  addCouche()
  draw()
#  sleep(0.05)