Python Forum
[pyGame] Load Image, Problem Found !
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[pyGame] Load Image, Problem Found !
#3
  • nothing should reside after pygame.quit() and sys.exit(). That is the end of the game.
  • you should only have one event loop, not two
  • you should only have one game loop, you should only have to type pygame.display.update() once in the whole game...even if it as big as minecraft. 
  • never load your images in your game loop as well as .convert() them to make it faster
  • You should probably make a package and put the image in a sub-directory of the root python script, not on your directory in your desktop. 
import pygame
import sys
  
screen = pygame.display.set_mode((800,600))
done = False
img = pygame.image.load(os.path.join('C:/Users/Gebruiker/Desktop/Renders', 'Render.png')).convert()
   
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                done = True
            elif event.key == pygame.K_SPACE:
                pass #do something
                 
    
    screen.fill((255,255,255))
    pygame.display.update()
pygame.quit()
sys.exit()
Recommended Tutorials:
Reply


Messages In This Thread
RE: [pyGame] Load Image, Problem Found ! - by metulburr - Sep-29-2017, 06:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with pygame.event.clear qq12346 1 2,246 Oct-05-2023, 08:39 AM
Last Post: patriciainman
  pygame double jump problem Yegor123 2 2,817 Nov-20-2022, 07:23 PM
Last Post: Yegor123
  Pygame Zero - no actor image toiling_away 2 2,013 Oct-14-2022, 12:16 AM
Last Post: toiling_away
  [PyGame] Sprite image rotation problem XavierPlatinum 4 2,559 Jul-25-2022, 01:31 PM
Last Post: Ruslan8819
  How to make an image move in relation to another in PYGAME CompleteNewb 1 2,419 Nov-10-2021, 03:38 PM
Last Post: metulburr
  (HELP GREATLY APPRECIATED) New user- Huge Pygame Installation Problem! Jbomb 1 2,957 Jan-12-2021, 07:32 PM
Last Post: MK_CodingSpace
  problem with pygame Aladdin 3 4,329 Jun-25-2020, 01:41 PM
Last Post: Aladdin
  pygame module not found on Idle after installing on Mac crunchypen 1 3,624 May-09-2020, 11:03 PM
Last Post: metulburr
  Pycharm dosnt load pygame Matres 1 2,073 Mar-16-2020, 02:15 AM
Last Post: Larz60+
  open cv ->pygame: turn image into location Gamedeveloper 1 2,158 Jan-20-2020, 05:00 PM
Last Post: michael1789

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020