SnakesBite
Still Fresh
- Joined
- Nov 10, 2012
- Messages
- 3
Hi, I am new to pygame and trying to start off simple. The background image only covers a very small amount of the screen at the top left. In other small programs it has covered the whole screen. Can anyone help to see the problem in my code affecting my background please.
import pygame, sys, random
from pygame.locals import *
pygame.init()
FPS = 30
fpsClock = pygame.time.Clock()
gameSurface = pygame.display.set_mode((640, 480))
pygame.display.set_caption('beginner')
bgImg = pygame.image.load("space_invaders\space_image.png").convert()
shipImg = pygame.image.load('ship.bmp').convert()
position = shipImg.get_rect().move(random.randrange(640), 479)
while True:
gameSurface.blit(bgImg, (0,0))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
# keyboard inputs
if event.key == K_LEFT:
position = position.move(-1, 0)
if event.key == K_RIGHT:
position = position.move(1, 0)
gameSurface.blit(shipImg, position)
pygame.display.update()
fpsClock.tick(FPS)
import pygame, sys, random
from pygame.locals import *
pygame.init()
FPS = 30
fpsClock = pygame.time.Clock()
gameSurface = pygame.display.set_mode((640, 480))
pygame.display.set_caption('beginner')
bgImg = pygame.image.load("space_invaders\space_image.png").convert()
shipImg = pygame.image.load('ship.bmp').convert()
position = shipImg.get_rect().move(random.randrange(640), 479)
while True:
gameSurface.blit(bgImg, (0,0))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
# keyboard inputs
if event.key == K_LEFT:
position = position.move(-1, 0)
if event.key == K_RIGHT:
position = position.move(1, 0)
gameSurface.blit(shipImg, position)
pygame.display.update()
fpsClock.tick(FPS)
Last edited by a moderator: