stick_fighter.py

Created by marius-layan

Created on February 05, 2024

3.58 KB

Ce jeu est une reconstitution simple du jeu Street-fighter, un jeu d’arcade de combat. C’est un jeu à 2 et le but et d’éliminer le joueur adverse (barre de vie visible en haut).

Joueur 1: •gauche[ZERO] •droite[DOT] •coup de point[ONE] •sauter[TWO]

Joueur 2: •gauche[ANS] •droite[EXE] •coup de point[PLUS] •sauter[MINUS]

BON JEU !


from kandinsky import *
from ion import *
from time import *
def font():
  fill_rect(0,170,320,52,'gray');fill_rect(0,160,320,10,(100,100,100));fill_rect(0,145,320,15,(130,130,130))
  for i in range(4):fill_rect(0+i*80,195,40,4,'white')
  for k in range(6):
    if k%2==0:
      fill_rect(0+k*60,80,60,65,(110,110,110));fill_rect(0+k*60,75,60,5,(100,100,100));fill_rect(0+k*60,70,60,5,'gray');fill_rect(20+k*60,50,5,20,'gray')
      for j in range(3):
        for i in range(3):fill_rect(4+i*18+k*60,85+j*20,10,15,(150,150,255))
    else:
      fill_rect(0+k*60,45,60,100,(100,100,100));fill_rect(0+k*60,40,60,5,(90,90,90));fill_rect(0+k*60,35,60,5,(130,130,130));fill_rect(20+k*60,20,5,15,(130,130,130));fill_rect(28+k*60,25,4,10,(130,130,130))
      for j in range(5):
        for i in range(4):fill_rect(4+i*14+k*60,50+j*18,8,12,(150,150,255))
def p1():
  global cmt1,y3,pv2
  if jump1==0:
    fill_rect(x1,int(y1),15,15,'orange');fill_rect(x1+5,int(y1)+15,5,20,'orange')
    for i in range(10):fill_rect(x1+5-i,int(y1)+35+i*2,5,2,'orange');fill_rect(x1+5+i,int(y1)+35+i*2,5,2,'orange')
    if h1==1 and d1==0:
      a=0
      for i in range(10):
        if get_pixel(x1+10+i*2,int(y1)+20)==(0,0,248):a=1
      if a==1:a=0;pv2-=1;pv()
      fill_rect(x1+10,int(y1)+20,20,5,'orange')
    if h1==1 and d1==1:
      a=0
      for i in range(10):
        if get_pixel(x1+5-i*2,int(y1)+20)==(0,0,248):a=1
      if a==1:a=0;pv2-=1;pv()
      fill_rect(x1+5,int(y1)+20,-20,5,'orange')
  else:fill_rect(x1,int(y1)+10,20,20,'orange');cmt1+=1
def p2():
  global cmt2,y4,pv1
  if jump2==0:
    fill_rect(x2,int(y2),15,15,'blue');fill_rect(x2+5,int(y2)+15,5,20,'blue')
    for i in range(10):fill_rect(x2+5-i,int(y2)+35+i*2,5,2,'blue');fill_rect(x2+5+i,int(y2)+35+i*2,5,2,'blue')
    if h2==1 and d2==0:
      a=0
      for i in range(10):
        if get_pixel(x2+5-i*2,int(y2)+20)==(248,132,24):a=1
      if a==1:a=0;pv1-=1;pv()
      fill_rect(x2+5,int(y2)+20,-20,5,'blue')
    if h2==1 and d2==1:
      a=0
      for i in range(10):
        if get_pixel(x2+10+i*2,int(y2)+20)==(248,132,24):a=1
      if a==1:a=0;pv1-=1;pv()
      fill_rect(x2+10,int(y2)+20,20,5,'blue')
  else:fill_rect(x2,int(y2)+10,20,20,'blue');cmt2+=1
def pv():
  fill_rect(8,3,24,24,'black');fill_rect(32,3,122,12,'black');fill_rect(10,5,20,20,'orange');fill_rect(32,5,pv1*2,8,'green');fill_rect(288,3,24,24,'black');fill_rect(166,3,122,12,'black');fill_rect(290,5,20,20,'blue');fill_rect(288-pv2*2,5,pv2*2,8,'green')
x1,x2,y1,y2,h1,h2,d1,d2,jump1,jump2,cmt1,cmt2,pv1,pv2=80,200,140,140,0,0,0,0,0,0,1,1,60,60
fill_rect(0,0,320,100,(150,150,255))
font();p1();p2();pv()
while True:
  if keydown(KEY_DOT) and x1!=300:
    if d1==1:d1=0
    x1+=4
  if keydown(KEY_ZERO) and x1!=4:
    if d1==0:d1=1
    x1-=4
  if keydown(KEY_ONE):h1=1
  else:h1=0
  if keydown(KEY_TWO) and jump1==0:jump1,y3=1,y1
  if jump1==1:
    y1=-8*cmt1+((cmt1**(2))/(4))+y3
    if int(y1)==140:jump1,y1,cmt1=0,140,1
  if keydown(KEY_EXE) and x2!=300:
    if d2==0:d2=1
    x2+=4
  if keydown(KEY_ANS) and x2!=4:
    if d2==1:d2=0
    x2-=4
  if keydown(KEY_PLUS):h2=1
  else:h2=0
  if keydown(KEY_MINUS) and jump2==0:jump2,y4=1,y2
  if jump2==1:
    y2=-8*cmt2+((cmt2**(2))/(4))+y4
    if int(y2)==140:jump2,y2,cmt2=0,140,1
  font();p1();p2()
  if jump1==1:cmt1-=1
  p1();sleep(0.05)
  if pv1==0 or pv2==0:break
fill_rect(0,0,320,222,'black');fill_rect(4,4,152,214,'orange');fill_rect(164,4,152,214,'blue')
if pv1==0:draw_string("YOU LOSE",40,100,'white','orange');draw_string("YOU WIN",200,100,'white','blue')
else:draw_string("YOU WIN",40,100,'white','orange');draw_string("YOU LOSE",200,100,'white','blue')

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.