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.
101 lines
3.1 KiB
101 lines
3.1 KiB
#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);
|
|
|
|
return textures;
|
|
}
|
|
|
|
void LoadCursorTextures(Texture2D *cursorTextures){
|
|
*cursorTextures = LoadTexture("assets/cursor.gif");
|
|
*(cursorTextures + 1) = LoadTexture("assets/cursor_down.gif");
|
|
}
|
|
|
|
void LoadWorkerTextures(Texture2D *workerTextures){
|
|
/*
|
|
Image worker1flip = LoadImage("assets/worker/worker-1.png");
|
|
ImageFlipHorizontal(&worker1flip);
|
|
Image worker2flip = LoadImage("assets/worker/worker-2.png");
|
|
ImageFlipHorizontal(&worker2flip);
|
|
Image worker3flip = LoadImage("assets/worker/worker-3.png");
|
|
ImageFlipHorizontal(&worker3flip);
|
|
textures->workerTextures[6] = LoadTexture("assets/worker/worker-0.png");
|
|
textures->workerTextures[5] = LoadTexture("assets/worker/worker-1.png");
|
|
textures->workerTextures[7] = LoadTextureFromImage(worker1flip);
|
|
textures->workerTextures[4] = LoadTexture("assets/worker/worker-2.png");
|
|
textures->workerTextures[0] = LoadTextureFromImage(worker2flip);
|
|
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;
|
|
}
|
|
}
|
|
}
|