如何编写代码,让我的游戏每 30 帧每秒一次通过这些颜色转换?
self.bg_color = 0, 0, 0
self.bg_color = 255, 0, 0
self.bg_color = 0, 255, 0
self.bg_color = 0, 0, 255
self.bg_color = 255, 165, 0
self.bg_color = 255, 255, 0
self.bg_color = 199, 97, 20
编辑:
如果我展示骨架会有帮助吗?
from __future__ import division
import math
import sys
import pygame
class MyGame(object):
def __init__(self):
pygame.mixer.init()
pygame.mixer.pre_init(44100, -16, 2, 2048)
pygame.init()
self.width = 800
self.height = 600
self.screen = pygame.display.set_mode((self.width, self.height))
self.bg_color = 0, 0, 0
self.FPS = 30
self.REFRESH = pygame.USEREVENT+1
pygame.time.set_timer(self.REFRESH, 1000//self.FPS)
def run(self):
running = True
while running:
event = pygame.event.wait()
if event.type == pygame.QUIT:
running = False
elif event.type == self.REFRESH:
self.draw()
else:
pass
def draw(self):
self.screen.fill(self.bg_color)
pygame.display.flip()
MyGame().run()
pygame.quit()
sys.exit()
我一直在寻找一种方法来做到这一点,到目前为止没有运气,这就是我在这里问的原因