flappy_bird.py

Created by marius-layan

Created on February 05, 2024

2.52 KB

Voici une reconstitution du jeu Flappy Bird, le but est simple: on incarne un petit oiseaux jaune qui doit éviter les tuileaux vert, sinon c’est Game Over.

pour sauter: EXE

BON JEU !


from random import *
from kandinsky import *
from ion import *
from time import *
blue=(176,180,248)
while True:
  a,i,p,c,d,score=[randint(30,142) for i in range(3)],[320,427,534],130,0,0,0;fill_rect(0,0,320,222,blue)
  while True:
    if get_pixel(30,0)==blue and d==1:score+=1;d=0
    if get_pixel(30,0)==(80,192,0):d=1
    fill_rect(30,int(p),15,15,'yellow');fill_rect(36,int(p),9,10,'white');fill_rect(40,int(p)+3,3,6,'black');fill_rect(42,int(p)+8,10,8,'orange');fill_rect(30,int(p)-1,15,1,blue);fill_rect(45,int(p)+7,7,1,blue);p+=0.75
    if keydown(KEY_OK):fill_rect(30,int(p),15,15,blue);fill_rect(42,int(p)+12,10,5,blue);p-=5;fill_rect(30,int(p),15,15,'yellow');fill_rect(36,int(p),9,10,'white');fill_rect(40,int(p)+3,3,6,'black');fill_rect(42,int(p)+8,10,8,'orange')
    if i[0]==-30: i[0],a[0]=320,randint(30,142)
    fill_rect(i[0],0,30,a[0],'green');fill_rect(i[0]+30,0,1,a[0],blue);fill_rect(i[0],a[0]+70,30,320-a[0],'green');fill_rect(i[0]+30,a[0]+70,1,320-a[0],blue);i[0]-=1
    if i[1]==-30: i[1],a[1]=320,randint(30,142)
    fill_rect(i[1],0,30,a[1],'green');fill_rect(i[1]+30,0,1,a[1],blue);fill_rect(i[1],a[1]+70,30,320-a[1],'green');fill_rect(i[1]+30,a[1]+70,1,320-a[1],blue);i[1]-=1
    if i[2]==-30: i[2],a[2]=320,randint(30,142)
    fill_rect(i[2],0,30,a[2],'green');fill_rect(i[2]+30,0,1,a[2],blue);fill_rect(i[2],a[2]+70,30,320-a[2],'green');fill_rect(i[2]+30,a[2]+70,1,320-a[2],blue);i[2]-=1
    if p>208 or p<0 or get_pixel(30,int(p))==(80,192,0) or get_pixel(45,int(p))==(80,192,0) or get_pixel(30,int(p)+15)==(80,192,0) or get_pixel(52,int(p)+15)==(80,192,0) or get_pixel(52,int(p)+8)==(80,192,0):break
    sleep(0.011)
  sleep(0.2);a,b=0,0;fill_rect(0,0,320,222,'black');draw_string("REJOUER",125,100,'yellow','black');draw_string(" oui ",135,150,'black','green');draw_string(" non ",135,180,'white','black');draw_string("score: "+str(int(score)),2,202,'yellow','black')
  while keydown(KEY_OK)==False:
    if b==0:c=0
    if b==254:c=1
    if c==0:b+=2
    else:b-=2
    draw_string("GAME  OVER",110,40,(255,b,b),'black')
    if keydown(KEY_UP) and a==1:draw_string(" oui ",135,150,'black','green');draw_string(" non ",135,180,'white','black');a=0
    if keydown(KEY_DOWN) and a==0:draw_string(" oui ",135,150,'white','black');draw_string(" non ",135,180,'black','green');a=1
  while keydown(KEY_OK):
    if a==0:draw_string(" oui ",135,150,'gray',(50,130,0));draw_string(" non ",135,180,'white','black')
    if a==1:draw_string(" oui ",135,150,'white','black');draw_string(" non ",135,180,'gray',(50,130,0))
  if a==1:break