chess1.py

Created by schraf

Created on March 05, 2020

924 Bytes

Suivre une partie de jeu d'échecs

Voir les explications en vidéo ici

Première partie - Création du plateau et des pièces

On reprend l’idée de la vidéo sur les nageurs pour la création des pièces.
Inspiration pour la forme des pièces : https://youtu.be/36P26xWokjY


from kandinsky import *

# Pieces echecs
P = [0,120,252,252,120,120,252,510,510,0]
T = [0,438,438,510,252,252,252,510,510,0]
C = [0,56,124,124,240,248,252,510,510,0]
F = [48,56,156,220,478,510,252,510,510,0]
R = [48,120,48,252,510,252,252,510,510,0]
D = [72,120,306,438,180,252,252,510,510,0]
pos="TCFDRFCTPPPPPPPP"

def dessin(x,y,p,coul):
  for c in range(10):
    for l in range(10):
      if p[l]>>c & 1:
        car(x+2*c,y+2*l,2,coul)

def car(x,y,t,c):
  for i in range(t*t): 
    set_pixel(x+i%t,y+i//t,c)
    
def jeu():
  g,h=30,30
  for c in range(8):
    for l in range(8):
      coul = (110,110,220) if (c+l)%2==0 else (0,0,0)
      car(g+20*c,h+20*l,20,coul)
    draw_string(str(c+1),g-20,h+1+7*20-20*c)
    draw_string(chr(97+c),g+5+20*c,h-20)
  for v in range(16):
    dessin(g+20*(v%8),h+20*(v//8),eval(pos[v]),(240,150,50))
    dessin(g+20*(v%8),h+7*20-20*(v//8),eval(pos[v]),(248,255,248))

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.