threeways.py

Created by diage-77

Created on March 27, 2025

5.78 KB

  • Jeu de chance 🍀
  • Tutoriel inclus dans le jeu.
  • Vous pouvez choisir le nombres de tours que vous faites.

Compte tenu du fait que j’ai beaucoup de travail (le bac arrive 😭), je travaille à une moins grande cadence sur ces programmes, mais pour les potentiels ajouts et mise à jours que je vais faire, voici mes idées :

  • Retirer le bug d’affichage à la fin (le plateau se ré-affiche avant de passer à l’écran noir),
  • Afficher le score sur l’écran noir à la fin, et non pas dans la console d’exécution,
  • Faire un joli menu d’accueil,
  • Animer les flèches,
  • Changer le fond d’écran du jeu (il est aléatoire),
  • Optimiser (rendre le jeu moins lourd en kilo-octets, l’objectif est de pas dépasser 5 ko).

Pour toutes suggestions ou questions, n’hésitez pas à me contacter à mon adresse mail pro : dasilvatiago77310@gmail.com


from math import *
from turtle import *
from random import *
from kandinsky import *
from ion import *
from time import *
"""Ce jeu est un choice game en 2D, il necessite de la chance et de l'intuition.Realise par Tiago Da Silva (en une nuit)."""
#Catalogue des couleurs + variables
vc=[0,255,80]
vv=[0,200,0]
vf=[0,140,0]
bb=[0,170,255]
mm=[70,50,0]
bm=[77,63,0]
w=0
s=0
#def esthetique immobile
def presentoir(i):
  #Plateau
  fill_rect(0,0,330,230,vv)
  for i in range(2150):
    set_pixel(randint(0,330),randint(0,230),vc)
    set_pixel(randint(0,330),randint(0,230),vf)
    set_pixel(randint(0,330),randint(0,230),bm)
    set_pixel(randint(0,330),randint(0,230),mm)
  fill_rect(78,43,154,154,'gray')
  fill_rect(0,113,330,14,'gray')
  fill_rect(92,57,126,56,bb)
  fill_rect(92,127,126,56,bb)
  for i in range(150):
    set_pixel(randint(92,218),randint(57,113),vc)
    set_pixel(randint(92,218),randint(127,183),vc)
    set_pixel(randint(92,218),randint(57,113),vf)
    set_pixel(randint(92,218),randint(127,183),vf)
  fill_rect(0,115,80,10,'white')
  fill_rect(90,45,130,10,'white')
  fill_rect(90,115,130,10,'white')
  fill_rect(90,185,130,10,'white')
  fill_rect(80,45,10,150,'white')
  fill_rect(230,115,100,10,'white')
  fill_rect(220,45,10,150,'white')
  #Fleche 1 : up
  fill_rect(82,107,1,1,'black')
  fill_rect(83,106,1,1,'black') 
  fill_rect(84,105,1,8,'black')
  fill_rect(85,106,1,1,'black')
  fill_rect(86,107,1,1,'black')
  #Fleche 2 : down
  fill_rect(82,132,1,1,'black')
  fill_rect(83,133,1,1,'black')
  fill_rect(84,127,1,8,'black')
  fill_rect(85,133,1,1,'black')
  fill_rect(86,132,1,1,'black')
  #Fleche 3 : mid
  fill_rect(98,117,1,1,'black')
  fill_rect(99,118,1,1,'black')
  fill_rect(92,119,9,1,'black')
  fill_rect(99,120,1,1,'black')
  fill_rect(98,121,1,1,'black')
  #Fleche 4 : depart
  fill_rect(42,117,1,1,'black')
  fill_rect(43,118,1,1,'black')
  fill_rect(36,119,9,1,'black')
  fill_rect(43,120,1,1,'black')
  fill_rect(42,121,1,1,'black')
  #Marque
  draw_string("Tatch",0,0)
