Jonathan Hager 3 years ago
commit 4761234a10
Signed by: JonathanHager
GPG Key ID: 34881E488569708C

@ -3,10 +3,14 @@
#include <stdio.h>
#include <stdlib.h>
#include "../Sprite/sprite.h"
#include "../MapObject/mapobject.h"
#include "../definitions.h"
#include "../Textures/textureatlas.h"
Entity * EntityInit(Sprite *sprite){
Entity * EntityInit(Sprite *sprite, int profession, TextureAtlas *atlas){
Entity *new = malloc(sizeof(Entity));
new->angle = 0;
new->sprite = sprite;
new->destX = 0;
new->destY = 0;
@ -14,6 +18,19 @@ Entity * EntityInit(Sprite *sprite){
new->selected = 0;
new->next = 0;
new->prev = 0;
new->task = TaskInit();
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;
}
@ -97,13 +114,82 @@ void EntityListActAllEntities(Game *game){
angle = angle * RAD2DEG;
angle -= 35.26;
current->sprite->angle = angle;
if(angle <= 22.5 && angle >= -22.5){
// E
AnimationChangeDirection(current->animationHandler, E);
}
else if(angle > 0 && angle <= 67.5){
// NE
AnimationChangeDirection(current->animationHandler, NE);
}
else if(angle > 0 && angle <= 112.5){
// N
AnimationChangeDirection(current->animationHandler, N);
}
else if(angle > 0 && angle <= 157.5){
// NW
AnimationChangeDirection(current->animationHandler, NW);
}
else if(angle < 0 && angle >= -67.5){
// SE
AnimationChangeDirection(current->animationHandler, SE);
}
else if(angle < 0 && angle >= -112.5){
// S
AnimationChangeDirection(current->animationHandler, S);
}
else if(angle < 0 && angle >= -157.5){
// SW
AnimationChangeDirection(current->animationHandler, SW);
}
else{
// W
AnimationChangeDirection(current->animationHandler, W);
}
}
}
else{
/*
if(current->profession == PR_BUILDER){
if(current->task->target == 0){
// Prüft, ob eine Baustelle existiert
MapObject *currentMO = game->mapObjects->head;
while(currentMO != 0){
if(currentMO->id == MO_Baustelle){
current->hasDestination = 1;
current->destX = currentMO->sprite->x;
current->destY = currentMO->sprite->y;
current->task->target = currentMO;
break;
}
currentMO = currentMO->next;
}
}
else{
// Is beim target angekommen
/*
MapObject *obj = current->task->target;
printf("Hier\n");
Sprite *new = SpriteCreate(game->textures, 2, obj->sprite->x, obj->sprite->y);
SpriteListRemove(game->sprites, obj->sprite);
SpriteListInsert(game->sprites, new);
free(obj->sprite);
MapObject *newObject = MapObjectInit(new, MO_Building);
MapObjectListRemove(game->mapObjects, obj);
MapObjectListInsert(game->mapObjects, newObject);
current->task->target = 0;
free(obj);
*/
//}
//}
}
SpriteUpdate(current->sprite);
AnimationUpdate(current->animationHandler);
SpriteUpdate(current->sprite);
SpriteListSpriteChanged(game->sprites, current->sprite);
current = current->next;

@ -2,15 +2,21 @@
#define ENTITY_H_
#include "../Sprite/sprite.h"
#include "../game.h"
#include "task.h"
#include "../Textures/animationHandler.h"
typedef struct Entity Entity;
typedef struct Entity{
Sprite *sprite;
AnimationHandler *animationHandler;
float angle;
float destX;
float destY;
int hasDestination;
int selected;
Task *task;
int profession;
Entity *next;
Entity *prev;
@ -21,7 +27,7 @@ typedef struct EntityList{
Entity *tail;
} EntityList;
Entity * EntityInit(Sprite *sprite);
Entity * EntityInit(Sprite *sprite, int profession, TextureAtlas *atlas);
EntityList * EntityListInit();
void EntityListPrintForward(EntityList *entities);

@ -0,0 +1,8 @@
#include <stdlib.h>
#include "task.h"
Task * TaskInit(){
Task *new = malloc(sizeof(Task));
new->target = 0;
return new;
}

@ -0,0 +1,12 @@
#ifndef TASK_H_
#define TASK_H_
typedef struct Task Task;
typedef struct Task{
void *target;
} Task;
Task * TaskInit();
#endif

@ -3,11 +3,13 @@
#include "../Sprite/sprite.h"
#include "../IsometricMap/isometricMap.h"
#include "../Entity/entity.h"
#include "../MapObject/mapobject.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "../IsometricMap/tile.h"
#include "../game.h"
#include "../definitions.h"
void DrawRect(Vector2 rectStart, Vector2 *mousePosition){
float width = GetMousePosition().x - rectStart.x;
@ -69,6 +71,16 @@ void mouseInput(Game *game){
IsometricMapChangeTextureIdOfTile(map, (int) inputHandler->cursorWorldTile.x, (int) inputHandler->cursorWorldTile.y, 0);
}
if(IsKeyPressed(KEY_G)){
// Baustelle adden
/*
Sprite *new = SpriteCreate(game->textures, 3, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y);
MapObject *newObject = MapObjectInit(new, MO_Baustelle);
SpriteListInsert(game->sprites, new);
MapObjectListInsert(game->mapObjects, newObject);
*/
}
// hardcoded layer amount
float tileWidthHalf = map->tileTextures[0].width / 2;
float tileHeightQuarter = map->tileTextures[0].height / 4;
@ -99,7 +111,7 @@ void mouseInput(Game *game){
inputHandler->pressed = 1;
// Cursorsprite is changed to "down"
inputHandler->cursorSprite->texture = (inputHandler->cursorTextures) + 1;
game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][1];
}
}
@ -111,7 +123,7 @@ void mouseInput(Game *game){
if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){
inputHandler->pressed = 0;
// 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 height = GetMousePosition().y - inputHandler->rectStart.y;
@ -125,8 +137,8 @@ void mouseInput(Game *game){
else if(inputHandler->cursorWorldPos.x > maxWidth){ printf("OutOfBoundsDestination Spawn\n");}
else if(inputHandler->cursorWorldPos.y > maxHeight){ printf("OutOfBoundsDestination Spawn\n");}
else {
Sprite *newSprite = SpriteCreate(game->textures, 1, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y);
Entity *entity = EntityInit(newSprite);
Sprite *newSprite = SpriteCreate(game->textures, TE_WORKER, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y);
Entity *entity = EntityInit(newSprite, TE_WORKER, game->textures);
EntityListInsert(game->entities, entity);
SpriteListInsert(game->sprites, newSprite);
//ListPrintForward(sprites);

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

@ -165,5 +165,4 @@ void IsometricMapDraw(Game *game){
}
}
SpriteListDrawAllSprites(game->sprites, game->map, game->camera);
}

@ -1,6 +1,6 @@
CC = gcc
FLAGS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
OBJS = main.o sprite.o inputHandler.o isometricMap.o game.o textureatlas.o animation.o animationHandler.o button.o uiContainer.o debug.o mapobject.o entity.o selectable.o
OBJS = main.o sprite.o inputHandler.o isometricMap.o game.o textureatlas.o animation.o animationHandler.o button.o uiContainer.o debug.o mapobject.o entity.o selectable.o task.o
spiel: $(OBJS)
$(CC) -o spiel $(OBJS) $(FLAGS)
@ -47,5 +47,8 @@ mapobject.o: MapObject/mapobject.c
selectable.o: Ui/selectable.c
$(CC) -c Ui/selectable.c $(FLAGS)
task.o: Entity/task.c
$(CC) -c Entity/task.c $(FLAGS)
clean:
rm *.o spiel

@ -1,10 +1,11 @@
#include "mapobject.h"
#include <stdlib.h>
MapObject * MapObjectInit(Sprite *sprite){
MapObject * MapObjectInit(Sprite *sprite, int id){
MapObject *new = malloc(sizeof(MapObject));
new->sprite = sprite;
new->id = id;
new->next = 0;
new->prev = 0;

@ -7,6 +7,7 @@ typedef struct MapObjectList MapObjectList;
typedef struct MapObject{
Sprite *sprite;
int id;
MapObject *next;
MapObject *prev;
@ -17,7 +18,7 @@ typedef struct MapObjectList{
MapObject *tail;
} MapObjectList;
MapObject * MapObjectInit(Sprite *sprite);
MapObject * MapObjectInit(Sprite *sprite, int id);
MapObjectList * MapObjectListInit();
void MapObjectListPrintForward(MapObjectList *mapObjects);

@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "../IsometricMap/isometricMap.h"
#include "../Textures/textureIDs.h"
#include "../definitions.h"
#include "../Textures/animationHandler.h"
#include "../Textures/animation.h"
#include "../Textures/textureatlas.h"
@ -43,68 +43,17 @@ void SpriteUpdate(Sprite *sprite){
sprite->depth = sprite->x + sprite->y + sprite->z;
if(sprite->angle <= 22.5 && sprite->angle >= -22.5){
// E
AnimationChangeAnimation(sprite->animationHandler, E);
}
else if(sprite->angle > 0 && sprite->angle <= 67.5){
// NE
AnimationChangeAnimation(sprite->animationHandler, NE);
}
else if(sprite->angle > 0 && sprite->angle <= 112.5){
// N
AnimationChangeAnimation(sprite->animationHandler, N);
}
else if(sprite->angle > 0 && sprite->angle <= 157.5){
// NW
AnimationChangeAnimation(sprite->animationHandler, NW);
}
else if(sprite->angle < 0 && sprite->angle >= -67.5){
// SE
AnimationChangeAnimation(sprite->animationHandler, SE);
}
else if(sprite->angle < 0 && sprite->angle >= -112.5){
// S
AnimationChangeAnimation(sprite->animationHandler, S);
}
else if(sprite->angle < 0 && sprite->angle >= -157.5){
// SW
AnimationChangeAnimation(sprite->animationHandler, SW);
}
else{
// W
AnimationChangeAnimation(sprite->animationHandler, W);
}
AnimationUpdate(sprite->animationHandler);
sprite->texture = sprite->animationHandler->currentFrame->texture;
// sprite->texture = sprite->animationHandler->currentFrame->texture;
}
Sprite * SpriteCreate(TextureAtlas *atlas, int textureID, int x, int y){
Sprite *newSprite = malloc(sizeof(Sprite));
//AnimationHandler create
Animation **animations = 0;
if(textureID == worker){
animations = atlas->workerAnimations;
}
else if(textureID == cursor){
animations = atlas->cursorAnimation;
}
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->texture = atlas->textures[textureID];
newSprite->x = x - newSprite->texture->width / 2;
newSprite->y = y - newSprite->texture->height / 2;
newSprite->z = 0;
newSprite->depth = newSprite->x + newSprite->y;
newSprite->angle = 0;
newSprite->next = 0;
newSprite->prev = 0;

@ -9,13 +9,11 @@ typedef struct Sprite Sprite;
typedef struct SpriteList SpriteList;
typedef struct Sprite {
AnimationHandler *animationHandler;
Texture2D *texture;
float x;
float y;
float z;
float depth;
float angle;
Sprite *next;
Sprite *prev;

@ -1,21 +1,26 @@
#include "animationHandler.h"
#include "animation.h"
#include "stdlib.h"
#include "stdio.h"
#include <stdlib.h>
#include <stdio.h>
AnimationHandler * AnimationHandlerInit(Animation **animations){
AnimationHandler * AnimationHandlerInit(Animation ***animations, Texture2D **spriteTexture){
AnimationHandler *new = malloc(sizeof(AnimationHandler));
new->spriteTexture = spriteTexture;
new->animations = animations;
new->currentAnimation = 0;
new->currentFrame = new->animations[new->currentAnimation]->head;
new->currentType = 0;
new->currentDirection = 0;
new->currentFrame = new->animations[new->currentType][new->currentDirection]->head;
new->spriteTexture = spriteTexture;
new->forward = 1;
new->deltaElapsed = 0;
return new;
}
void AnimationUpdate(AnimationHandler *animationHandler){
animationHandler->deltaElapsed += GetFrameTime();
if(animationHandler->deltaElapsed >= 0.2){
if(animationHandler->forward == 1){
animationHandler->currentFrame = animationHandler->currentFrame->next;
@ -26,17 +31,27 @@ void AnimationUpdate(AnimationHandler *animationHandler){
animationHandler->deltaElapsed = 0;
}
*(animationHandler->spriteTexture) = animationHandler->currentFrame->texture;
}
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;
}
void AnimationChangeAnimation(AnimationHandler *animationHandler, int newAnimation){
if(animationHandler->currentAnimation != newAnimation){
animationHandler->currentAnimation = newAnimation;
void AnimationChangeAnimation(AnimationHandler *animationHandler, int animationType, int direction){
if(animationHandler->currentType != animationType || animationHandler->currentDirection != direction){
animationHandler->currentType = animationType;
animationHandler->currentDirection = direction;
AnimationReset(animationHandler);
}
}
}
void AnimationChangeDirection(AnimationHandler *animationHandler, int direction){
if(animationHandler->currentDirection != direction){
animationHandler->currentDirection = direction;
AnimationReset(animationHandler);
}
}

@ -7,16 +7,19 @@
typedef struct AnimationHandler AnimationHandler;
typedef struct AnimationHandler{
Animation **animations;
Animation ***animations;
AnimationFrame *currentFrame;
int currentAnimation;
Texture2D **spriteTexture;
int currentType;
int currentDirection;
int forward;
float deltaElapsed;
} AnimationHandler;
AnimationHandler * AnimationHandlerInit(Animation **animations);
AnimationHandler * AnimationHandlerInit(Animation ***animations, Texture2D **spriteTexture);
void AnimationUpdate(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

@ -1,16 +0,0 @@
#ifndef TEXTUREIDS_H_
#define TEXTUREIDS_H_
#define N 0
#define NE 1
#define E 3
#define SE 5
#define S 7
#define SW 6
#define W 4
#define NW 2
#define cursor 0
#define worker 1
#endif

@ -5,28 +5,50 @@
#include "stdio.h"
TextureAtlas * TextureAtlasInit(){
TextureAtlas *textures = malloc(sizeof(TextureAtlas));
LoadCursorTextures(textures->cursorTextures, textures->cursorAnimation);
LoadWorkerTextures(textures->workerTextures);
LoadWorkerAnimations(textures->workerAnimations, textures->workerTextures);
TextureAtlas *new = malloc(sizeof(TextureAtlas));
TextureAtlasLoadTextures(new->textures);
//LoadWorkerAnimations(textures->workerAnimations, textures->workerTextures);
TextureAtlasLoadAnimations(new->animations, new->textures);
return textures;
return new;
}
void LoadCursorTextures(Texture2D *cursorTextures, Animation **cursorAnimation){
*cursorTextures = LoadTexture("assets/cursor.gif");
*(cursorTextures + 1) = LoadTexture("assets/cursor_down.gif");
Animation *new = AnimationInit();
AnimationInsertBack(new, cursorTextures);
cursorAnimation[0] = new;
void TextureAtlasLoadTextures(Texture2D **textures){
int i;
for(i = 0; i < TE_AMOUNT; i++){
switch(i){
case TE_CURSOR:
textures[TE_CURSOR] = malloc(2 * sizeof(Texture2D));
LoadCursorTextures(textures[TE_CURSOR]);
break;
case TE_WORKER:
textures[TE_WORKER] = malloc(TE_ENTITY_LENGTH * sizeof(Texture2D));
LoadEntityTextures(textures[TE_WORKER], "worker");
break;
case TE_BUILDING:
textures[TE_BUILDING] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_BUILDING], "building");
break;
case TE_BAUSTELLE:
textures[TE_BAUSTELLE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle");
break;
default:
printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED TEXTUREID!!\n");
}
}
}
void LoadWorkerTextures(Texture2D *workerTextures){
void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix){
char beginning[30] = "assets/worker/walk-";
char filename[30] = "";
// pathToFile wird erstellt. z.B. assets/entities/ + worker ---> assets/entities/worker/
char pathToFile[50] = "assets/entities/";
strcat(pathToFile, directoryPrefix);
strcat(pathToFile, "/");
char animation[30] = "walk";
char filename[100] = "";
char number[3] = "";
char ending[5] = ".png";
@ -34,10 +56,12 @@ void LoadWorkerTextures(Texture2D *workerTextures){
// 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)
for(i = 0; i < TE_ENTITY_LENGTH; i++){
// Concatenate the correct string for the filename assets/worker/ + walk + - + 5 + .png
sprintf(number, "%d", file);
strcat(filename, beginning);
strcat(filename, pathToFile);
strcat(filename, animation);
strcat(filename, "-");
strcat(filename, number);
strcat(filename, ending);
@ -46,41 +70,39 @@ void LoadWorkerTextures(Texture2D *workerTextures){
// 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);
atlasrow[i] = LoadTexture(filename);
printf("\n");
file++;
}
else if(lol == 2){
Image tmp = LoadImage(filename);
ImageFlipHorizontal(&tmp);
*(workerTextures + i) = LoadTextureFromImage(tmp);
atlasrow[i] = LoadTextureFromImage(tmp);
printf("flipped\n");
file++;
}
else if(lol == 4){
Image tmp = LoadImage(filename);
ImageFlipHorizontal(&tmp);
*(workerTextures + i) = LoadTextureFromImage(tmp);
atlasrow[i] = LoadTextureFromImage(tmp);
printf("flipped\n");
file++;
}
else if(lol == 6){
Image tmp = LoadImage(filename);
ImageFlipHorizontal(&tmp);
*(workerTextures + i) = LoadTextureFromImage(tmp);
atlasrow[i] = LoadTextureFromImage(tmp);
printf("flipped\n");
file++;
}
else if(lol == 7){
*(workerTextures + i) = LoadTexture(filename);
atlasrow[i] = LoadTexture(filename);
printf("\n");
file++;
}
else{
*(workerTextures + i) = LoadTexture(filename);
atlasrow[i] = LoadTexture(filename);
printf("\n");
}
@ -88,14 +110,86 @@ void LoadWorkerTextures(Texture2D *workerTextures){
strcpy(number, "");
if(i == 39){
strcpy(beginning, "assets/worker/umackern-");
strcpy(animation, "arbeiten");
file = 0;
}
else if(i == 79){
strcpy(beginning, "assets/worker/die-");
strcpy(animation, "die");
file = 0;
}
}
}
void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix){
// pathToFile wird erstellt. z.B. assets/mapobjects/ + building ---> assets/mapobjects/building/
char pathToFile[50] = "assets/mapobjects/";
strcat(pathToFile, directoryPrefix);
strcat(pathToFile, "/");
//char animation[30] = "walk";
char filename[100] = "";
//char number[3] = "";
char ending[5] = ".png";
strcat(filename, pathToFile);
strcat(filename, "idle");
strcat(filename, ending);
atlasrow[0] = LoadTexture(filename);
}
void LoadCursorTextures(Texture2D *cursorTextures){
cursorTextures[0] = LoadTexture("assets/cursor.gif");
cursorTextures[1] = LoadTexture("assets/cursor_down.gif");
}
void TextureAtlasLoadAnimations(Animation ****animations, Texture2D **textures){
int i;
for(i = 0; i < AN_AMOUNT; i++){
switch(i){
case AN_WORKER:
animations[AN_WORKER] = malloc(AN_ENTITY_AMOUNT * sizeof(Animation *));
LoadEntityAnimations(animations[AN_WORKER], textures[TE_WORKER], AN_WORKER);
break;
default:
printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED ANIMATION!!\n");
}
}
}
void LoadEntityAnimations(Animation ***animationsrow, Texture2D *atlasrow, int id){
int i;
int j;
int frame;
for(i = 0; i < AN_ENTITY_AMOUNT; i++){
animationsrow[i] = malloc(DIRECTIONS_AMOUNT * sizeof(Animation));
int obergrenze;
if(i == AN_ENTITY_DIE){
obergrenze = 3;
}
else{
obergrenze = 5;
}
for(j = 0; j < DIRECTIONS_AMOUNT; j++){
Animation *newAnimation = AnimationInit();
frame = i * DIRECTIONS_AMOUNT * 5 + j;
int frameCounter;
for(frameCounter = 0; frameCounter < obergrenze; frameCounter++){
AnimationInsertBack(newAnimation, (atlasrow + frame));
frame += 8;
}
animationsrow[i][j] = newAnimation;
}
}
}
void LoadWorkerAnimations(Animation **workerAnimations, Texture2D *workerTextures){

@ -2,23 +2,28 @@
#define TEXTUREATLAS_H_
#include "raylib.h"
#include "animation.h"
#include "../definitions.h"
typedef struct TextureAtlas TextureAtlas;
typedef struct TextureAtlas{
Texture2D cursorTextures[2];
Animation *cursorAnimation[1];
Texture2D *textures[TE_AMOUNT];
Animation ***animations[AN_AMOUNT];
Texture2D workerTextures[104];
Animation *workerAnimations[24];
//Texture2D[] mapTextures;
} TextureAtlas;
// Initialize the full TextureAtlas struct with all Textures used in the game
TextureAtlas * TextureAtlasInit();
void LoadCursorTextures(Texture2D *cursorTextures, Animation **cursorAnimation);
void LoadWorkerTextures(Texture2D *workerTextures);
void TextureAtlasLoadTextures(Texture2D **textures);
void LoadCursorTextures(Texture2D *cursorTextures);
void LoadEntityTextures(Texture2D *atlasrow, char *directoryPrefix);
void LoadMapObjectTextures(Texture2D *atlasrow, char *directoryPrefix);
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: 760 B

After

Width:  |  Height:  |  Size: 760 B

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 753 B

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 775 B

Before

Width:  |  Height:  |  Size: 728 B

After

Width:  |  Height:  |  Size: 728 B

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

Before

Width:  |  Height:  |  Size: 817 B

After

Width:  |  Height:  |  Size: 817 B

Before

Width:  |  Height:  |  Size: 754 B

After

Width:  |  Height:  |  Size: 754 B

Before

Width:  |  Height:  |  Size: 790 B

After

Width:  |  Height:  |  Size: 790 B

Before

Width:  |  Height:  |  Size: 754 B

After

Width:  |  Height:  |  Size: 754 B

Before

Width:  |  Height:  |  Size: 755 B

After

Width:  |  Height:  |  Size: 755 B

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 809 B

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 733 B

Before

Width:  |  Height:  |  Size: 749 B

After

Width:  |  Height:  |  Size: 749 B

Before

Width:  |  Height:  |  Size: 765 B

After

Width:  |  Height:  |  Size: 765 B

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 756 B

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 738 B

Before

Width:  |  Height:  |  Size: 767 B

After

Width:  |  Height:  |  Size: 767 B

Before

Width:  |  Height:  |  Size: 758 B

After

Width:  |  Height:  |  Size: 758 B

Before

Width:  |  Height:  |  Size: 816 B

After

Width:  |  Height:  |  Size: 816 B

Before

Width:  |  Height:  |  Size: 772 B

After

Width:  |  Height:  |  Size: 772 B

Before

Width:  |  Height:  |  Size: 736 B

After

Width:  |  Height:  |  Size: 736 B

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 700 B

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 777 B

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 812 B

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 814 B

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 814 B

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 814 B

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

Before

Width:  |  Height:  |  Size: 820 B

After

Width:  |  Height:  |  Size: 820 B

Before

Width:  |  Height:  |  Size: 704 B

After

Width:  |  Height:  |  Size: 704 B

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 757 B

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 757 B

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 771 B

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 692 B

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 700 B

Before

Width:  |  Height:  |  Size: 696 B

After

Width:  |  Height:  |  Size: 696 B

Before

Width:  |  Height:  |  Size: 688 B

After

Width:  |  Height:  |  Size: 688 B

Before

Width:  |  Height:  |  Size: 675 B

After

Width:  |  Height:  |  Size: 675 B

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 712 B

Before

Width:  |  Height:  |  Size: 764 B

After

Width:  |  Height:  |  Size: 764 B

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 689 B

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 670 B

Before

Width:  |  Height:  |  Size: 695 B

After

Width:  |  Height:  |  Size: 695 B

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 713 B

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 756 B

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 664 B

Before

Width:  |  Height:  |  Size: 688 B

After

Width:  |  Height:  |  Size: 688 B

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 679 B

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 682 B

Before

Width:  |  Height:  |  Size: 715 B

After

Width:  |  Height:  |  Size: 715 B

Before

Width:  |  Height:  |  Size: 770 B

After

Width:  |  Height:  |  Size: 770 B

Before

Width:  |  Height:  |  Size: 721 B

After

Width:  |  Height:  |  Size: 721 B

Before

Width:  |  Height:  |  Size: 761 B

After

Width:  |  Height:  |  Size: 761 B

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 692 B

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 691 B

Before

Width:  |  Height:  |  Size: 698 B

After

Width:  |  Height:  |  Size: 698 B

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 701 B

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 753 B

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

@ -0,0 +1,36 @@
#ifndef DEFINITIONS_H_
#define DEFINITIONS_H_
#define N 0
#define NE 1
#define E 3
#define SE 5
#define S 7
#define SW 6
#define W 4
#define NW 2
#define DIRECTIONS_AMOUNT 8
// Texture definitions
#define TE_CURSOR 0
#define TE_WORKER 1
#define TE_BUILDING 2
#define TE_BAUSTELLE 3
#define TE_AMOUNT 4
#define TE_ENTITY_LENGTH 104
#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

@ -18,7 +18,7 @@ Game *GameInit()
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->pressed = 0;
game->inputHandler->rectStart.x = 0;
@ -30,9 +30,6 @@ Game *GameInit()
game->inputHandler->cursorWorldTile.x = 0;
game->inputHandler->cursorWorldTile.y = 0;
game->inputHandler->selectedLayer = -1;
game->inputHandler->cursorTextures = game->textures->cursorTextures;
game->inputHandler->cursorSprite = game->cursorSprite;
game->screen = SCREEN_MAINMENU;
game->camera = malloc(sizeof(Camera2D));

@ -50,12 +50,14 @@ int main(){
return 0;
case SCREEN_GAME:
// Updating Sprites
// Updating Entities
EntityListActAllEntities(game);
// Drawing IsometricMap
BeginMode2D(*(game->camera)); // Sorgt dafür, dass die Kameraposition beachtet wird
IsometricMapDraw(game);
SpriteListDrawAllSprites(game->sprites, game->map, game->camera);
EndMode2D();
// User Input Handling

Loading…
Cancel
Save