Reputation: 71
Im learning Pygame and I cannot understand how I can possibly screw this up. All I get is a black screen.
import pygame, sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((640,360),0,32)
pygame.display.set_caption("Game!")
bg = pygame.image.load("graphics/bg.bmp").convert()
chris = pygame.image.load("graphics/chris.bmp").convert_alpha()
x,y=0,0
movex, movey=0,0
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key==K_LEFT:
movex=-1
elif event.key==K_RIGHT:
movex=+1
elif event.key==K_UP:
movey=-1
elif event.key==K_DOWN:
movey=+1
if event.type==KEYUP:
if event.key==K_LEFT:
movex=0
elif event.key==K_RIGHT:
movex=0
elif event.key==K_UP:
movey=0
elif event.key==K_DOWN:
movey=0
x+=movex
y+=movey
screen.blit(bg, (0,0))
screen.blit(chris, (100, 100))
pygame.display.update
All I get from this is a black screen. The bg.bmp is a grey background image and chris is a character with the same background. This is taken from theNewBostons tutorial. Copied everything. I have Python 2.7 and Pygame 1.9.2 64bit
Please help :)
Upvotes: 0
Views: 73
Reputation: 156158
This:
pygame.display.update
Should perhaps be:
pygame.display.update()
# ^^
without the parentheses; python looks up the update
attribute on display
, but doesn't do anything more; with the parentheses, it then calls the attribute it found.
Upvotes: 7