import pygame
from pygame.locals import*
def main():
global FPSCLOCK, DISPLAYSURF, BASICFONT, PLAY_SURF, PLAY_RECT, NEW_SURF, NEW_RECT, SOLVE_SURF, SOLVE_RECT
black = (0, 0, 0)
Aqua = (0, 255, 255)
Blue = (0, 0, 255)
Fuchsia = (255, 0, 255)
Gray = (128, 128, 128)
Green =(0, 128, 0)
Lime =(0, 255, 0)
Maroon= (128, 0, 0)
NavyBlue = (0, 0, 128)
Olive =(128, 128, 0)
Purple =(128, 0, 128)
Red= (255, 0, 0)
Silver =(192, 192, 192)
Teal =(0, 128, 128)
White =(255, 255, 255)
Yellow =(255, 255, 0)
ButtonColor= black
textcolor= Red
BASICFONTSIZE = 20
pygame.init()
def makeText(text, color, bgcolor, top, left):
textSurf = BASICFONT.render(text, True, color, bgcolor)
textRect = textSurf.get_rect()
textRect.topleft = (top, left)
return (textSurf, textRect)
FPSCLOCK = pygame.time.Clock()
BASICFONT = pygame.font.Font('freesansbold.ttf', BASICFONTSIZE)
title_screen= pygame.image.load("Journey to Vallhalla.png")
DISPLAYSURF = pygame.display.set_mode((1300, 690))
PLAY_SURF , PLAY_RECT = makeText("Click to Play", textcolor, ButtonColor, 600,400)
title=DISPLAYSURF.blit(title_screen, (0,0))
playb=DISPLAYSURF.blit(PLAY_SURF, PLAY_RECT)
player=pygame.image.load("player.jpg")
playerx=650
playery=520
movex,movey=0,0
while True: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and PLAY_SURF.get_rect(topleft=(600, 400)).collidepoint(pygame.mouse.get_pos()):
player1= DISPLAYSURF.blit(player,(650,520))
DISPLAYSURF.fill(Gray)
if event.type == KEYDOWN:
if event.key==K_LEFT:
movex = -10
elif event.key==K_RIGHT:
movex=+10
elif event.key==K_DOWN:
movey=+10
elif event.key==K_SPACE:
movey=-30
if event.type==KEYUP:
if event.key==K_LEFT:
movex += 10
elif event.key==K_RIGHT:
movex=0
elif event.key==K_DOWN:
movey=0
elif event.key==K_SPACE:
movey=0
movex+=playerx
movey+=playery
pygame.display.update()
を初期化していない、私はこのエラーを取得しています:それは私がpost.dsijklasdvjnkjdlsnvのksdjvkjkjsndlknsdvaを提出できるようになるので、pygame.display.update()エラー:ビデオシステム
Traceback (most recent call last): pygame.display.update() error: video system not initialized I am a pygame noob and do not know how to fix this please help!
は、私は今だけの文章を追加していkksajsdjdvkjlkvnsddlkvndk。 sddvjvkdsvnlskdkdsjvjkvv skdvkvjnskjv
これは私の目的です。私はどのように助けることができないのか分かりません( –