I have an rpg game like character that can move up, down, left, right, which uses 4 different actors each with 4 different animations. I draw items from a list, and change the list item into the actor to show the actor walking in the direction, however the animation is still running in the background, but just in a way no one can see. This method makes my game slower, is there a way to make 1 actor that can switch between multiple images or animations instead of having them in separate actors?
import time
import random
from pgzhelper import *
WIDTH = 1280
HEIGHT = 720
taishan_walkspeed = 4.5
taishan_idle = Actor('taishan_idle_char1.png')
taishan_down = Actor('taishan_down_char1.png')
taishan_up = Actor('taishan_up_char1.png')
taishan_right = Actor('taishan_right_char1.png')
taishan_idle.images = ['taishan_idle_char1', 'taishan_idle_char2']
taishan_down.images = ['taishan_down_char1', 'taishan_down_char2', 'taishan_down_char3']
taishan_up.images = ['taishan_up_char1', 'taishan_up_char2', 'taishan_up_char3']
taishan_right.images = ['taishan_right_char1', 'taishan_right_char2', 'taishan_right_char3']
taishan_idle.fps = 2
taishan_down.fps = 4
taishan_up.fps = 4
taishan_right.fps = 4
taishan_player = [taishan_idle]
def idle_animation():
taishan_player[0] = taishan_idle
def draw():
screen.fill((172, 199, 145))
global taishan_player
for item in taishan_player:
item.draw()
def update():
global taishan_player
taishan_idle.animate()
taishan_down.animate()
taishan_up.animate()
taishan_right.animate()
if keyboard.right:
taishan_up.x += taishan_walkspeed
taishan_idle.x += taishan_walkspeed
taishan_down.x += taishan_walkspeed
taishan_right.x += taishan_walkspeed
taishan_right.flip_x = False
taishan_player[0] = taishan_right```
The rest of the key board movements are fairly the same
I usually change the actor's appearance every frame.