Reputation:
I'm currently working on a game with pygame, in python 3.7.2. I got a strange error when I run my program. This is the full traceback:
hello from the 1st lign of this code :D
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "C:\Users\-------\----------\---------\WIP\newfile.py", line 69, in <module>
Window('load')
File "C:\Users\-------\----------\---------\WIP\newfile.py", line 52, in Window
bg32 = pygame.load('sprites/bg32.png').convert_alpha()
AttributeError: module 'pygame' has no attribute 'load'
It's really strange because 'load' function is a really basic and import function of pygame... So this is my code (full), I still don't understand what's wrong here:
print('hello from the 1st lign of this code :D')
import time
spb = time.time()
import pygame
import os, sys
pygame.init()
os.environ['SDL_VIDEO_CENTERED'] = '1'
Very_Dark_Blue = ( 0, 0, 64)
barPos = (0, 0)
barSize = (400, 40)
borderColor = ( 0, 0, 0,)
max_a = 10000
a=0
screen=pygame.display.set_mode((1,1), pygame.NOFRAME)
def text(show_text, show_size, show_color, show_x, show_y):
fontObj = pygame.font.Font('Display_Font.ttf',show_size)
Load_text = fontObj.render(show_text,True,show_color,None)
render_text = Load_text.get_rect()
render_text.center = (show_x,show_y)
screen.blit(Load_text,render_text)
def image(name,x,y):
screen.blit(name,(x,y))
def DrawBar(pos, size, borderC, barC, progress):
global screen
pygame.draw.rect(screen, borderC, (*pos, *size), 1)
innerPos = (pos[0]+3, pos[1]+3)
innerSize = ((size[0]-6) * progress, size[1] - 6)
pygame.draw.rect(screen, barC, (*innerPos, *innerSize))
def Window(w):
global screen,a,max_a,barPos,barSize,Very_Dark_Blue,borderColor
if w == 'load':
screen=pygame.display.set_mode((400,40), pygame.NOFRAME)
bg32 = pygame.load('sprites/bg32.png').convert_alpha()
while w == 'load':
image(bg32,0,0)
DrawBar(barPos, barSize, borderColor, Very_Dark_Blue, a/max_a)
pygame.display.update()
a = a + 1
if a == max_a:
Window('main')
if w == 'main':
pygame.quit
screen=pygame.display.set_mode((1920,1080), pygame.NOFRAME)
while w == 'main':
image(background,0,0)
image(title,100,0)
pygame.display.update()
Window('load')
background = pygame.image.load('sprites/Background.png').convert_alpha()
title = pygame.image.load('sprites/Title.png').convert_alpha()
I hope someone will find the problem :D
Upvotes: 0
Views: 3165