Quellcode durchsuchen

Game(dash)

master
valdoucet vor 3 Jahren
Ursprung
Commit
647e5116b3
1 geänderte Dateien mit 15 neuen und 13 gelöschten Zeilen
  1. +15
    -13
      game/code.py

+ 15
- 13
game/code.py Datei anzeigen

@@ -8,10 +8,11 @@ tb = Actor("bottom", midtop=(490, 350))
th = Actor("top", midbottom=(490, 125)) th = Actor("top", midbottom=(490, 125))
didi = Actor("bird1", (245, 245)) didi = Actor("bird1", (245, 245))
end = 0 end = 0
gravitée = 2
saut = -35
saut = -7
gravite = 0.2
frotement = 1
gamemod_speed = -3 gamemod_speed = -3
flash = -30
dash = 0
espassement = 1 espassement = 1


def draw(): def draw():
@@ -21,7 +22,7 @@ def draw():
tb.draw() tb.draw()


def update(): def update():
global end
global end, saut, gamemod_speed, dash
if didi.y == 475 and end == 0: if didi.y == 475 and end == 0:
print("--Game over--") print("--Game over--")
@@ -32,9 +33,9 @@ def update():
tb.x += gamemod_speed tb.x += gamemod_speed


if th.x <= 0: if th.x <= 0:
tb.x = 490
tb.x = 490
tb.y = random.randrange(520,600) tb.y = random.randrange(520,600)
th.x = 490
th.x = 490
th.y = random.randrange(-160, -40) th.y = random.randrange(-160, -40)


if didi.y <= 15: if didi.y <= 15:
@@ -45,18 +46,19 @@ def update():
end = 1 end = 1


if didi.y < 475 and end == 0 : if didi.y < 475 and end == 0 :
didi.y += gravitée
didi.y += saut
saut += gravite
gamemod_speed += dash


if dash < 0 and end == 0:
dash += frotement


def on_mouse_down(button): def on_mouse_down(button):
global saut, dash
if button == mouse.LEFT: if button == mouse.LEFT:
didi.y += saut
saut += -5
elif button == mouse.RIGHT: elif button == mouse.RIGHT:
th.x += flash
tb.x += flash
dash += -1




pgzrun.go() pgzrun.go()

Laden…
Abbrechen
Speichern