`

The intro.py of Introduction to Pygame Zero

 
阅读更多

Introduction to Pygame Zero:  

https://pygame-zero.readthedocs.io/en/stable/introduction.html#

 

写道
How to run:
pgzrun intro.py

 

 

alien = Actor('alien')
alien.pos = 100, 56

WIDTH = 500
HEIGHT = alien.height + 20

def draw():
    screen.clear()
    alien.draw()

def update():
    alien.left += 2
    if alien.left > WIDTH:
        alien.right = 0

def on_mouse_down(pos):
    if alien.collidepoint(pos):
        set_alien_hurt()


def set_alien_hurt():
    alien.image = 'alien_hurt'
    sounds.eep.play()
    clock.schedule_unique(set_alien_normal, 1.0)

def set_alien_normal():
    alien.image = 'alien'

 

-----

[The End]

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics