Reputation: 51
I'm in the early stages of trying to build a simple game right now and I've checked my code over and over and can't seem to find the issue, in addition I'm really not good at coding but I'm trying to learn. In my program I should be able to see a race car image that I made myself in paint but all I see is a white screen :( please help
import pygame
pygame.init()
display_width= 900
display_height=600
black= (0,0,0)
white= (255,255,255)
red= (255,0,0)
gameDisplay= pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('Race Car')
clock = pygame.time.Clock()
carImg = pygame.image.load('C:/Users/Zack\'s PC/Pictures/gameimages/racecarimage.png')
def car(x,y):
gameDisplay.blit(carImg,(x,y))
x = (display_height * 0.45)
y = (display_width * 0.8)
crashed = False
while not crashed:
for event in pygame.event.get():
if event.type == pygame.QUIT:
crashed = True
gameDisplay.fill(white)
car(x, y)
pygame.display.update()
clock.tick(60)
pygame.quit()
quit()
Upvotes: 0
Views: 57
Reputation: 2779
You have the x and y co-ordinates set incorrectly. You are using height with the x and width with the y and it should be the other way around. You have:
x = (display_height * 0.45)
y = (display_width * 0.8)
It should be:
y = (display_height * 0.45)
x = (display_width * 0.8)
Upvotes: 1