anyone know why my pygame window keeps freezing and i need to close it with the window not responding button instead of escape here my code:
import pygame pygame.init() screen=pygame.display.set_mode((640,480)) running = True while running: for event in pygame.event.get(): if event.type==pygame.QUIT: running=False if event.type==pygame.KEYDOWN and event.key==pygame.K_ESCAPE: running = False
Because you left the engine running.... and I don't mean on your car. ``` import pygame pygame.init() screen=pygame.display.set_mode((640,480)) running = True while running: for event in pygame.event.get(): if event.type==pygame.QUIT: pygame.quit() running=False if event.type==pygame.KEYDOWN and event.key==pygame.K_ESCAPE: pygame.quit() running = False ``` The addition of pygame.quit() shuts down the game engine, allowing the process to be unlinked from those DLLs.
you are the best!
just wondering though, closing the screen means you close the whole pygame module? so pygame running == pop up screen showing up?
Solving yours was the first time I used pygame, so I do not know all of what the engine does.
oh i think theres just something wrong with my version though because
i saw the teacher type the same code, and theirs was working fine
On what OS, with what version of Pygame, and whatversion of Python? See, those things could change it very easily.
that what i was thinking, i think i should downlad the 32 bit version
Or just close the engine on exit. Part of the fun of programming is finding little differences like that!
hmm
i think i need the engine running though
Should not need it when you exit. Only when playing.
like there are gonna be questions where i just keep refreshing the display screen by closing and opening
Hmmm... dunno then.
If you do it from inside the software, it may be different.
i will try downloading the right bit version brb
i m excited lol
i am finally going to start adding pictures to my game
Sprites! Whee. I did an Attack of the Rhoombas game in C++ for a final project. They slamed into your tank and exploded to kill you. Had pickups pop up on the map for tank repair and missiles, but never got the missles fully worked out.
Another cute trick is the rolling background. Start with a pic and cut it in half. Then swap the sides. Next to make the new middle match up. Now, when you have two copies go by, the edges are what was originally thew center and they match. What you fixed matches. So the whole thing works and you can roll it by as an endless background.
Here is where I used the rolling background. http://www.youtube.com/watch?v=eym2HQjHaWQ And here was the attack of the Rhoomas: http://www.youtube.com/watch?v=iAL1YDT0dbI
Join our real-time social learning platform and learn together with your friends!