diff --git a/Input/inputHandler.c b/Input/inputHandler.c index 7b9eb8a..b2ddabe 100644 --- a/Input/inputHandler.c +++ b/Input/inputHandler.c @@ -9,195 +9,210 @@ #include "../IsometricMap/tile.h" #include "../game.h" #include "../definitions.h" +#include "../MapObject/staticobjects.h" void DrawRect(Vector2 rectStart, Vector2 *mousePosition){ - float width = GetMousePosition().x - rectStart.x; - float height = GetMousePosition().y - rectStart.y; + float width = GetMousePosition().x - rectStart.x; + float height = GetMousePosition().y - rectStart.y; - rectStart = GetRectangle(rectStart); + rectStart = GetRectangle(rectStart); - DrawRectangleLines(rectStart.x, rectStart.y, abs(width), abs(height), GREEN); + DrawRectangleLines(rectStart.x, rectStart.y, abs(width), abs(height), GREEN); } Vector2 GetRectangle(Vector2 rectStart){ - float width = GetMousePosition().x - rectStart.x; - float height = GetMousePosition().y - rectStart.y; - - if(width < 0 && height >= 0){ - width *= -1; - rectStart.x -= width; - } - else if(height < 0 && width >= 0){ - height *= -1; - rectStart.y -= height; - } - else if(height < 0 && width < 0){ - height *= -1; - width *= -1; - rectStart.x -= width; - rectStart.y -= height; - } - return rectStart; + float width = GetMousePosition().x - rectStart.x; + float height = GetMousePosition().y - rectStart.y; + + if(width < 0 && height >= 0){ + width *= -1; + rectStart.x -= width; + } + else if(height < 0 && width >= 0){ + height *= -1; + rectStart.y -= height; + } + else if(height < 0 && width < 0){ + height *= -1; + width *= -1; + rectStart.x -= width; + rectStart.y -= height; + } + return rectStart; } void mouseInput(Game *game){ - InputHandler *inputHandler = game->inputHandler; - EntityList *entities = game->entities; - Camera2D *camera = game->camera; - IsometricMap *map = game->map; - Texture2D *texture = game->worker +4; - - inputHandler->cursorPos.x = GetMousePosition().x; - inputHandler->cursorPos.y = GetMousePosition().y; - - - // bissl Kamera Zoom - float maxZoom = 5.0f; - float minZoom = 0.2f; - if(IsKeyPressed(KEY_I)){ - if(camera->zoom < maxZoom){ - camera->zoom += 0.2f; - } - } - if(IsKeyPressed(KEY_K)){ - if(camera->zoom > minZoom){ - camera->zoom -= 0.2f; - } - } - // resetting last selected Tile to grass texture - if(inputHandler->selectedLayer != -1){ - IsometricMapChangeTextureIdOfTile(map, (int) inputHandler->cursorWorldTile.x, (int) inputHandler->cursorWorldTile.y, 0); - } - - // hardcoded layer amount - float tileWidthHalf = map->tileTextures[0].width / 2; - float tileHeightQuarter = map->tileTextures[0].height / 4; - int mouseAdjustmentX = -tileWidthHalf; - int mouseAdjustmentY = -tileHeightQuarter; - - // Updating inputHandler->cursorWorldPos Vector2D - IsometricMapProject(map, camera, - (inputHandler->cursorPos.x / camera->zoom) + mouseAdjustmentX, - (inputHandler->cursorPos.y / camera->zoom) + mouseAdjustmentY, - &inputHandler->cursorWorldPos); - - Tile *selectedTile = IsometricMapGetTileFromWorldCoordinates(game->map, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); - - if(selectedTile != 0){ - inputHandler->selectedLayer = 0; - inputHandler->cursorWorldTile.x = selectedTile->x; - inputHandler->cursorWorldTile.y = selectedTile->y; - // setting currently selected tile to tower - IsometricMapChangeTextureIdOfTile(map, inputHandler->cursorWorldTile.x, inputHandler->cursorWorldTile.y, 1); - } - - if(game->mouseOnUI == 0){ - if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){ - if(inputHandler->pressed == 0){ - inputHandler->rectStart.x = GetMousePosition().x; - inputHandler->rectStart.y = GetMousePosition().y; - inputHandler->pressed = 1; - - // Cursorsprite is changed to "down" - game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][1]; - } - } - } - - if(inputHandler->pressed){ - DrawRect(inputHandler->rectStart, &(inputHandler->cursorPos)); - } - - if(game->mouseOnUI == 0){ - if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){ - inputHandler->pressed = 0; - // Cursorsprite is changed back to normal - game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][0]; - float width = GetMousePosition().x - inputHandler->rectStart.x; - float height = GetMousePosition().y - inputHandler->rectStart.y; - - - // Add Sprite - if(abs(width) + abs(height) < 20){ - int maxWidth = (game->map->width) * game->map->textureWidth; - int maxHeight = (game->map->height) * game->map->textureHeight; - if(inputHandler->cursorWorldPos.x < 0){ printf("OutOfBoundsDestination Spawn\n");} - else if(inputHandler->cursorWorldPos.y < 0){ 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 { - //Sprite *newSprite = SpriteCreate(game->textures, TE_WORKER, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); - //Entity *entity = EntityInit(newSprite, PR_BUILDER, game->textures); - //EntityListInsert(game->entities, entity); - //SpriteListInsert(game->sprites, newSprite); - //ListPrintForward(sprites); - //ListInsertSorted(sprites, SpriteCreate(game->textures, 1, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y)); - } - } else{ - // Berechnung, welche Sprites ausgewählt wurden - Vector2 rect = GetRectangle(inputHandler->rectStart); - width = abs(width); - height = abs(height); - - float deltaX; - float deltaY; - Entity *current = game->entities->head; - while (current != 0){ - Vector2 currPos = {current->sprite->x + current->sprite->texture->width, current->sprite->y + current->sprite->texture->height/2}; - IsometricMapUnproject(map, camera, currPos.x, currPos.y, current->sprite->z, &currPos); - - deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x); - deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y); - - if(deltaX > 0 && deltaX < width && deltaY > 0 && deltaY < height){ - current->selected = 1; + InputHandler *inputHandler = game->inputHandler; + EntityList *entities = game->entities; + Camera2D *camera = game->camera; + IsometricMap *map = game->map; + Texture2D *texture = game->worker +4; + + inputHandler->cursorPos.x = GetMousePosition().x; + inputHandler->cursorPos.y = GetMousePosition().y; + + + // bissl Kamera Zoom + float maxZoom = 5.0f; + float minZoom = 0.2f; + if(IsKeyPressed(KEY_I)){ + if(camera->zoom < maxZoom){ + camera->zoom += 0.2f; } - else{ - current->selected = 0; + } + if(IsKeyPressed(KEY_K)){ + if(camera->zoom > minZoom){ + camera->zoom -= 0.2f; } - current = current->next; - } + } + + // Temp code for testing HOLZHACKERLEUTE, weil ich net versteh wie die iButtons hmmpf. früher bescheid wisse! + if(IsKeyPressed(KEY_G)){ + //Baum + StaticObject *tree = StaticObjectInit(game, SO_PINETREE, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); + StaticObjectListInsert(game->objects, tree); + SpriteListPrintForward(game->sprites); + } + + if(IsKeyPressed(KEY_H)){ + //Holzkacker + + } + + // resetting last selected Tile to grass texture + if(inputHandler->selectedLayer != -1){ + IsometricMapChangeTextureIdOfTile(map, (int) inputHandler->cursorWorldTile.x, (int) inputHandler->cursorWorldTile.y, 0); + } + + // hardcoded layer amount + float tileWidthHalf = map->tileTextures[0].width / 2; + float tileHeightQuarter = map->tileTextures[0].height / 4; + int mouseAdjustmentX = -tileWidthHalf; + int mouseAdjustmentY = -tileHeightQuarter; + + // Updating inputHandler->cursorWorldPos Vector2D + IsometricMapProject(map, camera, + (inputHandler->cursorPos.x / camera->zoom) + mouseAdjustmentX, + (inputHandler->cursorPos.y / camera->zoom) + mouseAdjustmentY, + &inputHandler->cursorWorldPos); + + Tile *selectedTile = IsometricMapGetTileFromWorldCoordinates(game->map, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); + + if(selectedTile != 0){ + inputHandler->selectedLayer = 0; + inputHandler->cursorWorldTile.x = selectedTile->x; + inputHandler->cursorWorldTile.y = selectedTile->y; + // setting currently selected tile to tower + IsometricMapChangeTextureIdOfTile(map, inputHandler->cursorWorldTile.x, inputHandler->cursorWorldTile.y, 1); + } + + if(game->mouseOnUI == 0){ + if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)){ + if(inputHandler->pressed == 0){ + inputHandler->rectStart.x = GetMousePosition().x; + inputHandler->rectStart.y = GetMousePosition().y; + inputHandler->pressed = 1; + + // Cursorsprite is changed to "down" + game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][1]; + } } - } - - if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)){ - Entity *current = game->entities->head; - - while (current != 0){ - if(current->selected){ - current->hasDestination = 1; - float destX = inputHandler->cursorWorldPos.x; - float destY = inputHandler->cursorWorldPos.y; - int maxWidth = (game->map->width-1) * game->map->textureWidth; - int maxHeight = (game->map->height-1) * game->map->textureHeight; - if(destX < 0){ printf("OutOfBoundsDestination\n"); goto skip; } - if(destY < 0){ printf("OutOfBoundsDestination\n"); goto skip; } - if(destX > maxWidth){ printf("OutOfBoundsDestination\n"); goto skip; } - if(destY > maxHeight){ printf("OutOfBoundsDestination\n"); goto skip; } - - current->destX = destX; - current->destY = destY; - } - - skip: current = current->next; - } - } -} + } + + if(inputHandler->pressed){ + DrawRect(inputHandler->rectStart, &(inputHandler->cursorPos)); + } + + if(game->mouseOnUI == 0){ + if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){ + inputHandler->pressed = 0; + // Cursorsprite is changed back to normal + game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][0]; + float width = GetMousePosition().x - inputHandler->rectStart.x; + float height = GetMousePosition().y - inputHandler->rectStart.y; + + + // Add Sprite + if(abs(width) + abs(height) < 20){ + int maxWidth = (game->map->width) * game->map->textureWidth; + int maxHeight = (game->map->height) * game->map->textureHeight; + if(inputHandler->cursorWorldPos.x < 0){ printf("OutOfBoundsDestination Spawn\n");} + else if(inputHandler->cursorWorldPos.y < 0){ 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 { + //Sprite *newSprite = SpriteCreate(game->textures, TE_WORKER, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y); + //Entity *entity = EntityInit(newSprite, PR_BUILDER, game->textures); + //EntityListInsert(game->entities, entity); + //SpriteListInsert(game->sprites, newSprite); + //ListPrintForward(sprites); + //ListInsertSorted(sprites, SpriteCreate(game->textures, 1, inputHandler->cursorWorldPos.x, inputHandler->cursorWorldPos.y)); + } + } else{ + // Berechnung, welche Sprites ausgewählt wurden + Vector2 rect = GetRectangle(inputHandler->rectStart); + width = abs(width); + height = abs(height); + + float deltaX; + float deltaY; + Entity *current = game->entities->head; + while (current != 0){ + Vector2 currPos = {current->sprite->x + current->sprite->texture->width, current->sprite->y + current->sprite->texture->height/2}; + IsometricMapUnproject(map, camera, currPos.x, currPos.y, current->sprite->z, &currPos); + + deltaX = currPos.x - camera->target.x - (rect.x + camera->target.x); + deltaY = currPos.y - camera->target.y - (rect.y + camera->target.y); + + if(deltaX > 0 && deltaX < width && deltaY > 0 && deltaY < height){ + current->selected = 1; + } + else{ + current->selected = 0; + } + current = current->next; + } + } + } + + if(IsMouseButtonPressed(MOUSE_BUTTON_RIGHT)){ + Entity *current = game->entities->head; + + while (current != 0){ + if(current->selected){ + current->hasDestination = 1; + float destX = inputHandler->cursorWorldPos.x; + float destY = inputHandler->cursorWorldPos.y; + int maxWidth = (game->map->width-1) * game->map->textureWidth; + int maxHeight = (game->map->height-1) * game->map->textureHeight; + if(destX < 0){ printf("OutOfBoundsDestination\n"); goto skip; } + if(destY < 0){ printf("OutOfBoundsDestination\n"); goto skip; } + if(destX > maxWidth){ printf("OutOfBoundsDestination\n"); goto skip; } + if(destY > maxHeight){ printf("OutOfBoundsDestination\n"); goto skip; } + + current->destX = destX; + current->destY = destY; + } + +skip: current = current->next; + } + } + } } void keyboardInput(InputHandler *inputHandler, Camera2D *camera){ - float camSpeed = 1000.0f; - if(IsKeyDown(KEY_W)){ - (*camera).target.y -= camSpeed * GetFrameTime(); - } - if(IsKeyDown(KEY_S)){ - (*camera).target.y += camSpeed * GetFrameTime(); - } - if(IsKeyDown(KEY_D)){ - (*camera).target.x += camSpeed * GetFrameTime(); - } - if(IsKeyDown(KEY_A)){ - (*camera).target.x -= camSpeed * GetFrameTime(); - } + float camSpeed = 1000.0f; + if(IsKeyDown(KEY_W)){ + (*camera).target.y -= camSpeed * GetFrameTime(); + } + if(IsKeyDown(KEY_S)){ + (*camera).target.y += camSpeed * GetFrameTime(); + } + if(IsKeyDown(KEY_D)){ + (*camera).target.x += camSpeed * GetFrameTime(); + } + if(IsKeyDown(KEY_A)){ + (*camera).target.x -= camSpeed * GetFrameTime(); + } } diff --git a/Makefile b/Makefile index 92a35a9..2964d2c 100644 --- a/Makefile +++ b/Makefile @@ -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 building.o entity.o selectable.o task.o entityacts.o onClickFunctions.o +FLAGS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -g +OBJS = main.o sprite.o inputHandler.o isometricMap.o game.o textureatlas.o animation.o animationHandler.o button.o uiContainer.o debug.o building.o entity.o selectable.o task.o entityacts.o onClickFunctions.o staticobjects.o spiel: $(OBJS) $(CC) -o spiel $(OBJS) $(FLAGS) @@ -56,5 +56,8 @@ entityacts.o: Entity/entityacts.c onClickFunctions.o: Ui/onClickFunctions.c $(CC) -c Ui/onClickFunctions.c $(FLAGS) +staticobjects.o: MapObject/staticobjects.c + $(CC) -c MapObject/staticobjects.c $(FLAGS) + clean: rm *.o spiel diff --git a/MapObject/staticobjects.c b/MapObject/staticobjects.c new file mode 100644 index 0000000..2fdb6b9 --- /dev/null +++ b/MapObject/staticobjects.c @@ -0,0 +1,77 @@ +#include "staticobjects.h" +#include +#include "../game.h" +#include "../Sprite/sprite.h" + +StaticObject * StaticObjectInit(Game *game, int id, int x, int y){ + int textureId = 0; + + switch(id){ + case SO_PINETREE: + textureId = TE_PINETREE; + break; + default: + printf("WARNING: STATICOBJECTINIT MIT FALSCHER ID AUFGERUFEN\n"); + } + + Sprite *newSprite = SpriteCreate(game->textures, textureId, x, y); + SpriteListInsert(game->sprites, newSprite); + + StaticObject *new = malloc(sizeof(StaticObject)); + + new->sprite = newSprite; + new->id = id; + + new->next = 0; + new->prev = 0; + + return new; +} + +StaticObjectList * StaticObjectListInit(){ + StaticObjectList *new = malloc(sizeof(StaticObjectList)); + new->head = 0; + new->tail = 0; + return new; +} + +void StaticObjectListPrintForward(StaticObjectList *objects){ + +} + +void StaticObjectListInsert(StaticObjectList *objects, StaticObject *data){ + if(objects->head == 0){ + objects->head = data; + objects->tail = data; + } + else{ + objects->tail->next = data; + data->prev = objects->tail; + objects->tail = data; + } +} + +void StaticObjectListRemove(StaticObjectList *objects, StaticObject *remove){ + if(remove == 0){ + printf("WARNING: TRIED TO REMOVE NULLPOINTER\n"); + } + else if(objects->head == remove && objects->tail == remove){ + objects->head = 0; + objects->tail = 0; + } + else if(objects->head == remove){ + remove->next->prev = 0; + objects->head = remove->next; + } + else if(objects->tail == remove){ + remove->prev->next = 0; + objects->tail = remove->prev; + } + else{ + remove->prev->next = remove->next; + remove->next->prev = remove->prev; + } + + remove->next = 0; + remove->prev = 0; +} diff --git a/MapObject/staticobjects.h b/MapObject/staticobjects.h new file mode 100644 index 0000000..d489d09 --- /dev/null +++ b/MapObject/staticobjects.h @@ -0,0 +1,26 @@ +#ifndef STATICOBJECTS_H_ +#define STATICOBJECTS_H_ +#include "../Sprite/sprite.h" +#include "../game.h" + +typedef struct StaticObject{ + Sprite *sprite; + int id; + + struct StaticObject *next; + struct StaticObject *prev; +} StaticObject; + +typedef struct StaticObjectList { + StaticObject *head; + StaticObject *tail; +} StaticObjectList; + +StaticObject * StaticObjectInit(Game *game, int id, int x, int y); +StaticObjectList * StaticObjectListInit(); + +void StaticObjectListPrintForward(StaticObjectList *objects); +void StaticObjectListInsert(StaticObjectList *objects, StaticObject *data); +void StaticObjectListRemove(StaticObjectList *objects, StaticObject *remove); + +#endif diff --git a/README.md b/README.md index 0d5d434..9c55b43 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ KI Gegner ist erstmal zu aufwändig, ein wenig Ackern muss man aber immer! [turn off EXIT on ESC Key, for later](https://github.com/raysan5/raylib/issues/520) +[Texturentyp](https://opengameart.org/content/germanic-worker) + ## TODO Zu Function Pointern: diff --git a/Sprite/sprite.c b/Sprite/sprite.c index 59e00d4..a9144b0 100644 --- a/Sprite/sprite.c +++ b/Sprite/sprite.c @@ -82,6 +82,8 @@ void SpriteListInsertBefore(SpriteList *list, Sprite *new, Sprite *current){ else{ new->prev->next = new; } + + list->spriteAmount++; } void SpriteListInsertAfter(SpriteList *list, Sprite *new, Sprite *current){ @@ -95,6 +97,8 @@ void SpriteListInsertAfter(SpriteList *list, Sprite *new, Sprite *current){ else{ new->next->prev = new; } + + list->spriteAmount++; } void SpriteListInsert(SpriteList *list, Sprite *new){ @@ -102,6 +106,8 @@ void SpriteListInsert(SpriteList *list, Sprite *new){ if(list->head == 0){ list->head = new; list->tail = new; + + list->spriteAmount++; } else{ Sprite *current = list->head; @@ -116,6 +122,7 @@ void SpriteListInsert(SpriteList *list, Sprite *new){ SpriteListInsertAfter(list, new, list->tail); } + } void SpriteListSpriteChanged(SpriteList *list, Sprite *changed){ @@ -160,18 +167,22 @@ void SpriteListRemove(SpriteList *list, Sprite *remove){ else if(list->head == remove && list->tail == remove){ list->head = 0; list->tail = 0; + list->spriteAmount--; } else if(list->head == remove){ remove->next->prev = 0; list->head = remove->next; + list->spriteAmount--; } else if(list->tail == remove){ remove->prev->next = 0; list->tail = remove->prev; + list->spriteAmount--; } else{ remove->prev->next = remove->next; remove->next->prev = remove->prev; + list->spriteAmount--; } remove->next = 0; @@ -182,6 +193,7 @@ SpriteList * SpriteListInit(){ SpriteList *newSpriteList = malloc(sizeof(SpriteList)); newSpriteList->head = 0; newSpriteList->tail = 0; + newSpriteList->spriteAmount = 0; return newSpriteList; } diff --git a/Sprite/sprite.h b/Sprite/sprite.h index 8f819e8..9e6e7c9 100644 --- a/Sprite/sprite.h +++ b/Sprite/sprite.h @@ -22,6 +22,7 @@ typedef struct Sprite { typedef struct SpriteList { Sprite *head; Sprite *tail; + int spriteAmount; } SpriteList; void DrawSpriteToWorld(Sprite *sprite, IsometricMap *map, Camera2D *camera); diff --git a/Textures/textureatlas.c b/Textures/textureatlas.c index 22cf718..905d82b 100644 --- a/Textures/textureatlas.c +++ b/Textures/textureatlas.c @@ -34,6 +34,9 @@ void TextureAtlasLoadTextures(Texture2D **textures){ textures[TE_BAUSTELLE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D)); LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle"); break; + case TE_PINETREE: + textures[TE_PINETREE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D)); + LoadMapObjectTextures(textures[TE_PINETREE], "pinetree"); default: printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED TEXTUREID!!\n"); } diff --git a/Ui/debug.c b/Ui/debug.c index a0f5f8e..ec7b602 100644 --- a/Ui/debug.c +++ b/Ui/debug.c @@ -23,6 +23,7 @@ void DebugDraw(Game *game){ sprintf(strings[lineamount++], "Selected Layer: %d", game->inputHandler->selectedLayer); sprintf(strings[lineamount++], "DEPTH: %d", (int)(game->inputHandler->cursorWorldPos.x + game->inputHandler->cursorWorldPos.y + game->inputHandler->selectedLayer)); sprintf(strings[lineamount++], "Camera Zoom: %f", game->camera->zoom); + sprintf(strings[lineamount++], "Sprite Amount: %d", game->sprites->spriteAmount); // Hier müssten wir eine bessere Lösung finden, das flackert weil pressed nur für einen Frame gilt. Eine ähnliche Funktion gibt es für CharDown leider nicht, müssten wir selbst programmieren. Ich habe es erstmal nicht auskommentiert. Kann man aber easy machen sollte es stören int pressed = GetCharPressed(); diff --git a/assets/mapobjects/pinetree/idle.png b/assets/mapobjects/pinetree/idle.png new file mode 100644 index 0000000..dc84658 Binary files /dev/null and b/assets/mapobjects/pinetree/idle.png differ diff --git a/definitions.h b/definitions.h index 88ce607..8a42c86 100644 --- a/definitions.h +++ b/definitions.h @@ -16,8 +16,9 @@ #define TE_WORKER 1 #define TE_BUILDING 2 #define TE_BAUSTELLE 3 +#define TE_PINETREE 4 -#define TE_AMOUNT 4 +#define TE_AMOUNT 5 #define TE_ENTITY_LENGTH 104 #define TE_MAPOBJECT_LENGTH 1 @@ -34,10 +35,12 @@ // Definitions for buildings #define BU_HOUSE 0 +// Defintions for static map objects +#define SO_PINETREE 0 + // Defintions for professions #define PR_BUILDER 0 - // Definitions for Screen / View / Ui Stuff #define DEBUG_FONT_SIZE 20 diff --git a/game.c b/game.c index 38711d0..5424167 100644 --- a/game.c +++ b/game.c @@ -9,6 +9,7 @@ #include "Entity/entity.h" #include "MapObject/building.h" #include "Ui/uiContainer.h" +#include "MapObject/staticobjects.h" // returns pointer to new Game instance Game *GameInit() @@ -46,6 +47,7 @@ Game *GameInit() game->entities = EntityListInit(); game->buildings = BuildingListInit(); + game->objects = StaticObjectListInit(); game->map = IsometricMapInit(); //das du es weißt man kann wenn du nicht auf hört was machen und dann bist du leise es gibt was das nett sich rufmord diff --git a/game.h b/game.h index cdf6ff2..534b7a8 100644 --- a/game.h +++ b/game.h @@ -14,6 +14,7 @@ typedef struct Game{ struct Camera2D *camera; struct IsometricMap *map; struct BuildingList *buildings; + struct StaticObjectList *objects; struct EntityList *entities; struct UiContainer *UiContainers[SCREEN_AMOUNT]; int screen; diff --git a/main.c b/main.c index 198908a..2bf30b6 100644 --- a/main.c +++ b/main.c @@ -53,7 +53,6 @@ int main(){ printf("OPTIONS \n"); return 0; case SCREEN_GAME: - // Updating Entities EntityListActAllEntities(game);