I'm trying to create a very simple space invaders pygame for my Python class. I haven't got anywhere far yet but I keep receiving image loading errors when I try to test out the code. I am using Python 2.7 with Pycharm. This is my source code.
import pygame
from pygame.locals import *
pygame.init()
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
player = pygame.image.load("spacecraft.png")
#infinite loop
while 1:
screen.fill(0)
screen.blit(player, (100,100))
pygame.display.flip()
#loop though the events
for event in pygame.event.get():
if event.type == pygame.QUIT:
#if it is quit the game
pygame.quit()
exit()
Again this only should show a black screen with a picture of a spaceship in those coordinates. However, when I test it out the program shows this error:
libpng warning: Application built with libpng-1.6.23 but running with 1.5.4
line 9, in <module>
player = pygame.image.load("spacecraft.png")
pygame.error: Couldn't allocate memory for PNG file or incompatible PNG dll
I have tried re-installing Pygame, Python, and also tried using os to correctly path the image. The path to the image is root so I checked that off my checklist. I also downloaded libpng.1.6.16 but that didn't work either. Is there a way for me to fix this? BTW I'm not familiar with memory management. If you need any more information I will try to answer the best I can.
Thanks in advance!!