From 2a9feb24e27bff5bad5b015dc6eb693fc61d6769 Mon Sep 17 00:00:00 2001 From: Jonathan Hager Date: Tue, 24 Jan 2023 01:01:42 +0100 Subject: [PATCH] =?UTF-8?q?Neues=20hinzugef=C3=BCgt=20und=20so?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Input/inputHandler.c | 363 +++++++++++++++------------- Makefile | 7 +- MapObject/staticobjects.c | 77 ++++++ MapObject/staticobjects.h | 26 ++ README.md | 2 + Sprite/sprite.c | 12 + Sprite/sprite.h | 1 + Textures/textureatlas.c | 3 + Ui/debug.c | 1 + assets/mapobjects/pinetree/idle.png | Bin 0 -> 2155 bytes definitions.h | 7 +- game.c | 2 + game.h | 1 + main.c | 1 - 14 files changed, 324 insertions(+), 179 deletions(-) create mode 100644 MapObject/staticobjects.c create mode 100644 MapObject/staticobjects.h create mode 100644 assets/mapobjects/pinetree/idle.png 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 0000000000000000000000000000000000000000..dc846589f5e4a62adadcd85a26ef3a417eeddbd2 GIT binary patch literal 2155 zcmV-x2$c7UP)EX>4Tx04R}tkv&MmP!xqvTct%R4rUN>$WWauh>D1lR-p(LLaorMgUL((ph-iL z;^HW{799LptU9+0Yt2!cN#t}afBE>hxsNufoI7as59yn7Ds-3J646{cBTV}PdH zW;&S=v$<6<{E7e~5D>zQ%q(M0l2Y)kuY2mIx{LEH|Gqz~SIt`t2#Cb9%rI@@4dSUy z+u*!UEU=QS5}y-~nshu?YAB-u8*$ooQY@tDJmKRXbo~;!6mpfp z$gzMbG{~+W{11N5)+$Vldr8p*(EZ{#AHzU+7iiWU=lj@knkPW$8MxBh{%Ql5{v^HL z)?!CM-!^b@-PV*n;Bp5Tcrs*DcBK%lV4(oKpV2qvfc{&cXU&^i>l~*KK!#?Ox&aOj zfsrC*ulu|^(mA((ds_4R0a7$_nqSz#cK`qY24YJ`L;z|40000g!PJug000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j>9@6(SC0riyt0000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}000I;Nkl-EV3y;tN-_Ip zXLY*E*>}N-VA1Ta_r3SM@4Yt?@PGfvW3he6`@uuO=f?uy%z^o_z$B92#({@Y|0oP_ z^bc`n@U>BM?kADNMjIq+f?3nxUuA#+PEJQXaCYcxm=IqY{jTcSiAf}ZV}k_P`p!NY z17=MFRy{`zz=8Wrd`T+q?ZEtn*qVa6Xm1f^vL+zL_EA#c=hT#h(g>W)CDNoqo&%Fp zz!U^T7X05 z2d3X+s}`X(UJw8v&w=R_Zf&%^zB&z&tjUSg6a-VY@BDr{&fqTk8OW4`<@3l1%@hPV z7BB@NIk!>sH$SfyVbAH?(s4IMF}BkQuzVglngJl5kFe1O-kc+2$>0X zPAYq^yr_|Hfca9ul!SZ($Vl7}_TDm-#}?eFzOeZ;8kkOSLtO4XCEPWs1g0Pt_3E_K zf+-2*vDo@fJn_MmB&hEKJe>`@d|ncs+SZSu43Ou595w&|8a4Rz;Tl63;Mz3!SOyqg zTd=1id!Pa2SYUV<01fc*RiA;tr$#M8N3k5+ymBr%0;4Uh%tmSK{d{AYlS;V5x5qYD zKZV=98ej$hKrO;vfA=Y5Fu>$kE@Pmlrj7fX!md*6asc;=L5`&>1U2 zmRd?nBYLIBb5g04`d{GKl<^c>}ugwAT$IE*Hk!lq<8=|->LYMn@MJFtqf9bz%I0RYTmKuADmHHxyMY8Kl;A|v4#;1TRfvvp>pO|N8q7MXIL)%`79 ziop}a*y<~wdMj|%G&nl4P3BNGh-M)~eT_repl$@DXz&g$MZoz=)v^fb~NG`a(iX4Xcsrk*qWKCgQWh)iJl zqi`?r!z@lV63s$)KAl>f?3NfmXA0`=oP6i|oiN7MSFP_U8}=h(hS(VZy>%$NZpcpf zy#}ep4t7(p8%37(!IL%h08L@97o~6x6=l~Abyh=;MNj=Q5^n4Mgcte>xc=O@s9CiD zFgyrwv=~BXwW|)D)i{U*-oI-g>T4V=hWL;IY7!v7xW++17#$7qZcVs+1?Z-M(d2NL z0l^CuSw}`O?NxlT28`}D7)2=%&33l&nxHc)#QY_YgCJJ|SlN53Y^Uf*;0&GyRD|tx zB#?}816X7N;i|jN`q;N-X80O^{0dVgupEcbhH#eCAOL`qIC2rNmt0Z|E;8Y|n#kuoaHodd&06Z$SZ`0VU3rbc-Nv%J_Sa$`@`#`9^BZL=M}jWFcW3k8TOkJ zN5*Z|kGg2h`Wp`gAd&*w(CxpBmg5j7afIne^hD_ooZS-jsrH>1E1N>LF&zo0kwheg z6JXDQvz!Ln5YnP@Oswio(cBdo+-SliBUEqNKPNH^$We1Ca@n!icNy6GgK;$#Tc57H zvLZb%>b<+-(K9$ldcQGSCL<|a&cFC?x|4ahRU?VCsGKpboV+3@tn;Go0rI&|_oIBc hTK;LxW%i%{{0-l{dvDMu)vEvi002ovPDHLkV1jWh^F#mu literal 0 HcmV?d00001 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);