parent
1c1d919672
commit
ac9072fe01
@ -0,0 +1,52 @@
|
|||||||
|
#include "../game.h"
|
||||||
|
#include "selectable.h"
|
||||||
|
#include "button.h"
|
||||||
|
#include "../definitions.h"
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "../MapObject/building.h"
|
||||||
|
#include "../Sprite/sprite.h"
|
||||||
|
#include "../Entity/entity.h"
|
||||||
|
#include "../Input/inputHandler.h"
|
||||||
|
|
||||||
|
void OnClickButton(Game *game, Button *button){
|
||||||
|
printf("\n\n\n\n\n\n Unsupported Button ID %d \n\n\n\n\n\n", button->id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void OnClickContinueButton(Game *game, Button *button){
|
||||||
|
game->screen = SCREEN_GAME;
|
||||||
|
}
|
||||||
|
void OnClickExitButton(Game *game, Button *button){
|
||||||
|
game->screen = SCREEN_EXIT;
|
||||||
|
}
|
||||||
|
void OnClickStartButton(Game *game, Button *button){
|
||||||
|
game->screen = SCREEN_GAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Hier sollte eine Bedingung stehen die nur in einem Frame true sein kann
|
||||||
|
// Oder das selectable wird abgewählt indem seine ID auf default zurückgesetzt wird
|
||||||
|
// Sonst kann das hier jeden Frame passieren. ID wird nicht automatisch zurückgesetzt
|
||||||
|
void OnSelectedSelectable(Game *game, Selectable *selectable){
|
||||||
|
printf("\n\n\n\n\n\n WARNING: Unsupported SELECTABLE ID %d \n\n\n\n\n\n", selectable->id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void OnSelectedSpawnBuilding(Game *game, Selectable *selectable){
|
||||||
|
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT) && game->mouseOnUI == 0){
|
||||||
|
Building *newObject = BuildingInit(game, BU_HOUSE, game->inputHandler->cursorWorldPos.x, game->inputHandler->cursorWorldPos.y);
|
||||||
|
BuildingListInsert(game->buildings, newObject);
|
||||||
|
|
||||||
|
selectable->state = SELECTABLE_STATE_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void OnSelectedSpawnWorker(Game *game, Selectable *selectable){
|
||||||
|
if(IsMouseButtonDown(MOUSE_BUTTON_LEFT) && game->mouseOnUI == 0){
|
||||||
|
Sprite *newSprite = SpriteCreate(game->textures, TE_WORKER, game->inputHandler->cursorWorldPos.x, game->inputHandler->cursorWorldPos.y);
|
||||||
|
Entity *entity = EntityInit(newSprite, PR_BUILDER, game->textures);
|
||||||
|
EntityListInsert(game->entities, entity);
|
||||||
|
SpriteListInsert(game->sprites, newSprite);
|
||||||
|
|
||||||
|
selectable->state = SELECTABLE_STATE_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef ONCLICK_H_
|
||||||
|
#define ONCLICK_H_
|
||||||
|
|
||||||
|
#include "../game.h"
|
||||||
|
#include "button.h"
|
||||||
|
#include "selectable.h"
|
||||||
|
|
||||||
|
void OnClickButton(Game *game, Button *button);
|
||||||
|
void OnClickContinueButton(Game *game, Button *button);
|
||||||
|
void OnClickExitButton(Game *game, Button *button);
|
||||||
|
void OnClickStartButton(Game *game, Button *button);
|
||||||
|
void OnSelectedSelectable(Game *game, Selectable *selectable);
|
||||||
|
void OnSelectedSpawnBuilding(Game *game, Selectable *selectable);
|
||||||
|
void OnSelectedSpawnWorker(Game *game, Selectable *selectable);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in new issue