def game(i):
  n=int(input("Entrer le nombre de tours : "))
  w=n
  s=0
  print("Skip tutorial ?")
  print("1.Yes")
  print("2.No")
  m=int(input(""))
  if m==1:
    hideturtle()
  elif m==2:
    print("Ce jeu se nomme Tatch.")
    sleep(1.5)
    print("C'est un jeu de chance.")
    sleep(1.5)
    print("A chaque tour,")
    sleep(0.8)
    print("3 chemins s'ouvriront :")
    sleep(1.5)
    print("L'un rapportera 3 points,")
    sleep(1.5)
    print("L'autre en rapportera 2,")
    sleep(1.5)
    print("Et le dernier 1 point.")
    sleep(1.8)
    print("Utiliser les fleches pour")
    print("selectionner votre choix.")
    sleep(2.5)
    print("Votre partie se concluera")
    print("sur votre score.")
    sleep(2.5)
    print("Bonne chance !")
    sleep(3)
  else:
    print("Error!")
    game(1)
  presentoir(1)
  while n!=0:
    if keydown(KEY_UP)==True:
      fill_rect(90,45,140,10,'yellow')
      fill_rect(220,45,10,80,'yellow')
      fill_rect(80,45,10,80,'yellow')
      fill_rect(0,115,90,10,'yellow')
      fill_rect(220,115,110,10,'yellow')
      fill_rect(82,107,1,1,'red')
      fill_rect(83,106,1,1,'red')
      fill_rect(84,105,1,8,'red')
      fill_rect(85,106,1,1,'red')
      fill_rect(86,107,1,1,'red')
      fill_rect(42,117,1,1,'red')
      fill_rect(43,118,1,1,'red')
      fill_rect(36,119,9,1,'red')
      fill_rect(43,120,1,1,'red')
      fill_rect(42,121,1,1,'red')
      sleep(0.4)
      s=s+randint(1,3)
      n=n-1
      sleep(0.5)
      fill_rect(247,0,82,230,'pink')
      sleep(0.2)
      fill_rect(165,0,82,230,'purple')
      sleep(0.2)
      fill_rect(83,0,82,230,'blue')
      sleep(0.2)
      fill_rect(0,0,83,230,'red')
      sleep(0.6)
      presentoir(1)
    elif keydown(KEY_RIGHT)==True:
      fill_rect(0,115,330,10,'yellow')
      fill_rect(98,117,1,1,'red')
      fill_rect(99,118,1,1,'red')
      fill_rect(92,119,9,1,'red')
      fill_rect(99,120,1,1,'red')
      fill_rect(98,121,1,1,'red')
      fill_rect(42,117,1,1,'red')
      fill_rect(43,118,1,1,'red')
      fill_rect(36,119,9,1,'red')
      fill_rect(43,120,1,1,'red')
      fill_rect(42,121,1,1,'red')
      sleep(0.4)
      s=s+randint(1,3)
      n=n-1
      sleep(0.5)
      fill_rect(247,0,82,230,'green')
      sleep(0.2)
      fill_rect(165,0,82,230,'yellow')
      sleep(0.2)
      fill_rect(83,0,82,230,'blue')
      sleep(0.2)
      fill_rect(0,0,83,230,'red')
      sleep(0.6)
      presentoir(1)
    else:
      if keydown(KEY_DOWN)==True:
        fill_rect(220,115,110,10,'yellow')
        fill_rect(90,185,140,10,'yellow')
        fill_rect(220,115,10,80,'yellow')
        fill_rect(80,115,10,80,'yellow')
        fill_rect(80,115,10,80,'yellow')
        fill_rect(0,115,90,10,'yellow')
        fill_rect(82,132,1,1,'red')
        fill_rect(83,133,1,1,'red')
        fill_rect(84,127,1,8,'red')
        fill_rect(85,133,1,1,'red')
        fill_rect(86,132,1,1,'red')
        fill_rect(42,117,1,1,'red')
        fill_rect(43,118,1,1,'red')
        fill_rect(36,119,9,1,'red')
        fill_rect(43,120,1,1,'red')
        fill_rect(42,121,1,1,'red')
        sleep(0.4)
        s=s+randint(1,3)
        n=n-1
        sleep(0.5)
        fill_rect(247,0,82,230,'pink')
        sleep(0.2)
        fill_rect(165,0,82,230,'purple')
        sleep(0.2)
        fill_rect(83,0,82,230,'yellow')
        sleep(0.2)
        fill_rect(0,0,83,230,'green')
        sleep(0.6)
        presentoir(1)
  #Tableau de scores
  fill_rect(0,0,330,230,'black')
  fill_rect(145,110,2,14,'white')
  fill_rect(147,110,6,2,'white')
  fill_rect(147,116,4,2,'white')
  fill_rect(157,110,2,14,'white')
  fill_rect(163,110,2,14,'white')
  fill_rect(175,110,2,14,'white')
  fill_rect(165,110,4,2,'white')
  fill_rect(171,122,4,2,'white')
  fill_rect(169,110,2,14,'white')
  sleep(0.5)
  draw_string("Leave →",245,200)
  print("Votre score est de : ", s,"/", w*3, " points.")
  sleep(10)
game(1)

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.