Refactor erfolgreich

main
Jonathan Hager 3 years ago
parent 9ce0701cc7
commit 356e23e5a8
Signed by: JonathanHager
GPG Key ID: 34881E488569708C

@ -4,9 +4,10 @@
#include <stdlib.h> #include <stdlib.h>
#include "../Sprite/sprite.h" #include "../Sprite/sprite.h"
#include "../MapObject/mapobject.h" #include "../MapObject/mapobject.h"
#include "../Textures/textureIDs.h" #include "../definitions.h"
#include "../Textures/textureatlas.h"
Entity * EntityInit(Sprite *sprite, int profession){ Entity * EntityInit(Sprite *sprite, int profession, TextureAtlas *atlas){
Entity *new = malloc(sizeof(Entity)); Entity *new = malloc(sizeof(Entity));
new->angle = 0; new->angle = 0;
@ -20,6 +21,17 @@ Entity * EntityInit(Sprite *sprite, int profession){
new->task = TaskInit(); new->task = TaskInit();
new->profession = profession; new->profession = profession;
Animation ***animations = 0;
if(profession == TE_WORKER){
animations = atlas->animations[AN_WORKER];
}
else{
printf("\n\n\n\n\n\n\n\nEntityCreate mit falscher ID (%d) aufgerufen oder ID nicht bekannt!!!\n\n\n\n\n\n\n\n", profession);
}
new->animationHandler = AnimationHandlerInit(animations, &new->sprite->texture);
return new; return new;
} }
@ -104,40 +116,41 @@ void EntityListActAllEntities(Game *game){
if(angle <= 22.5 && angle >= -22.5){ if(angle <= 22.5 && angle >= -22.5){
// E // E
AnimationChangeAnimation(current->animationHandler, E); AnimationChangeDirection(current->animationHandler, E);
} }
else if(angle > 0 && angle <= 67.5){ else if(angle > 0 && angle <= 67.5){
// NE // NE
AnimationChangeAnimation(current->animationHandler, NE); AnimationChangeDirection(current->animationHandler, NE);
} }
else if(angle > 0 && angle <= 112.5){ else if(angle > 0 && angle <= 112.5){
// N // N
AnimationChangeAnimation(current->animationHandler, N); AnimationChangeDirection(current->animationHandler, N);
} }
else if(angle > 0 && angle <= 157.5){ else if(angle > 0 && angle <= 157.5){
// NW // NW
AnimationChangeAnimation(current->animationHandler, NW); AnimationChangeDirection(current->animationHandler, NW);
} }
else if(angle < 0 && angle >= -67.5){ else if(angle < 0 && angle >= -67.5){
// SE // SE
AnimationChangeAnimation(current->animationHandler, SE); AnimationChangeDirection(current->animationHandler, SE);
} }
else if(angle < 0 && angle >= -112.5){ else if(angle < 0 && angle >= -112.5){
// S // S
AnimationChangeAnimation(current->animationHandler, S); AnimationChangeDirection(current->animationHandler, S);
} }
else if(angle < 0 && angle >= -157.5){ else if(angle < 0 && angle >= -157.5){
// SW // SW
AnimationChangeAnimation(current->animationHandler, SW); AnimationChangeDirection(current->animationHandler, SW);
} }
else{ else{
// W // W
AnimationChangeAnimation(current->animationHandler, W); AnimationChangeDirection(current->animationHandler, W);
} }
} }
} }
else{ else{
/*
if(current->profession == PR_BUILDER){ if(current->profession == PR_BUILDER){
if(current->task->target == 0){ if(current->task->target == 0){
// Prüft, ob eine Baustelle existiert // Prüft, ob eine Baustelle existiert
@ -155,6 +168,7 @@ void EntityListActAllEntities(Game *game){
} }
else{ else{
// Is beim target angekommen // Is beim target angekommen
/*
MapObject *obj = current->task->target; MapObject *obj = current->task->target;
printf("Hier\n"); printf("Hier\n");
Sprite *new = SpriteCreate(game->textures, 2, obj->sprite->x, obj->sprite->y); Sprite *new = SpriteCreate(game->textures, 2, obj->sprite->x, obj->sprite->y);
@ -166,9 +180,10 @@ void EntityListActAllEntities(Game *game){
MapObjectListInsert(game->mapObjects, newObject); MapObjectListInsert(game->mapObjects, newObject);
current->task->target = 0; current->task->target = 0;
free(obj); free(obj);
} */
//}
} //}
} }

