问题是我所能看到的只是运行时的黑屏,认为问题与blitting有关但不是100%确定
#IMPORTING PYGAME
import pygame, sys
from pygame.locals import *
pygame.init()
FPS = 60
fpsClock = pygame.time.Clock()
windowSurface = pygame.display.set_mode((600,400), 0, 32)
pygame.display.set_caption("My Game")
#DIRECTIONS
LEFT = 1
DOWN = 3
UP = 7
RIGHT = 9
#SPEED OF MOVEMENT
MOVESPEED = 4
#COLOURS
WHITE = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
#DRAWING ASSETS/SPRITES
player1 = (windowSurface, pygame.Rect(200, 200, 20, 20), GREEN, UP)
player1.blit(pygame.surface.blit, (200), area=None, special_flags = 0)
player2 = (windowSurface, pygame.Rect(100, 100, 20, 20), GREEN, DOWN)
#player2 = (pygame.Surface.blit(, windowSurface))
barricade1 = {windowSurface:pygame.Rect(50, 5000, 20, 20), :GREEN, :UP}
#barricade1(pygame.Surface.blit(, windowSurface))
barricade2 = {windowSurface:pygame.Rect(250, 250, 20, 20), :GREEN, :DOWN}
#barricade2(pygame.Surface.blit(, windowSurface))
#ball = {'rect':pygame.Rect(200, 200, 20, 20), 'color':GREEN, 'dir':UPDOWNLEFTRIGHT}
#ball(pygame.Surface.blit(, windowSurface))
#SPRITE GROUPS
players = [player1, player2]
barricades = [barricade1, barricade2]
ball = [ball]
windowSurface.fill(WHITE)
pygame.display.update()
fpsclock = pygame.time.Clock
答案 0 :(得分:0)
1。您的WHITE
变量有误。这是RGB格式的黑色。白色是(255,255,255)
2。您正在填写屏幕,然后立即更新它。
首先填满屏幕然后那么你可以将你的玩家吸引到最顶层。
windowSurface.fill(WHITE)
#Do drawing here
pygame.display.update()