以下是部分代码预览:
"""pygame飞扬小鸟.py,这是本人制作的一个版本,角色没有继承pygame.sprite.Sprite."""
__author__ = "李兴球"
__date__ = "2018年7月"
import pygame
from pygame.locals import *
from random import randint
import time
pygame.init()
screenWidth,screenHeight=480,360
screen = pygame.display.set_mode((screenWidth,screenHeight))
pygame.display.set_caption("飞扬小鸟_李兴球版")
class Bird():
def __init__(self,costumeList):
self.costumeId = 0
self.costumeList = costumeList
self.cosutmeAmount = len(costumeList)
self.image = self.costumeList[self.costumeId]
self.rect = self.image.get_rect()
self.rect.x = 100
self.rect.y = 100
self.xspeed = 0
self.yspeed = 3
self.aspeed = 0.5 # 加速度
self.moveStartTime = time.time()
self.costumeStartTime =time.time()
self.delete =0 # 删除标志
pass
class Pipe():
def __init__(self,image,t):
self.type = t # t为up或者down,用于区分上管道和下管道
self.image = image
self.rect = self.image.get_rect()
self.rect.left = screenWidth+1
self.sety()
self.xspeed= -5
self.yspeed = 0
self.moveStartTime = time.time()
self.delete = 0 #待删除标志
pass
def main():
punch = pygame.mixer.Sound("punch.wav")
过音= pygame.mixer.Sound("过.wav")
上管道 = pygame.image.load("上管道.png")
下管道 = pygame.image.load("下管道.png")
背景= pygame.image.load("背景.png")
cosList = []
cosList.append(pygame.image.load("costume1.png"))
cosList.append(pygame.image.load("costume2.png"))
cosList.append(pygame.image.load("costume3.png"))
cosList.append(pygame.image.load("costume4.png"))
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

