Re: library not initialized (pygame)
Could you share the traceback / error that you are seeing? On Sun, May 02, 2021 at 03:23:21PM -0400, Quentin Bock wrote: Code: #imports and variables for game import pygame from pygame import mixer running = True #initializes pygame pygame.init() #creates the pygame window screen = pygame.display.set_mode((1200, 800)) #Title and Icon of window pygame.display.set_caption("3.02 Project") icon = pygame.image.load('3.02 icon.png') pygame.display.set_icon(icon) #setting up font pygame.font.init() font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16) font_x = 10 font_y = 40 items_picked_up = 0 items_left = 3 def main(): global running, event #Game Loop while running: #sets screen color to black screen.fill((0, 0, 0)) #checks if the user exits the window for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() def display_instruction(x, y): instructions = font.render("Each level contains 3 items you must pick up in each room.", True, (255, 255, 255)) instructions_2 = font.render("When you have picked up 3 items, you will advance to the next room, there are 3.", True, (255, 255, 255)) instructions_3 = font.render("You will be able to change the direction you are looking in the room, this allows you to find different objects.", True, (255, 255, 255)) clear = font.render("Click to clear the text.", True, (255, 255, 255)) screen.blit(instructions, (10, 40)) screen.blit(instructions_2, (10, 60)) screen.blit(instructions_3, (10, 80)) screen.blit(clear, (10, 120)) if event.type == pygame.MOUSEBUTTONDOWN: if event.type == pygame.MOUSEBUTTONUP: screen.fill(pygame.Color('black')) # clears the screen text display_instruction(font_x, font_y) pygame.display.update() main() the error apparently comes from the first instructions variable saying library not initialized not sure why, its worked before but not now :/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: library not initialized (pygame)
On Sunday, 2 May 2021 at 21:04:40 UTC+1, Michael Torrie wrote: > On 5/2/21 1:23 PM, Quentin Bock wrote: > > the error apparently comes from the first instructions variable saying > > library not initialized not sure why, its worked before but not now :/ > I don't get that error on my Fedora 32 machine. The script ultimately > doesn't run because it can't find the icon png file. But the window > briefly appears and it seems like pygame is being initialized properly. i have the same problem currently have you found a solution by chance. -- https://mail.python.org/mailman/listinfo/python-list
library not initialized pygame
code: #imports and variable for loop import pygame running = True #initializes pygame pygame.init() pygame.mixer.init() pygame.font.init() #creates the pygame window screen = pygame.display.set_mode((1200, 800)) #Title and Icon of window pygame.display.set_caption("3.02 Project") icon = pygame.image.load('3.02 icon.png') pygame.display.set_icon(icon) #setting up font pygame.font.init() font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16) font_x = 10 font_y = 40 items_picked_up = 0 items_left = 3 def main(): global running, event #Game Loop while running: #sets screen color to black screen.fill((0, 0, 0)) #checks if the user exits the window for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() def music(): pygame.mixer.init() pygame.font.init() pygame.mixer.music.load('onoken - load.mp3') #places song into queue pygame.mixer.music.play(10, 0, 3) #fist number indicates the loop amount, second is the offset of the song, third is fading the song in song_text = font.render("Song: onoken - load", True, (255, 255, 255)) screen.blit(song_text, (10, 750)) music() def display_instruction(x, y): pygame.font.init() pygame.mixer.init() instructions = font.render("Each level contains 3 items you must pick up in each room.", True, (255, 255, 255)) instructions_2 = font.render("When you have picked up 3 items, you will advance to the next room, there are 3.", True, (255, 255, 255)) instructions_3 = font.render("You will be able to change the direction you are looking in the room, this allows you to find different objects.", True, (255, 255, 255)) screen.blit(instructions, (10, 40)) screen.blit(instructions_2, (10, 60)) screen.blit(instructions_3, (10, 80)) display_instruction(font_x, font_y) pygame.display.update() main() if you try to run this, I'm aware that the icon and music file will not load because you don't have the file on your device, but if it somehow works for you please let me know, and if you think there's any difference between my code and when you ran it I need this figured out. Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: library not initialized (pygame)
On 5/2/21 1:23 PM, Quentin Bock wrote: > the error apparently comes from the first instructions variable saying > library not initialized not sure why, its worked before but not now :/ I don't get that error on my Fedora 32 machine. The script ultimately doesn't run because it can't find the icon png file. But the window briefly appears and it seems like pygame is being initialized properly. -- https://mail.python.org/mailman/listinfo/python-list
library not initialized (pygame)
Code: #imports and variables for game import pygame from pygame import mixer running = True #initializes pygame pygame.init() #creates the pygame window screen = pygame.display.set_mode((1200, 800)) #Title and Icon of window pygame.display.set_caption("3.02 Project") icon = pygame.image.load('3.02 icon.png') pygame.display.set_icon(icon) #setting up font pygame.font.init() font = pygame.font.Font('C:\Windows\Fonts\OCRAEXT.ttf', 16) font_x = 10 font_y = 40 items_picked_up = 0 items_left = 3 def main(): global running, event #Game Loop while running: #sets screen color to black screen.fill((0, 0, 0)) #checks if the user exits the window for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() def display_instruction(x, y): instructions = font.render("Each level contains 3 items you must pick up in each room.", True, (255, 255, 255)) instructions_2 = font.render("When you have picked up 3 items, you will advance to the next room, there are 3.", True, (255, 255, 255)) instructions_3 = font.render("You will be able to change the direction you are looking in the room, this allows you to find different objects.", True, (255, 255, 255)) clear = font.render("Click to clear the text.", True, (255, 255, 255)) screen.blit(instructions, (10, 40)) screen.blit(instructions_2, (10, 60)) screen.blit(instructions_3, (10, 80)) screen.blit(clear, (10, 120)) if event.type == pygame.MOUSEBUTTONDOWN: if event.type == pygame.MOUSEBUTTONUP: screen.fill(pygame.Color('black')) # clears the screen text display_instruction(font_x, font_y) pygame.display.update() main() the error apparently comes from the first instructions variable saying library not initialized not sure why, its worked before but not now :/ -- https://mail.python.org/mailman/listinfo/python-list