Reputation:
I am using Pygame in Python 3.6.5 on win32, and my MarioGround.png is not showing up. I have two images yet, one of them is working and the other one isn't. I am getting no errors, either. Here is my complete code yet (to be worked on):
import pygame
pygame.init()
black = (0,0,0)
white = (255,255,255)
red = (255,0,0)
blue = (0,0,255)
sky_blue = (0,150,225)
green = (0,255,0)
displayWidth = 800
displayHeight = 600
#Final :- pygame.display.set_mode((1365, 1050))
gameDisplay = pygame.display.set_mode((displayWidth,displayHeight))
pygame.display.set_caption('Super Mario')
clock = pygame.time.Clock()
crashed = False
timeOut = False
Quit = False
#50,75
marioStanding = pygame.image.load('Super_Mario_Standing2.png').convert()
marioStanding = pygame.transform.scale(marioStanding, (displayWidth//16,displayHeight//8))
ground = pygame.image.load('MarioGround.png')
def Stand(mx,my):
gameDisplay.blit(marioStanding,(mx,my))
mx = (displayWidth * 0.45)
my = (displayHeight * 0.8)
def makeGround(gx,gy):
gameDisplay.blit(ground,(gx,gy))
gx = (displayHeight * 0.45)
gy = (displayWidth * 0.8)
while not crashed and not timeOut and not Quit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
Quit = True
print (event)
gameDisplay.fill(sky_blue)
makeGround(gx,gy)
Stand(mx,my)
pygame.display.update()
clock.tick(24)
pygame.quit()
quit()
My Super_Mario_Standing2.png is appearing, though MarioGround.png is not. Here as links to both of them: MarioGround.png: https://drive.google.com/open?id=1Jz7zTI5Cukv8fXlmyOEkwJTOTkuxIGUP
Super_Mario_Standing.png: https://drive.google.com/open?id=1eUDAin-BUUzi6l-DgxHrf9v8JP8kdAPt
Thank you!!!
Upvotes: 2
Views: 44
Reputation: 20438
You've mixed up the displayWidth
and displayHeight
variables and that means the gy
variable is 640 (below the screen). Just swap them (also, there's no need for parentheses here):
gx = displayWidth * 0.45
gy = displayHeight * 0.8
Upvotes: 1