---
title: "The intro.py of Introduction to Pygame Zero"
author: "wjason"
date: "2019-02-06T16:29:51Z"
tags: []
categories: ["移动开发"]
slug: "the-intro-py-of-introduction-to-pygame-zero"
draft: false
lastmod: "2019-02-06T16:29:51Z"
id: 2437379
url: "https://wjason.iteye.com/blog/2437379"
---

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]