I just started using pygame and when I try to move an object it Crashes [duplicate]
This question already has answers here: How to animate the position of an object or sprite in Pygame and move it towards predefined positions or along a defined path? (1 answer) Do something every x (milli)seconds in pygame (3 answers) Closed 46 mins ago. import pygame import sys from pygame.locals import * import random from […]
I just started using pygame and when I try to move an object it Crashes [duplicate]
This question already has answers here: How to animate the position of an object or sprite in Pygame and move it towards predefined positions or along a defined path? (1 answer) Do something every x (milli)seconds in pygame (3 answers) Closed 46 mins ago. import pygame import sys from pygame.locals import * import random from […]
I just started using pygame and when I try to move an object it Crashes [duplicate]
This question already has answers here: How to animate the position of an object or sprite in Pygame and move it towards predefined positions or along a defined path? (1 answer) Do something every x (milli)seconds in pygame (3 answers) Closed 46 mins ago. import pygame import sys from pygame.locals import * import random from […]
speed is min but in screen is too fast to play [duplicate]
This question already has answers here: Does running pygame usually make computers warm (1 answer) Pygame clock and event loops (1 answer) Closed 1 min ago. import pygame import random pygame.init() width,height=900,500 screen=pygame.display.set_mode((width,height)) vel=0.1 def main(): player1=pygame.Rect(5,height//2-20,10,40) player2=pygame.Rect(0,height//2-20,10,40) player2=pygame.Rect(width-5-player2.width,height//2-20,10,40) go=random.randint(0,1) while True: for event in pygame.event.get(): if event.type==pygame.QUIT: exit() screen.fill((0,0,0)) pygame.draw.rect(screen,(255,255,255),player1) pygame.draw.rect(screen,(255,255,255),player2) key=pygame.key.get_pressed() if key[pygame.K_UP] […]
bool getting set back to true without my intent
I am trying to make pygame quit when i press a “quit” button. however when setting my running bool to false my code keeps spitting out the text “test” and whenever i click the quit button it prints false, then goes right back to saying “test”. if printing running in both instances, it still prints false in the quit function but true in the while loop.
How do implement alarm in python?
I am trying to build a alarm application in Python using pygame to load music file. I have implemented alarm in below mentioned by using time.sleep(10)
. But Alarm is ringing just once and execution of code completes.
The code is as follows :-