ITeye博客

The intro.py of Introduction to Pygame Zero

wjason · 2019-02-06 16:29 · Python · 移动开发 · Markdown

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]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。