0
Moving image in pygame
Hey guys! I know how tonset up a basic pygame window with a background. The next thing i would like to do is to move an other image in every 4 seconds automatically on this background. And also i would like to attach a text next to the moving image that is always next to it, and in every movement it prints an other text. Can you please help me how can i code it?
6 Réponses
+ 1
Edit the x and y position in game loop!
+ 1
Can you show your code!
+ 1
https://www.pygame.org/docs/tut/MoveIt.html
This is from Pygame's official site, hope it's help you 🙂
0
And what about the 4 second refreshrate?
0
#Pygame base
import pygame
#Color pre_definition
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
pygame.init ()
#Screen size, name, refreshrate
size = (800, 600)
screen = pygame.display.set_mode(size)
pygame.display.set_caption('TEST')
done = False
clock = pygame.time.Clock()
background = pygame.image.load("").convert()
#Main program loop
while not done :
for event in pygame.event.get() :
if event.type == pygame.QUIT :
done = True
#Program logic
screen.blit(background, [0,0])
#Drawing
pygame.display.flip()
clock.tick(60)
#Close window
pygame.quit()
0
I will try it, thank you