Using a single spritesheet question

so this lesson teaches us how to load multiple spritesheets and how to change the animation by assigning the value of the other spritesheets to the “core” one.

looking at the nebula, or a spritesheet from spriters resource or itch.io, it looks like we’d have to adjust the y value like we do the x value right?

so would something like this work? for this example, say we have 6 different types of animation (idle, walking, running, jumping, crawling, climbing):

#define idle 1
#define walk 2
#define run 3
#define jump 4
#define crawl 5
#define climb 6
int animation_action{idle};

if (IsKeyDown(KEY_SPACE))  animation_action = jump;
if(Vector2Length(direction)!= 0.0 && IsKeyDown(KEY_C)) animation_action = crawl;

Rectangle source{frame*(float)knight.width/6.f, animation_action*(float)knight.height/6.f, rightLeft * (float)knight.width/6.f, (float)knight.height/6.f};

etcetera, etcetera.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms