msfdvbndwf.py

Created by leno-m

Created on April 16, 2025

1.97 KB


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

#fonction
def init_screen():
  fill_rect(0,0,320,222,textures[0])
  for x in range(4):
    for y in range(4):
      fill_rect(80+x*40,31+y*40,40,40,textures[1])
      fill_rect(80+x*40+1,31+y*40+1,38,38,textures[2])

def adjust_color(color, dr, dg, db):
    r = min(max(color[0] + dr, 0), 255)
    g = min(max(color[1] + dg, 0), 255)
    b = min(max(color[2] + db, 0), 255)
    return (r, g, b)

def draw_tetris_block(x, y, size, base_color):
    border = max(2, size // 8)

    light_color = adjust_color(base_color, +40, +40, +40)
    dark_color = adjust_color(base_color, -50, -50, -50)
    inner_color = adjust_color(base_color, -20, -10, -30)

    fill_rect(x, y, size, size, base_color)
    for i in range(border):
        fill_rect(x + i, y, size - 2*i, 1, light_color)
        fill_rect(x, y + i, 1, size - 2*i, light_color)
    for i in range(border):
        fill_rect(x + i, y + size - 1 - i, size - 2*i, 1, dark_color)
        fill_rect(x + size - 1 - i, y + i, 1, size - 2*i, dark_color)

    inset = border + 1
    fill_rect(x + inset, y + inset, size - 2*inset, size - 2*inset, inner_color)

def draw_grille():
  for x in range(4):
     for y in range(4):
       if grille[x][y] != 0:
          x_absolut = int(80+x*40+1)
          y_absolut = int(31+y*40+1)
          draw_tetris_block(x_absolut,y_absolut,38,couleurs[grille[x][y]])
          draw_string(str(2**grille[x][y]), x_absolut+14, y_absolut+11,"white",adjust_color(couleurs[grille[x][y]], -20, -10, -30))

#main
textures = [(50,50,50),(40,40,40),(70,70,70),(0,200,0),(255,0,0)]
couleurs = [(200, 60, 60),(60, 100, 200),(60, 180, 90),(150, 60, 180),(230, 140, 60),(220, 200, 60),(140, 100, 60),(60, 200, 200),(255, 100, 180)]
grille = []
for x in range(4):
    grille.append([])
    for y in range(4):
      grille[x].append(0)

#for i in range(4):
grille[randint(0,3)][randint(0,3)]= randint(1,2)

init_screen()
draw_grille()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

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.