taquin.py

Created by marius-layan

Created on February 05, 2024

3.09 KB

Taquin est un jeu avec comme but du jeu reconstituer un carré orange avec des contour noir. un pièce sur les 9 est manquante et cela vous permet de pouvoir déplacer les pièces au alentours.

pour boucher: flèches directionnelles

BON JEU !


from random import *
from kandinsky import *
from ion import *
from time import *
def start():
  global l,l1,lr,a,gray
  fill_rect(0,0,320,222,'white')
  l1,l,lr,gray=[],[[130,21],[70,81],[130,141],[190,21],[130,81],[190,141],[70,21],[190,81],[70,141]],[[130,21],[70,81],[130,141],[190,21],[130,81],[190,141],[70,21],[190,81],[70,141]],(180,180,180)
  while len(l1)!=9 or l1==[[130,21],[70,81],[130,141],[190,21],[130,81],[190,141],[70,21],[190,81],[70,141]]:
    if l1==[[130,21],[70,81],[130,141],[190,21],[130,81],[190,141],[70,21],[190,81],[70,141]]:l1=[]
    a=choice(l)
    for i in range(len(l)):
      if l[i]==a:l1.append(a);del l[i];break
  r=randint(0,8)
  for i in range(9):
    if lr[i]==l1[r]:lr[i]=0;l1[r]=0;break
def view():
  global x,y,z
  a=0
  for i in range(3):
    for j in range(3):
      if l1[a]==[130,21]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+100,j*60+51,30,30,'orange')
      elif l1[a]==[190,21]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+70,j*60+51,60,30,'orange')
      elif l1[a]==[70,21]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+70,j*60+51,30,30,'orange')
      elif l1[a]==[130,81]:fill_rect(i*60+70,j*60+21,60,60,'orange')
      elif l1[a]==[70,81]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+100,j*60+21,30,60,'orange')
      elif l1[a]==[190,81]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+70,j*60+21,30,60,'orange')
      elif l1[a]==[130,141]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+100,j*60+21,30,30,'orange')
      elif l1[a]==[190,141]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+70,j*60+21,60,30,'orange')
      elif l1[a]==[70,141]:fill_rect(i*60+70,j*60+21,60,60,'black');fill_rect(i*60+70,j*60+21,30,30,'orange')
      else:fill_rect(i*60+70,j*60+21,60,60,gray);x,y,z=i*60+70,j*60+21,a
      a+=1
start()
while True:
  if l1!=lr:view()
  else:
    c,gray=0,(80,192,0)
    fill_rect(0,0,320,222,'green');view();sleep(0.5);fill_rect(0,0,320,222,'black');draw_string("Partie fini",105,40,'green','black');draw_string("REJOUER",125,100,'yellow','black');draw_string(" oui ",135,150,'black','green');draw_string(" non ",135,180,'white','black')
    while True:
      if keydown(KEY_UP) and c==1:draw_string(" oui ",135,150,'black','green');draw_string(" non ",135,180,'white','black');c=0
      if keydown(KEY_DOWN) and c==0:draw_string(" oui ",135,150,'white','black');draw_string(" non ",135,180,'black','green');c=1
      if keydown(KEY_OK):break
    if c==1:break
    else:start();view()
  while True:
    if keydown(KEY_RIGHT) and get_pixel(x-1,y)!=(248,252,248):
      l1[z-3],l1[z]=l1[z],l1[z-3];x-=60
      while keydown(KEY_RIGHT):continue
      break
    if keydown(KEY_LEFT) and get_pixel(x+60,y)!=(248,252,248):
      l1[z+3],l1[z]=l1[z],l1[z+3];x+=60
      while keydown(KEY_LEFT):continue
      break
    if keydown(KEY_DOWN) and get_pixel(x,y-1)!=(248,252,248):
      l1[z-1],l1[z]=l1[z],l1[z-1];y-=60
      while keydown(KEY_DOWN):continue
      break
    if keydown(KEY_UP) and get_pixel(x,y+60)!=(248,252,248):
      l1[z+1],l1[z]=l1[z],l1[z+1];y+=60
      while keydown(KEY_UP):continue
      break

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.