You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.0 KiB
81 lines
2.0 KiB
#include "animation.h"
|
|
#include "stdlib.h"
|
|
|
|
Animation * AnimationInit(){
|
|
Animation *animation = malloc(sizeof(Animation));
|
|
|
|
animation->head = 0;
|
|
animation->tail = 0;
|
|
|
|
return animation;
|
|
}
|
|
|
|
AnimationFrame * AnimationFrameCreate(Texture2D *texture){
|
|
AnimationFrame *frame = malloc(sizeof(AnimationFrame));
|
|
|
|
frame->texture = texture;
|
|
frame->next = 0;
|
|
frame->prev = 0;
|
|
|
|
return frame;
|
|
}
|
|
|
|
void AnimationInsertFront(Animation *animation, Texture2D *texture){
|
|
AnimationFrame *new = AnimationFrameCreate(texture);
|
|
|
|
if(animation->head == 0){
|
|
animation->head = new;
|
|
animation->tail = new;
|
|
|
|
animation->head->prev = animation->tail;
|
|
animation->tail->next = animation->head->prev;
|
|
|
|
}
|
|
else if(animation->head == animation->tail){
|
|
animation->head = new;
|
|
|
|
animation->head->next = animation->tail;
|
|
animation->head->prev = animation->tail;
|
|
|
|
animation->tail->prev = animation->head;
|
|
animation->tail->next = animation->head;
|
|
}
|
|
else{
|
|
animation->head->prev = new;
|
|
|
|
new->next = animation->head;
|
|
new->prev = animation->tail;
|
|
|
|
animation->tail->next = new;
|
|
animation->head = new;
|
|
}
|
|
}
|
|
|
|
void AnimationInsertBack(Animation *animation, Texture2D *texture){
|
|
AnimationFrame *new = AnimationFrameCreate(texture);
|
|
|
|
if(animation->head == 0){
|
|
animation->head = new;
|
|
animation->tail = new;
|
|
|
|
animation->head->prev = animation->tail;
|
|
animation->tail->next = animation->head->prev;
|
|
}
|
|
else if(animation->head == animation->tail){
|
|
animation->tail = new;
|
|
|
|
animation->head->next = animation->tail;
|
|
animation->head->prev = animation->tail;
|
|
|
|
animation->tail->prev = animation->head;
|
|
animation->tail->next = animation->head;
|
|
}
|
|
else{
|
|
animation->tail->next = new;
|
|
new->prev = animation->tail;
|
|
new->next = animation->head;
|
|
animation->head->prev = new;
|
|
animation->tail = new;
|
|
}
|
|
}
|