pygame动态背景之熊熊大火燃烧场景类

动态背景之熊熊大火燃烧场景,本程序的类是用来做动态背景的

"""动态背景之熊熊大火燃烧场景,本程序的类是用来做动态背景的"""

import time
import pygame
from pygame.locals import *

class Dynamic_background(pygame.sprite.Sprite):
    """动态背景类,把一系列帧图像做为背景不断地显示"""
    
    def __init__(self,images,size):
        """images:已转换成surface的对象列表,size:屏幕尺寸"""
        pygame.sprite.Sprite.__init__(self)
        self.screen_size = size
        self.images = images                   # images是surface列表
        self.image_index = 0                   # 切换造型从0开始
        self.images_amount = len(images)       # 造型数量
        self.image = self.images[0]            # 当前待渲染的图像
        self.rect = self.image.get_rect()      # 获取图像的矩形对象
        self.rect.bottom = self.screen_size[1] # 定位在左下角
        self.interval = 0.1                    # 造型切换间隔时间
        self.start_time = time.time()          # 记录起始时间 

def update(self):
        """超时更换图像"""
         

You must log in to read the rest of this article. Please log in or register as a user.