Neues hinzugefügt und so

main
Jonathan Hager 3 years ago
parent c526c257cc
commit 2a9feb24e2
Signed by: JonathanHager
GPG Key ID: 34881E488569708C

@ -9,195 +9,210 @@
#include "../IsometricMap/tile.h" #include "../IsometricMap/tile.h"
#include "../game.h" #include "../game.h"
#include "../definitions.h" #include "../definitions.h"
#include "../MapObject/staticobjects.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;
float height = GetMousePosition().y - rectStart.y; 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){ Vector2 GetRectangle(Vector2 rectStart){
float width = GetMousePosition().x - rectStart.x; float width = GetMousePosition().x - rectStart.x;
float height = GetMousePosition().y - rectStart.y; float height = GetMousePosition().y - rectStart.y;
if(width < 0 && height >= 0){ if(width < 0 && height >= 0){
width *= -1; width *= -1;
rectStart.x -= width; rectStart.x -= width;
} }
else if(height < 0 && width >= 0){ else if(height < 0 && width >= 0){
height *= -1; height *= -1;
rectStart.y -= height; rectStart.y -= height;
} }
else if(height < 0 && width < 0){ else if(height < 0 && width < 0){
height *= -1; height *= -1;
width *= -1; width *= -1;
rectStart.x -= width; rectStart.x -= width;
rectStart.y -= height; rectStart.y -= height;
} }
return rectStart; return rectStart;
} }
void mouseInput(Game *game){ void mouseInput(Game *game){
InputHandler *inputHandler = game->inputHandler; InputHandler *inputHandler = game->inputHandler;
EntityList *entities = game->entities; EntityList *entities = game->entities;
Camera2D *camera = game->camera; Camera2D *camera = game->camera;
IsometricMap *map = game->map; IsometricMap *map = game->map;
Texture2D *texture = game->worker +4; Texture2D *texture = game->worker +4;
inputHandler->cursorPos.x = GetMousePosition().x; inputHandler->cursorPos.x = GetMousePosition().x;
inputHandler->cursorPos.y = GetMousePosition().y; inputHandler->cursorPos.y = GetMousePosition().y;
// bissl Kamera Zoom // bissl Kamera Zoom
float maxZoom = 5.0f; float maxZoom = 5.0f;
float minZoom = 0.2f; float minZoom = 0.2f;
if(IsKeyPressed(KEY_I)){ if(IsKeyPressed(KEY_I)){
if(camera->zoom < maxZoom){ if(camera->zoom < maxZoom){
camera->zoom += 0.2f; 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;
} }
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)){ if(inputHandler->pressed){
Entity *current = game->entities->head; DrawRect(inputHandler->rectStart, &(inputHandler->cursorPos));
}
while (current != 0){
if(current->selected){ if(game->mouseOnUI == 0){
current->hasDestination = 1; if(IsMouseButtonReleased(MOUSE_BUTTON_LEFT)){
float destX = inputHandler->cursorWorldPos.x; inputHandler->pressed = 0;
float destY = inputHandler->cursorWorldPos.y; // Cursorsprite is changed back to normal
int maxWidth = (game->map->width-1) * game->map->textureWidth; game->cursorSprite->texture = &game->textures->textures[TE_CURSOR][0];
int maxHeight = (game->map->height-1) * game->map->textureHeight; float width = GetMousePosition().x - inputHandler->rectStart.x;
if(destX < 0){ printf("OutOfBoundsDestination\n"); goto skip; } float height = GetMousePosition().y - inputHandler->rectStart.y;
if(destY < 0){ printf("OutOfBoundsDestination\n"); goto skip; }
if(destX > maxWidth){ printf("OutOfBoundsDestination\n"); goto skip; }
if(destY > maxHeight){ printf("OutOfBoundsDestination\n"); goto skip; } // Add Sprite
if(abs(width) + abs(height) < 20){
current->destX = destX; int maxWidth = (game->map->width) * game->map->textureWidth;
current->destY = destY; 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");}
skip: current = current->next; 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){ void keyboardInput(InputHandler *inputHandler, Camera2D *camera){
float camSpeed = 1000.0f; float camSpeed = 1000.0f;
if(IsKeyDown(KEY_W)){ if(IsKeyDown(KEY_W)){
(*camera).target.y -= camSpeed * GetFrameTime(); (*camera).target.y -= camSpeed * GetFrameTime();
} }
if(IsKeyDown(KEY_S)){ if(IsKeyDown(KEY_S)){
(*camera).target.y += camSpeed * GetFrameTime(); (*camera).target.y += camSpeed * GetFrameTime();
} }
if(IsKeyDown(KEY_D)){ if(IsKeyDown(KEY_D)){
(*camera).target.x += camSpeed * GetFrameTime(); (*camera).target.x += camSpeed * GetFrameTime();
} }
if(IsKeyDown(KEY_A)){ if(IsKeyDown(KEY_A)){
(*camera).target.x -= camSpeed * GetFrameTime(); (*camera).target.x -= camSpeed * GetFrameTime();
} }
} }

@ -1,6 +1,6 @@
CC = gcc CC = gcc
FLAGS = -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 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 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) spiel: $(OBJS)
$(CC) -o spiel $(OBJS) $(FLAGS) $(CC) -o spiel $(OBJS) $(FLAGS)
@ -56,5 +56,8 @@ entityacts.o: Entity/entityacts.c
onClickFunctions.o: Ui/onClickFunctions.c onClickFunctions.o: Ui/onClickFunctions.c
$(CC) -c Ui/onClickFunctions.c $(FLAGS) $(CC) -c Ui/onClickFunctions.c $(FLAGS)
staticobjects.o: MapObject/staticobjects.c
$(CC) -c MapObject/staticobjects.c $(FLAGS)
clean: clean:
rm *.o spiel rm *.o spiel

@ -0,0 +1,77 @@
#include "staticobjects.h"
#include <stdlib.h>
#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;
}

@ -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

@ -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) [turn off EXIT on ESC Key, for later](https://github.com/raysan5/raylib/issues/520)
[Texturentyp](https://opengameart.org/content/germanic-worker)
## TODO ## TODO
Zu Function Pointern: Zu Function Pointern:

@ -82,6 +82,8 @@ void SpriteListInsertBefore(SpriteList *list, Sprite *new, Sprite *current){
else{ else{
new->prev->next = new; new->prev->next = new;
} }
list->spriteAmount++;
} }
void SpriteListInsertAfter(SpriteList *list, Sprite *new, Sprite *current){ void SpriteListInsertAfter(SpriteList *list, Sprite *new, Sprite *current){
@ -95,6 +97,8 @@ void SpriteListInsertAfter(SpriteList *list, Sprite *new, Sprite *current){
else{ else{
new->next->prev = new; new->next->prev = new;
} }
list->spriteAmount++;
} }
void SpriteListInsert(SpriteList *list, Sprite *new){ void SpriteListInsert(SpriteList *list, Sprite *new){
@ -102,6 +106,8 @@ void SpriteListInsert(SpriteList *list, Sprite *new){
if(list->head == 0){ if(list->head == 0){
list->head = new; list->head = new;
list->tail = new; list->tail = new;
list->spriteAmount++;
} }
else{ else{
Sprite *current = list->head; Sprite *current = list->head;
@ -116,6 +122,7 @@ void SpriteListInsert(SpriteList *list, Sprite *new){
SpriteListInsertAfter(list, new, list->tail); SpriteListInsertAfter(list, new, list->tail);
} }
} }
void SpriteListSpriteChanged(SpriteList *list, Sprite *changed){ void SpriteListSpriteChanged(SpriteList *list, Sprite *changed){
@ -160,18 +167,22 @@ void SpriteListRemove(SpriteList *list, Sprite *remove){
else if(list->head == remove && list->tail == remove){ else if(list->head == remove && list->tail == remove){
list->head = 0; list->head = 0;
list->tail = 0; list->tail = 0;
list->spriteAmount--;
} }
else if(list->head == remove){ else if(list->head == remove){
remove->next->prev = 0; remove->next->prev = 0;
list->head = remove->next; list->head = remove->next;
list->spriteAmount--;
} }
else if(list->tail == remove){ else if(list->tail == remove){
remove->prev->next = 0; remove->prev->next = 0;
list->tail = remove->prev; list->tail = remove->prev;
list->spriteAmount--;
} }
else{ else{
remove->prev->next = remove->next; remove->prev->next = remove->next;
remove->next->prev = remove->prev; remove->next->prev = remove->prev;
list->spriteAmount--;
} }
remove->next = 0; remove->next = 0;
@ -182,6 +193,7 @@ SpriteList * SpriteListInit(){
SpriteList *newSpriteList = malloc(sizeof(SpriteList)); SpriteList *newSpriteList = malloc(sizeof(SpriteList));
newSpriteList->head = 0; newSpriteList->head = 0;
newSpriteList->tail = 0; newSpriteList->tail = 0;
newSpriteList->spriteAmount = 0;
return newSpriteList; return newSpriteList;
} }

@ -22,6 +22,7 @@ typedef struct Sprite {
typedef struct SpriteList { typedef struct SpriteList {
Sprite *head; Sprite *head;
Sprite *tail; Sprite *tail;
int spriteAmount;
} SpriteList; } SpriteList;
void DrawSpriteToWorld(Sprite *sprite, IsometricMap *map, Camera2D *camera); void DrawSpriteToWorld(Sprite *sprite, IsometricMap *map, Camera2D *camera);

@ -34,6 +34,9 @@ void TextureAtlasLoadTextures(Texture2D **textures){
textures[TE_BAUSTELLE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D)); textures[TE_BAUSTELLE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle"); LoadMapObjectTextures(textures[TE_BAUSTELLE], "baustelle");
break; break;
case TE_PINETREE:
textures[TE_PINETREE] = malloc(TE_MAPOBJECT_LENGTH * sizeof(Texture2D));
LoadMapObjectTextures(textures[TE_PINETREE], "pinetree");
default: default:
printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED TEXTUREID!!\n"); printf("WARNING: TEXTUREATLAS TRIED LOADING NON DEFINED TEXTUREID!!\n");
} }

@ -23,6 +23,7 @@ void DebugDraw(Game *game){
sprintf(strings[lineamount++], "Selected Layer: %d", game->inputHandler->selectedLayer); 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++], "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++], "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 // 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(); int pressed = GetCharPressed();

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@ -16,8 +16,9 @@
#define TE_WORKER 1 #define TE_WORKER 1
#define TE_BUILDING 2 #define TE_BUILDING 2
#define TE_BAUSTELLE 3 #define TE_BAUSTELLE 3
#define TE_PINETREE 4
#define TE_AMOUNT 4 #define TE_AMOUNT 5
#define TE_ENTITY_LENGTH 104 #define TE_ENTITY_LENGTH 104
#define TE_MAPOBJECT_LENGTH 1 #define TE_MAPOBJECT_LENGTH 1
@ -34,10 +35,12 @@
// Definitions for buildings // Definitions for buildings
#define BU_HOUSE 0 #define BU_HOUSE 0
// Defintions for static map objects
#define SO_PINETREE 0
// Defintions for professions // Defintions for professions
#define PR_BUILDER 0 #define PR_BUILDER 0
// Definitions for Screen / View / Ui Stuff // Definitions for Screen / View / Ui Stuff
#define DEBUG_FONT_SIZE 20 #define DEBUG_FONT_SIZE 20

@ -9,6 +9,7 @@
#include "Entity/entity.h" #include "Entity/entity.h"
#include "MapObject/building.h" #include "MapObject/building.h"
#include "Ui/uiContainer.h" #include "Ui/uiContainer.h"
#include "MapObject/staticobjects.h"
// returns pointer to new Game instance // returns pointer to new Game instance
Game *GameInit() Game *GameInit()
@ -46,6 +47,7 @@ Game *GameInit()
game->entities = EntityListInit(); game->entities = EntityListInit();
game->buildings = BuildingListInit(); game->buildings = BuildingListInit();
game->objects = StaticObjectListInit();
game->map = IsometricMapInit(); 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 //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

@ -14,6 +14,7 @@ typedef struct Game{
struct Camera2D *camera; struct Camera2D *camera;
struct IsometricMap *map; struct IsometricMap *map;
struct BuildingList *buildings; struct BuildingList *buildings;
struct StaticObjectList *objects;
struct EntityList *entities; struct EntityList *entities;
struct UiContainer *UiContainers[SCREEN_AMOUNT]; struct UiContainer *UiContainers[SCREEN_AMOUNT];
int screen; int screen;

@ -53,7 +53,6 @@ int main(){
printf("OPTIONS \n"); printf("OPTIONS \n");
return 0; return 0;
case SCREEN_GAME: case SCREEN_GAME:
// Updating Entities // Updating Entities
EntityListActAllEntities(game); EntityListActAllEntities(game);

Loading…
Cancel
Save