1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| from p5 import *
liste=0
x_chariot=26
y_chariot=510
pas_chariot=11
chariot_en_vie=True
x_banane=400
y_banane=26
pas_banane=10
banane_en_vie=True
tempo=400
def setup():
global fond
global chariot
global banane
createCanvas(926, 717)
fond=loadImage("https://capytale2.ac-paris.fr/web/sites/default/files/2023/11-02/14-49-20/8800560.jpg")
chariot=loadImage("https://capytale2.ac-paris.fr/web/sites/default/files/2023/11-02/15-01-28/chariot.png")
banane=loadImage("https://capytale2.ac-paris.fr/web/sites/default/files/2023/11-02/15-01-28/banana.png")
def draw():
global x_chariot,pas_chariot,y_chariot,chariot_en_vie,x_banane,pas_banane,y_banane,banane_en_vie
if chariot_en_vie:
if x_chariot>900-chariot.width:
pas_chariot = -pas_chariot
if x_chariot<26:
pas_chariot=-pas_chariot
x_chariot=x_chariot+pas_chariot
#if banane_en_vie:
if mouseIsPressed :
if tempo== True:
# tempo=True #tempo pour éviter les tirs en rafale
if y_banane>650-banane.width:
pas_banane = -pas_banane
#if y_banane<26:
pas_banane=-pas_banane
y_banane=y_banane+pas_banane
background(fond)
#global banane
#image(banane,380,20)
if chariot_en_vie:
image(chariot,x_chariot,y_chariot)
if banane_en_vie:
image(banane,x_banane,y_banane)
#image(banane,mouseX - banane.width/2,mouseY-banane.height/2)
run() |
Partager