@ -9,7 +9,7 @@ typedef struct Entity Entity;
typedef struct Entity{ typedef struct Entity{
Sprite *sprite; Sprite *sprite;
AnimationHandler animationHandler; AnimationHandler *animationHandler;
float angle; float angle;
float destX; float destX;
float destY; float destY;
@ -27,7 +27,7 @@ typedef struct EntityList{
Entity *tail; Entity *tail;
} EntityList; } EntityList;
Entity * EntityInit(Sprite *sprite, int profession); Entity * EntityInit(Sprite *sprite, int profession, TextureAtlas *atlas);
EntityList * EntityListInit(); EntityList * EntityListInit();
void EntityListPrintForward(EntityList *entities); void EntityListPrintForward(EntityList *entities);

@ -9,9 +9,7 @@
#include <math.h> #include <math.h>
#include "../IsometricMap/tile.h" #include "../IsometricMap/tile.h"
#include "../game.h" #include "../game.h"
#include "../MapObject/mapobjectIDs.h" #include "../definitions.h"
#include "../Entity/professions.h"
//#include "../Textures/textureIDs.h"
void DrawRect(Vector2 rectStart, Vector2 *mousePosition){ void DrawRect(Vector2 rectStart, Vector2 *mousePosition){
float width = GetMousePosition().x - rectStart.x; float width = GetMousePosition().x - rectStart.x;
@ -75,10 +73,12 @@ void mouseInput(Game *game){
if(IsKeyPressed(KEY_G)){ if(IsKeyPressed(KEY_G)){
// Baustelle adden // Baustelle adden
/*
Sprite *new = SpriteCreate(game->textures, 3, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); Sprite *new = SpriteCreate(game->textures, 3, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y);
MapObject *newObject = MapObjectInit(new, MO_Baustelle); MapObject *newObject = MapObjectInit(new, MO_Baustelle);
SpriteListInsert(game->sprites, new); SpriteListInsert(game->sprites, new);
MapObjectListInsert(game->mapObjects, newObject); MapObjectListInsert(game->mapObjects, newObject);
*/
} }
// hardcoded layer amount // hardcoded layer amount
@ -111,7 +111,7 @@ void mouseInput(Game *game){
inputHandler->pressed = 1; inputHandler->pressed = 1;
// Cursorsprite is changed to "down" // Cursorsprite is changed to "down"
inputHandler->cursorSprite->texture = (inputHandler->cursorTextures) + 1; game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][1];
} }
} }
@ -123,7 +123,7 @@ void mouseInput(Game *game){
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){ if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){
inputHandler->pressed = 0; inputHandler->pressed = 0;
// Cursorsprite is changed back to normal // Cursorsprite is changed back to normal
inputHandler->cursorSprite->texture = (inputHandler->cursorTextures); game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][0];
float width = GetMousePosition().x - inputHandler->rectStart.x; float width = GetMousePosition().x - inputHandler->rectStart.x;
float height = GetMousePosition().y - inputHandler->rectStart.y; float height = GetMousePosition().y - inputHandler->rectStart.y;
@ -137,8 +137,8 @@ void mouseInput(Game *game){
else if(inputHandler->cursorWorldPos.x > maxWidth){ printf("OutOfBoundsDestination Spawn\n");} else if(inputHandler->cursorWorldPos.x > maxWidth){ printf("OutOfBoundsDestination Spawn\n");}
else if(inputHandler->cursorWorldPos.y > maxHeight){ printf("OutOfBoundsDestination Spawn\n");} else if(inputHandler->cursorWorldPos.y > maxHeight){ printf("OutOfBoundsDestination Spawn\n");}
else { else {
Sprite *newSprite = SpriteCreate(game->textures, 1, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); Sprite *newSprite = SpriteCreate(game->textures, TE_WORKER, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y);
Entity *entity = EntityInit(newSprite, PR_BUILDER); Entity *entity = EntityInit(newSprite, TE_WORKER, game->textures);
EntityListInsert(game->entities, entity); EntityListInsert(game->entities, entity);
SpriteListInsert(game->sprites, newSprite); SpriteListInsert(game->sprites, newSprite);
//ListPrintForward(sprites); //ListPrintForward(sprites);

@ -12,8 +12,6 @@ typedef struct InputHandler{
Vector2 cursorWorldPos; Vector2 cursorWorldPos;
Vector2 cursorWorldTile; Vector2 cursorWorldTile;
int selectedLayer; int selectedLayer;
Texture2D *cursorTextures;
Sprite *cursorSprite;
} InputHandler; } InputHandler;
void mouseInput(Game *game); void mouseInput(Game *game);

@ -49,34 +49,11 @@ void SpriteUpdate(Sprite *sprite){
Sprite * SpriteCreate(TextureAtlas *atlas, int textureID, int x, int y){ Sprite * SpriteCreate(TextureAtlas *atlas, int textureID, int x, int y){
Sprite *newSprite = malloc(sizeof(Sprite)); Sprite *newSprite = malloc(sizeof(Sprite));
//AnimationHandler create newSprite->texture = atlas->textures[textureID];
Animation **animations = 0;
if(textureID == TE_WORKER){
animations = atlas->workerAnimations;
}
else if(textureID == TE_WORKER){
animations = atlas->cursorAnimation;
}
else if(textureID == TE_BUILDING){
animations = atlas->buildingAnimation;
}
else if(textureID == TE_BAUSTELLE){
animations = atlas->baustelleAnimation;
}
else{
printf("\n\n\n\n\n\n\n\nSpriteCreate mit falscher ID (%d) aufgerufen oder ID nicht bekannt!!!\n\n\n\n\n\n\n\n", textureID);
}
AnimationHandler *newHandler = AnimationHandlerInit(animations);
newSprite->animationHandler = newHandler;
newSprite->texture = newSprite->animationHandler->currentFrame->texture;
newSprite->x = x - newSprite->texture->width / 2; newSprite->x = x - newSprite->texture->width / 2;
newSprite->y = y - newSprite->texture->height / 2; newSprite->y = y - newSprite->texture->height / 2;
newSprite->z = 0; newSprite->z = 0;
newSprite->depth = newSprite->x + newSprite->y; newSprite->depth = newSprite->x + newSprite->y;
newSprite->angle = 0;
newSprite->next = 0; newSprite->next = 0;
newSprite->prev = 0; newSprite->prev = 0;

@ -3,13 +3,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
AnimationHandler * AnimationHandlerInit(Animation **animations, Texture2D **spriteTexture){ AnimationHandler * AnimationHandlerInit(Animation ***animations, Texture2D **spriteTexture){
AnimationHandler *new = malloc(sizeof(AnimationHandler)); AnimationHandler *new = malloc(sizeof(AnimationHandler));
new->spriteTexture = spriteTexture; new->spriteTexture = spriteTexture;
new->animations = animations; new->animations = animations;
new->currentAnimation = 0; new->currentType = 0;
new->currentFrame = new->animations[new->currentAnimation]->head; new->currentDirection = 0;
new->currentFrame = new->animations[new->currentType][new->currentDirection]->head;
new->spriteTexture = spriteTexture;
new->forward = 1; new->forward = 1;
new->deltaElapsed = 0; new->deltaElapsed = 0;
@ -34,13 +36,22 @@ void AnimationUpdate(AnimationHandler *animationHandler){
} }
void AnimationReset(AnimationHandler *animationHandler){ void AnimationReset(AnimationHandler *animationHandler){
animationHandler->currentFrame = animationHandler->animations[animationHandler->currentAnimation]->head; animationHandler->currentFrame = animationHandler->animations[animationHandler->currentType][animationHandler->currentDirection]->head;
*(animationHandler->spriteTexture) = animationHandler->currentFrame->texture; *(animationHandler->spriteTexture) = animationHandler->currentFrame->texture;
} }
void AnimationChangeAnimation(AnimationHandler *animationHandler, int newAnimation){ void AnimationChangeAnimation(AnimationHandler *animationHandler, int animationType, int direction){
if(animationHandler->currentAnimation != newAnimation){ if(animationHandler->currentType != animationType || animationHandler->currentDirection != direction){
animationHandler->currentAnimation = newAnimation; animationHandler->currentType = animationType;
animationHandler->currentDirection = direction;
AnimationReset(animationHandler);
}
}
void AnimationChangeDirection(AnimationHandler *animationHandler, int direction){
if(animationHandler->currentDirection != direction){
animationHandler->currentDirection = direction;
AnimationReset(animationHandler); AnimationReset(animationHandler);
} }
} }

@ -7,17 +7,19 @@
typedef struct AnimationHandler AnimationHandler; typedef struct AnimationHandler AnimationHandler;
typedef struct AnimationHandler{ typedef struct AnimationHandler{
Animation **animations; Animation ***animations;
AnimationFrame *currentFrame; AnimationFrame *currentFrame;
Texture2D **spriteTexture; Texture2D **spriteTexture;
int currentAnimation; int currentType;
int currentDirection;
int forward; int forward;
float deltaElapsed; float deltaElapsed;
} AnimationHandler; } AnimationHandler;
AnimationHandler * AnimationHandlerInit(Animation **animations, Texture2D **spriteTexture); AnimationHandler * AnimationHandlerInit(Animation ***animations, Texture2D **spriteTexture);
void AnimationUpdate(AnimationHandler *animationHandler); void AnimationUpdate(AnimationHandler *animationHandler);
void AnimationReset(AnimationHandler *animationHandler); void AnimationReset(AnimationHandler *animationHandler);
void AnimationChangeAnimation(AnimationHandler *animationHandler, int newAnimation); void AnimationChangeAnimation(AnimationHandler *animationHandler, int animationType, int direction);
void AnimationChangeDirection(AnimationHandler *animationHandler, int direction);
#endif #endif

@ -8,39 +8,8 @@ TextureAtlas * TextureAtlasInit(){
TextureAtlas *new = malloc(sizeof(TextureAtlas)); TextureAtlas *new = malloc(sizeof(TextureAtlas));
TextureAtlasLoadTextures(new->textures); TextureAtlasLoadTextures(new->textures);
//LoadCursorTextures(textures->cursorTextures, textures->cursorAnimation);
//LoadWorkerTextures(textures->workerTextures);
//LoadWorkerAnimations(textures->workerAnimations, textures->workerTextures); //LoadWorkerAnimations(textures->workerAnimations, textures->workerTextures);
TextureAtlasLoadAnimations(new->animations, new->textures);
/*
//Das soll nicht hier hin, bin aber zu faul :|
textures->building = LoadTexture("assets/building.png");
Animation *buildingAnimation = AnimationInit();
AnimationInsertBack(buildingAnimation, &textures->building);
textures->buildingAnimation[0] = buildingAnimation;
textures->buildingAnimation[1] = buildingAnimation;
textures->buildingAnimation[2] = buildingAnimation;
textures->buildingAnimation[3] = buildingAnimation;
textures->buildingAnimation[4] = buildingAnimation;
textures->buildingAnimation[5] = buildingAnimation;
textures->buildingAnimation[6] = buildingAnimation;
textures->buildingAnimation[7] = buildingAnimation;
*/
//Das soll nicht hier hin, bin aber zu faul :|
/*
textures->baustelle = LoadTexture("assets/construction.png");
Animation *baustelleAnimation = AnimationInit();
AnimationInsertBack(baustelleAnimation, &textures->baustelle);
textures->baustelleAnimation[0] = baustelleAnimation;
textures->baustelleAnimation[1] = baustelleAnimation;
textures->baustelleAnimation[2] = baustelleAnimation;
textures->baustelleAnimation[3] = baustelleAnimation;
textures->baustelleAnimation[4] = baustelleAnimation;
textures->baustelleAnimation[5] = baustelleAnimation;
textures->baustelleAnimation[6] = baustelleAnimation;
textures->baustelleAnimation[7] = baustelleAnimation;
*/
return new; return new;
} }
@ -50,16 +19,19 @@ void TextureAtlasLoadTextures(Texture2D **textures){
for(i = 0; i < TE_AMOUNT; i++){ for(i = 0; i < TE_AMOUNT; i++){
switch(i){ switch(i){
case TE_CURSOR: case TE_CURSOR:
textures[TE_CURSOR] = malloc(2 * sizeof(Texture2D)); // So vielleicht textures[TE_CURSOR] = malloc(2 * sizeof(Texture2D));
LoadCursorTextures(textures[TE_CURSOR]); LoadCursorTextures(textures[TE_CURSOR]);
break; break;
case TE_WORKER: case TE_WORKER:
textures[TE_WORKER] = malloc(TE_ENTITY_LENGTH * sizeof(Texture2D));
LoadEntityTextures(textures[TE_WORKER], "worker"); LoadEntityTextures(textures[TE_WORKER], "worker");
break; break;
case TE_BUILDING: case TE_BUILDING:
textures[TE_BUILDING] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_BUILDING], "building"); LoadMapObjectTextures(textures[TE_BUILDING], "building");
break; break;
case TE_BAUSTELLE: case TE_BAUSTELLE:
textures[TE_BAUSTELLE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle"); LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle");
break; break;
default: default:
@ -69,8 +41,6 @@ void TextureAtlasLoadTextures(Texture2D **textures){
} }
void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix){ void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix){
// Das klappt so nicht
atlasrow = malloc(TE_ENTITY_LENGTH * sizeof(Texture2D));
// pathToFile wird erstellt. z.B. assets/entities/ + worker ---> assets/entities/worker/ // pathToFile wird erstellt. z.B. assets/entities/ + worker ---> assets/entities/worker/
char pathToFile[50] = "assets/entities/"; char pathToFile[50] = "assets/entities/";
@ -78,7 +48,7 @@ void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix){
strcat(pathToFile, "/"); strcat(pathToFile, "/");
char animation[30] = "walk"; char animation[30] = "walk";
char filename[100]; char filename[100] = "";
char number[3] = ""; char number[3] = "";
char ending[5] = ".png"; char ending[5] = ".png";
@ -152,7 +122,6 @@ void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix){
} }
void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix){ void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix){
atlasrow = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
// pathToFile wird erstellt. z.B. assets/mapobjects/ + building ---> assets/mapobjects/building/ // pathToFile wird erstellt. z.B. assets/mapobjects/ + building ---> assets/mapobjects/building/
char pathToFile[50] = "assets/mapobjects/"; char pathToFile[50] = "assets/mapobjects/";
@ -160,7 +129,7 @@ void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix){
strcat(pathToFile, "/"); strcat(pathToFile, "/");
//char animation[30] = "walk"; //char animation[30] = "walk";
char filename[100]; char filename[100] = "";
//char number[3] = ""; //char number[3] = "";
char ending[5] = ".png"; char ending[5] = ".png";
@ -173,83 +142,52 @@ void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix){
} }
void LoadCursorTextures(Texture2D *cursorTextures){ void LoadCursorTextures(Texture2D *cursorTextures){
cursorTextures = malloc(2 * sizeof(Texture2D));
cursorTextures[0] = LoadTexture("assets/cursor.gif"); cursorTextures[0] = LoadTexture("assets/cursor.gif");
cursorTextures[1] = LoadTexture("assets/cursor_down.gif"); cursorTextures[1] = LoadTexture("assets/cursor_down.gif");
} }
void LoadWorkerTextures(Texture2D *workerTextures){ void TextureAtlasLoadAnimations(Animation ****animations, Texture2D **textures){
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 i;
int file = 0; for(i = 0; i < AN_AMOUNT; i++){
for(i = 0; i < 104; i++){ switch(i){
// Concatenate the correct string for the filename (beginning + i + ending) case AN_WORKER:
sprintf(number, "%d", file); animations[AN_WORKER] = malloc(AN_ENTITY_AMOUNT * sizeof(Animation *));
strcat(filename, beginning); LoadEntityAnimations(animations[AN_WORKER], textures[TE_WORKER], AN_WORKER);
strcat(filename, number); break;
strcat(filename, ending); default:
printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED ANIMATION!!\n");
//printf("file:%s:file\n", filename);
// Set correct values for next iteration
int lol = i % 8;
// TODO: walk und umackern läuft nicht bis 24 sondern nur 23
if(lol == 0){
*(workerTextures + i) = LoadTexture(filename);
printf("\n");
file++;
} }
else if(lol == 2){
Image tmp = LoadImage(filename);
ImageFlipHorizontal(&tmp);
*(workerTextures + i) = LoadTextureFromImage(tmp);
printf("flipped\n");
file++;
} }
else if(lol == 4){
Image tmp = LoadImage(filename);
ImageFlipHorizontal(&tmp);
*(workerTextures + i) = LoadTextureFromImage(tmp);
printf("flipped\n");
file++;
} }
else if(lol == 6){
Image tmp = LoadImage(filename); void LoadEntityAnimations(Animation ***animationsrow, Texture2D *atlasrow, int id){
ImageFlipHorizontal(&tmp); int i;
*(workerTextures + i) = LoadTextureFromImage(tmp); int j;
printf("flipped\n"); int frame;
file++;
} for(i = 0; i < AN_ENTITY_AMOUNT; i++){
else if(lol == 7){ animationsrow[i] = malloc(DIRECTIONS_AMOUNT * sizeof(Animation));
*(workerTextures + i) = LoadTexture(filename);
printf("\n"); int obergrenze;
file++; if(i == AN_ENTITY_DIE){
obergrenze = 3;
} }
else{ else{
*(workerTextures + i) = LoadTexture(filename); obergrenze = 5;
printf("\n");
} }
strcpy(filename, ""); for(j = 0; j < DIRECTIONS_AMOUNT; j++){
strcpy(number, ""); Animation *newAnimation = AnimationInit();
frame = i * DIRECTIONS_AMOUNT * 5 + j;
if(i == 39){ int frameCounter;
strcpy(beginning, "assets/worker/umackern-"); for(frameCounter = 0; frameCounter < obergrenze; frameCounter++){
file = 0; AnimationInsertBack(newAnimation, (atlasrow + frame));
frame += 8;
} }
else if(i == 79){
strcpy(beginning, "assets/worker/die-"); animationsrow[i][j] = newAnimation;
file = 0;
} }
} }
} }

@ -9,18 +9,10 @@ typedef struct TextureAtlas TextureAtlas;
typedef struct TextureAtlas{ typedef struct TextureAtlas{
Texture2D *textures[TE_AMOUNT]; Texture2D *textures[TE_AMOUNT];
Animation ***animations[AN_AMOUNT];
Texture2D cursorTextures[2];
Animation *cursorAnimation[1];
Texture2D workerTextures[104];
Animation *workerAnimations[24]; Animation *workerAnimations[24];
Texture2D building;
Animation *buildingAnimation[8];
Texture2D baustelle;
Animation *baustelleAnimation[8];
} TextureAtlas; } TextureAtlas;
// Initialize the full TextureAtlas struct with all Textures used in the game // Initialize the full TextureAtlas struct with all Textures used in the game
@ -30,7 +22,8 @@ void LoadCursorTextures(Texture2D *cursorTextures);
void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix); void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix);
void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix); void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix);
void LoadWorkerTextures(Texture2D *workerTextures);
void LoadWorkerAnimations(Animation **workerAnimations, Texture2D *workerTextures); void LoadWorkerAnimations(Animation **workerAnimations, Texture2D *workerTextures);
void TextureAtlasLoadAnimations(Animation ****animations, Texture2D **textures);
void LoadEntityAnimations(Animation ***animationsrow, Texture2D *atlasrow, int id);
#endif #endif

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

