fix animation mirroring
This commit is contained in:
parent
9bfe543322
commit
0ffb5d90ad
2 changed files with 4 additions and 4 deletions
|
@ -36,7 +36,7 @@ int aniplayer_get_frame(AniPlayer *plr) {
|
|||
mirror = s->mirrored;
|
||||
}
|
||||
|
||||
return (row*plr->ani->cols+col)*(1-2*mirror);
|
||||
return plr->ani->rows*plr->ani->cols*mirror+row*plr->ani->cols+col;
|
||||
}
|
||||
|
||||
void aniplayer_free(AniPlayer *plr) {
|
||||
|
@ -99,8 +99,8 @@ void aniplayer_update(AniPlayer *plr) {
|
|||
}
|
||||
|
||||
void play_animation_frame(Animation *ani, float x, float y, int frame) {
|
||||
int mirror = frame < 0;
|
||||
frame = abs(frame);
|
||||
int mirror = frame/(ani->cols*ani->rows);
|
||||
frame = frame%(ani->cols*ani->rows);
|
||||
if(mirror) {
|
||||
glPushMatrix();
|
||||
glCullFace(GL_FRONT);
|
||||
|
|
|
@ -53,7 +53,7 @@ void aniplayer_reset(AniPlayer *plr); // resets to a neutral state with empty qu
|
|||
// this returns a representation of the frame that is currently drawn by the aniplayer.
|
||||
// in multirow animations it is computed as follows:
|
||||
//
|
||||
// idx = (row*ani->cols+col)*(1-2*mirrored)
|
||||
// idx = ani->rows*ani->cols*mirrored+row*ani->cols+col
|
||||
//
|
||||
int aniplayer_get_frame(AniPlayer *plr);
|
||||
void play_animation_frame(Animation *ani, float x, float y, int frame); // context free version that can be used with aniplayer_get_frame to draw a specific state
|
||||
|
|
Loading…
Reference in a new issue