Recently I've learned some basic Python, so I am writing a game using PyGame to enhance my programming skills.
In my game, I want to move an image of a monster every 3 seconds, at the same time I can aim it with my mouse and click the mouse to shoot it.
At the beginning I tried to use time.sleep(3), but it turned out that it pause the whole program, and I can't click to shoot the monster during the 3 seconds.
So do you have any solution for this?
Thanks in advance! :)
Finally I solved the problem with the help of you guys. Thank you so much! Here is part of my code:
import random, pygame, time
x = 0
t = time.time()
while True:
screen = pygame.display.set_mode((1200,640))
screen.blit(bg,(0,0))
if time.time() > t + 3:
x = random.randrange(0,1050)
t = time.time()
screen.blit(angel,(x,150))
pygame.display.flip()