|
超级新手,刚开始学习,求助,谢谢
############################################
import pygame
from pygame.locals import *
SCREENWIDTH = 822
SCREENHEIGHT = 260
FPS = 30
class MyMap:
def __init__(self, x, y):
self.bg = pygame.image.load("image/bg.png").convert_alpha()
self.x = x
self.y = y
def map_rolling(self):
if self.x < -790:
self.x = 800
else:
self.x -= 5
def map_update(self):
SCREEN.blits(self.bg, (self.x, self.y))
def mainGame(QUIT=None):
score = 0
over = False
global SCREEN, FPSCLOCK
pygame.init()
FPSCLOCK = pygame.time.Clock()
SCREEN = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT))
pygame.display.set_caption('小恐龙')
bg1 = MyMap(0, 0)
bg2 = MyMap(800, 0)
if not over:
bg1.map_update()
bg1.map_rolling()
bg2.map_update()
bg2.map_rolling()
while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()
pygame.display.update()
FPSCLOCK.tick(FPS)
if __name__ == '__main__':
mainGame()
############################################
报错:
C:\Users\15376\PycharmProjects\konglong\venv\Scripts\python.exe C:/Users/15376/PycharmProjects/konglong/main.pypygame 2.0.1 (SDL 2.0.14, Python 3.6.5)Hello from the pygame community. https://www.pygame.org/contribute.htmlTraceback (most recent call last): File "C:/Users/15376/PycharmProjects/konglong/main.py", line 52, in <module> mainGame() File "C:/Users/15376/PycharmProjects/konglong/main.py", line 38, in mainGame bg1.map_update() File "C:/Users/15376/PycharmProjects/konglong/main.py", line 22, in map_update SCREEN.blits(self.bg, (0,0))TypeError: an integer is required (got type tuple)进程已结束,退出代码 1
|
|