课堂

admin 2026-07-08 13:02:42









超级点我

import pgzrun,random
WIDTH = 480
HEIGHT = 800
TITLE = "飞机大战"
bg1 = Actor("background")
bg1.x = 480/2
bg1.y = 852/2
bg2 = Actor("background")
bg2.x = 480/2
bg2.y = -852/2
hero = Actor("hero")
hero.x = 400/2
hero.y = 800/2
sun = Actor("bullet")
sun.x = 400
sun.y = -400      #默认不显示
def draw():
    bg1.draw()   #显示
    bg2.draw()   #显示
    hero.draw()  #显示
    sun.draw()   #显示
def on_mouse_move(pos,rel,buttons):
    hero.x = pos[0]    #鼠标的x坐标给到战机
    hero.y = pos[1]
def on_mouse_down():   #当按下鼠标
    sun.x = hero.x     #
    sun.y = hero.y-50
    sounds.gun.play()
def update():   #刷新运动的函数
    if bg1.y >= 852/2+852:   #bg1往下彻底离开屏幕
        bg1.y = -852/2
    if bg2.y >= 852/2+852:   
        bg2.y = -852/2
    bg1.y+=2
    bg2.y+=2
    sun.y -= 15
pgzrun.go()