@ -9,7 +9,9 @@
#define SW 6 #define SW 6
#define W 4 #define W 4
#define NW 2 #define NW 2
#define DIRECTIONS_AMOUNT 8
// Texture definitions
#define TE_CURSOR 0 #define TE_CURSOR 0
#define TE_WORKER 1 #define TE_WORKER 1
#define TE_BUILDING 2 #define TE_BUILDING 2
@ -19,4 +21,16 @@
#define TE_ENTITY_LENGTH 104 #define TE_ENTITY_LENGTH 104
#define TE_MAPOBJECT_LENGTH 1 #define TE_MAPOBJECT_LENGTH 1
// Definitions for animations
#define AN_WORKER 0
#define AN_AMOUNT 1
#define AN_ENTITY_AMOUNT 3
#define AN_ENTITY_IDLE 0
#define AN_ENTITY_ARBEITEN 1
#define AN_ENTITY_DIE 2
#endif #endif

@ -17,7 +17,7 @@ Game *GameInit()
game->textures = TextureAtlasInit(); game->textures = TextureAtlasInit();
game->cursorSprite = SpriteCreate(game->textures, 0, 450, 225); game->cursorSprite = SpriteCreate(game->textures, TE_CURSOR, 450, 225);
game->inputHandler = malloc(sizeof(InputHandler)); game->inputHandler = malloc(sizeof(InputHandler));
game->inputHandler->pressed = 0; game->inputHandler->pressed = 0;
game->inputHandler->rectStart.x = 0; game->inputHandler->rectStart.x = 0;
@ -29,7 +29,7 @@ Game *GameInit()
game->inputHandler->cursorWorldTile.x = 0; game->inputHandler->cursorWorldTile.x = 0;
game->inputHandler->cursorWorldTile.y = 0; game->inputHandler->cursorWorldTile.y = 0;
game->inputHandler->selectedLayer = -1; game->inputHandler->selectedLayer = -1;
game->inputHandler->cursorTextures = game->textures->cursorTextures; game->inputHandler->cursorTextures = game->textures->textures[TE_CURSOR];
game->inputHandler->cursorSprite = game->cursorSprite; game->inputHandler->cursorSprite = game->cursorSprite;
game->screen = SCREEN_MAINMENU; game->screen = SCREEN_MAINMENU;

Loading…
Cancel
Save