소스 검색

invincible en cours

Chap3-challenge-physique-inversée
Alain Somville 3 년 전
부모
커밋
875784c9c1
1개의 변경된 파일35개의 추가작업 그리고 7개의 파일을 삭제
  1. +35
    -7
      birdie.py

+ 35
- 7
birdie.py 파일 보기

@@ -4,17 +4,44 @@ TITLE = "Paf l'oiseau"
WIDTH = 400
HEIGHT = 708

def on_mouse_down():
print('Clic souris !')
titi.y -= 50
def on_mouse_down(button):
if (titi.vivant):
print('Clic souris !')
titi.speed = -6.5

def on_key_down(key):
if key == keys.A:
titi.invincible = True
print('vivant !!')
def reset():
print("Retour au départ...")
titi.invincible = False
titi.vivant = True
titi.image = "bird1"
titi.speed = 1
titi.center = (75, 50)
tube_superieur.center = (300, 0)
tube_inferieur.center = (300, tube_superieur.height + ecart)

def heurte_tube():
print("Paf l'oiseau!")
if titi.invincible == False:
titi.image = "birddead"
titi.vivant = False

def update():
titi.speed += gravite
titi.y += titi.speed
tube_superieur.x -= vitesse_defilement
tube_inferieur.x -= vitesse_defilement
if tube_superieur.right < 0 :
tube_superieur.left = WIDTH
tube_inferieur.left = WIDTH
if titi.y > HEIGHT or titi.y < 0:
reset()
if (titi.colliderect(tube_superieur)) or (titi.colliderect(tube_inferieur)):
heurte_tube()
titi.vivant = False

def draw():
screen.blit('background', (0, 0))
@@ -22,12 +49,13 @@ def draw():
tube_superieur.draw()
tube_inferieur.draw()

titi = Actor('bird1', (75, 350))
titi.speed = 1
titi = Actor('bird1')
ecart = 140
tube_superieur = Actor('top', (300, 0))
tube_inferieur = Actor('bottom', (300, tube_superieur.height + ecart))
tube_superieur = Actor('top')
tube_inferieur = Actor('bottom')
vitesse_defilement = 1
gravite = 0.3
reset()

# print(tube_superieur.width, tube_superieur.height)



불러오는 중...
취소
저장