tir_a_la_corde.py

Created by elnix90

Created on March 15, 2023

2.8 KB

Petit jeu à deux rapide quand on s’ennuie. Utilisez les touches [0] et EXE] pour ramener le bâton dans votre camp. Savourez bien l’animation de fin, car j’ai galéré à la faire! Dites moi ce que vous en pensez sur discord: Elnix90#0116


from math import *
from random import *
from kandinsky import *
from time import *
from ion import *
score=[0,0]
fill_rect(0,0,320,222,"black")
fill_rect(163,96,4,30,"white")
while 1:
  X=159
  gagnant=None
  ZERO=False
  EXE =False
  fill_rect(0,0,5,222,"red")
  fill_rect(320,0,-5,222,"blue")
  fill_rect(5,96,310,30,(50,50,50))
  draw_string("[0]",15,205,(randint(0,256),randint(0,256),randint(0,256)),"black")
  draw_string("[EXE]",260,205,(randint(0,256),randint(0,256),randint(0,256)),"black")
  fill_rect(5,90,310,-20,"black")
  sleep(0.3)
  draw_string("3",155,70,"white","black")
  sleep(0.3)
  draw_string("2",155,70,"white","black")
  sleep(0.3)
  draw_string("1",155,70,"white","black")
  sleep(0.3)
  draw_string("GO!",147,70,"white","black")
  sleep(0.3)
  draw_string("   ",147,70,"black","black")
  while 1:
    if keydown(KEY_EXE) or keydown(KEY_ZERO):
      if get_pixel(0,111)==(248,252,248):
        gagnant=True
        score[0]+=1
        break
      if get_pixel(319,111)==(248,252,248):
        gagnant=False
        score[1]+=1
        break
      if keydown(KEY_RIGHTPARENTHESIS):
        fill_rect(X,96,4,30,(50,50,50))
        X+=10
      if keydown(KEY_SEVEN):
        fill_rect(X,96,4,30,(50,50,50))
        X-=10
    if keydown(KEY_ZERO) and ZERO==False:
      draw_string("[0]",15,205,(randint(0,256),randint(0,256),randint(0,256)),"black")
      fill_rect(X,96,4,30,(50,50,50))#################################################
      X-=10##########################################################################
      ZERO=True######################################################################
    if keydown(KEY_EXE) and EXE==False:##############################################
      draw_string("[EXE]",260,205,(randint(0,256),randint(0,256),randint(0,256)),"black")
      fill_rect(X,96,4,30,(50,50,50))
      X+=10
      EXE=True
    if not keydown(KEY_ZERO):
      ZERO=False
    if not keydown(KEY_EXE):
      EXE=False
    fill_rect(X,96,4,30,"white")
  t=0.001
  if gagnant==True:
    x=0
    y=96
    y_=30
    for i in range(316):
      fill_rect(x,96,1,30,"red")
      sleep(t)
      x+=1
    x=5
    for i in range(306):
      fill_rect(315,y,5,y_,"red")
      fill_rect(5,96,x,30,(50,50,50))
      y-=1
      y_+=2
      x+=1
      sleep(t)
  elif gagnant==False:
    x=320
    y=96
    y_=30
    for i in range(316):
      fill_rect(x,96,1,30,"blue")
      sleep(t)
      x-=1
    x=0
    for i in range(311):
      fill_rect(0,y,5,y_,"blue")
      fill_rect(315,96,x,30,(50,50,50))
      y-=1
      y_+=2
      x-=1
      sleep(t)
  draw_string("REJOUER:",90,70,"green","black")
  draw_string("[OK]",180,70,(255,0,255),"black")
  while keydown(KEY_OK):True
  while not keydown(KEY_OK):True
  draw_string(str(score[0]),15,10,"red","black")
  draw_string(str(score[1]),290,10,"blue","black")

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.