1

I am making a game, but it doesn't work. I am new to pygame, so I think I did somenthing stupid in my code. (It opens the pygame window, but just doesn't work.)

the code in question:

from pygame import image import time import os import subprocess import pygame from pygame.locals import* from pygame import mixer pygame.event.pump def image(imagename): img = pygame.image.load(imagename) black = (0, 0 ,0 ) w = 1251 h = 584 screen = pygame.display.set_mode((w, h)) screen.fill((black)) running = 1 while running: screen.fill((black)) screen.blit(img,(0,0)) pygame.display.flip() def backstory(): pygame.init; image(imagename='backtory.') time.sleep(25) def title(): pygame.init() image(imagename='title_screen.jpg') time.sleep(3) backstory() title() for event in pygame.event.get(): if event.type == MOUSEBUTTONUP: None 
2
  • 3
    can you include more description of what happens when you open the window, rather than just doesn't work? Commented Apr 19, 2018 at 19:29
  • 2
    Please read the how to ask page and describe your goals, the problems and what you've tried to fix them. Also, provide a minimal, complete and verifiable example. Commented Apr 19, 2018 at 22:43

1 Answer 1

1

"Just doesn't work" doesn't tell us much, but looking at the code I think I got what you had intended to do. Here's some fixed code, with the wrong lines commented out. Make sure you fix the image file name in image(imagename='backtory.') too.

from pygame import image import time import os import subprocess import pygame from pygame.locals import* from pygame import mixer pygame.event.pump def image(imagename): img = pygame.image.load(imagename) black = (0, 0 ,0 ) w = 1251 h = 584 screen = pygame.display.set_mode((w, h)) screen.fill((black)) #running = 1 #while running: # screen.fill((black)) screen.blit(img,(0,0)) pygame.display.flip() def backstory(): # pygame.init; image(imagename='backstory.jpg') time.sleep(25) def title(): pygame.init() image(imagename='title_screen.jpg') time.sleep(3) backstory() title() for event in pygame.event.get(): if event.type == MOUSEBUTTONUP: None 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.