Animation Framework added, Textures almost properly loaded into TextureAtlas

main
Jonathan Hager 3 years ago
parent 8a4ac55c90
commit 92beda7778
Signed by: JonathanHager
GPG Key ID: 34881E488569708C

@ -0,0 +1,59 @@
#include "animation.h"
#include "stdlib.h"
Animation * AnimationInit(){
Animation *animation = (Animation *) malloc(sizeof(Animation));
animation->head = 0;
animation->tail = 0;
return animation;
}
AnimationFrame * AnimationFrameCreate(Texture2D *texture){
AnimationFrame *frame = (AnimationFrame *) 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(list->head == 0){
list->head = new;
list->tail = new;
}
else if(list->head == list->tail){
list->head = new;
list->head->next = list->tail;
list->tail->prev = list->head;
}
else{
list->head->prev = new;
new->next = list->head;
list->head = new;
}
}
void AnimationInsertBack(Animation *animation, Texture2D *texture){
AnimationFrame *new = AnimationFrameCreate(texture);
if(list->head == 0){
list->head = new;
list->tail = new;
}
else if(list->head == list->tail){
list->tail = new;
list->head->next = list->tail;
list->tail->prev = list->head;
}
else{
list->tail->next = new;
new->prev = list->tail;
list->tail = new;
}
}

@ -0,0 +1,27 @@
#ifndef ANIMATION_H_
#define ANIMATION_H_
#include "raylib.h"
struct Animation;
struct AnimationFrame;
typedef struct Animation {
AnimationFrame *head;
AnimationFrame *tail;
} Animation;
typedef struct AnimationFrame {
Texture2D *texture;
AnimationFrame *next;
AnimationFrame *prev;
} AnimationFrame;
Animation * AnimationInit();
AnimationFrame * AnimationFrameCreate(Texture2D *texture);
void AnimationInsertFront(Animation *animation, Texture2D *texture);
void AnimationInsertBack(Animation *animation, Texture2D *texture);
#endif

@ -1,10 +1,12 @@
#include "textureatlas.h"
#include "stdlib.h"
#include "raylib.h"
#include "string.h"
#include "stdio.h"
TextureAtlas * TextureAtlasInit(){
TextureAtlas *textures = (TextureAtlas *) malloc(sizeof(TextureAtlas));
LoadCursorTextures(textures->cursorTextures);
LoadWorkerTextures(textures->workerTextures);
@ -17,6 +19,7 @@ void LoadCursorTextures(Texture2D *cursorTextures){
}
void LoadWorkerTextures(Texture2D *workerTextures){
/*
Image worker1flip = LoadImage("assets/worker/worker-1.png");
ImageFlipHorizontal(&worker1flip);
Image worker2flip = LoadImage("assets/worker/worker-2.png");
@ -31,4 +34,67 @@ void LoadWorkerTextures(Texture2D *workerTextures){
textures->workerTextures[3] = LoadTexture("assets/worker/worker-3.png");
textures->workerTextures[1] = LoadTextureFromImage(worker3flip);
textures->workerTextures[2] = LoadTexture("assets/worker/worker-4.png");
assets/worker/umackern-20.png
*/
char beginning[30] = "assets/worker/walk-";
char filename[30] = "";
char number[3] = "";
char ending[5] = ".png";
// Since some Images need to be flipped, we have fewer pngs than textures later loaded. i counts textures
// file counts the filename and is incremented manually when needed
int i;
int file = 0;
for(i = 0; i < 104; i++){
// Concatenate the correct string for the filename (beginning + i + ending)
sprintf(number, "%d", file);
strcat(filename, beginning);
strcat(filename, number);
strcat(filename, ending);
//*(workerTextures + i) = LoadTexture(filename);
printf("lol: %s ", filename);
// Set correct values for next iteration
int lol = i % 5;
// TODO: walk und umackern läuft nicht bis 24 sondern nur 23
if(lol == 0){
printf("\n");
file++;
}
else if(lol == 2){
printf("flipped\n");
file++;
}
else if(lol == 4){
printf("flipped\n");
file++;
}
else if(lol == 6){
printf("flipped\n");
file++;
}
else if(lol == 7){
printf("\n");
file++;
}
else{
printf("\n");
}
strcpy(filename, "");
strcpy(number, "");
if(i == 39){
strcpy(beginning, "assets/worker/umackern-");
file = 0;
}
else if(i == 79){
strcpy(beginning, "assets/worker/die-");
file = 0;
}
}
}

@ -4,7 +4,7 @@
typedef struct TextureAtlas{
Texture2D cursorTextures[2];
Texture2D workerTextures[8][5];
Texture2D workerTextures[104];
//Texture2D[] mapTextures;
} TextureAtlas;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 B

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 B

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 B

After

Width:  |  Height:  |  Size: 704 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 782 B

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 783 B

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 738 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 758 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 816 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 736 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 840 B

After

Width:  |  Height:  |  Size: 812 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

After

Width:  |  Height:  |  Size: 700 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 B

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

After

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

After

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 698 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 716 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 710 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save