I have a game with a background made of tiles, some are static (grass, mud), but i want water to be flowing. i have created a surface called water, then i have a loop that iterates through a series of 10 pngs for the frames of the water flowing. i want to then update this surface 10x as often as the rest of the game, and blit it to the main surface at 30fps with the other objects.
However all i can achieve is no movement or the water flowing at insane speed(by updating the whole display in the water update loop.)
is there a way i can update just this surface?
here's my code:
#mud, grass and surface are defined earlier.
water = pygame.Surface((100,100))
#create mud tiles
for x in range(0,800,100):
for y in range(0, 500, 100):
screen.blit(mud,(x,y))
#create grass tiles
for x in range(400, 800, 100):
for y in range(0, 300, 100):
screen.blit(grass,(x,y))
#create filenames
for x in range(1,11):
if x < 10:
filename = "images\water\water1000" + str(x) + ".png "
else:
filename = "images\water\water100" + str(x) + ".png "
waterimg = pygame.image.load(filename)
#add to a surface, then tile the surface onto the game.
water.blit(waterimg,(0,0))
for x in range(100, 200, 100):
for y in range(0, 500, 100):
screen.blit(water, (x,y))
pygame.display.flip() #makes it update crazily. removing this line makes it not update at all.
allsprites.draw(screen)
pygame.display.flip()