To keep it (relatively) simple you could not use the extra t_sprite type for the moment, and add a couple of fields to the t_player type for the image and the current frame. The extra fields could be:
- an image variable (TImage); this points to one of the animations that you loaded as global variables
- an int representing the current frame in the current animation
As the player moves, the int increases until the maximum frame is reached, at which stage it wraps around to 0. If the player changes direction, the image would be changed (it would then point to one of the other global images) and the frame counter would be reset to 0.
(Of course there can be situations where using separate sprite objects to represent the images of otherwise different types of objects is useful but if this is not such a case it might make things unnecessarily complicated.)
When that works you could add a "state" variable (for instance an int) to represent the current state: 0 = walking, 1 = standing. This state changes depending on whether the player is holding down movement keys. Based on this state, the above image is selected from different sets of images.
- an image variable (TImage); this points to one of the animations that you loaded as global variables
- an int representing the current frame in the current animation
As the player moves, the int increases until the maximum frame is reached, at which stage it wraps around to 0. If the player changes direction, the image would be changed (it would then point to one of the other global images) and the frame counter would be reset to 0.
(Of course there can be situations where using separate sprite objects to represent the images of otherwise different types of objects is useful but if this is not such a case it might make things unnecessarily complicated.)
When that works you could add a "state" variable (for instance an int) to represent the current state: 0 = walking, 1 = standing. This state changes depending on whether the player is holding down movement keys. Based on this state, the above image is selected from different sets of images.