feat: add Inventar struct, add SeedCount in inventar, display seedCount on Screen
This commit is contained in:
+4
-1
@@ -82,6 +82,7 @@ void UpdateGame(GameState* g, State *state){
|
||||
UpdateFloor(&g->floor, &g->camera);
|
||||
UpdatePlayer(&g->player);
|
||||
UpdateBee(&g->bee1, &g->flowers, &g->hive);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -91,6 +92,7 @@ void RenderComponents(GameState* g){
|
||||
RenderObjectArray(&g->flowers);
|
||||
RenderSprite(&g->player.sprite);
|
||||
RenderSprite(&g->bee1.sprite);
|
||||
|
||||
}
|
||||
|
||||
void RenderGame(GameState* g){
|
||||
@@ -106,7 +108,8 @@ void RenderGame(GameState* g){
|
||||
for (int i = 0; i < SHADER_COUNT; i++){
|
||||
RenderPostFX(&g->postFX[i], &g->target);
|
||||
}
|
||||
DrawFPS(10, 10);
|
||||
DrawText( TextFormat("%d", g->player.inventar.seedCount), 10, 10, 50, WHITE);
|
||||
//DrawFPS(10, 10);
|
||||
EndDrawing();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef INVENTAR_H
|
||||
#define INVENTAR_H
|
||||
|
||||
|
||||
typedef struct{
|
||||
int seedCount;
|
||||
} Inventar;
|
||||
|
||||
#endif // INVENTAR_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../engine/animation.h"
|
||||
#include "../engine/physics.h"
|
||||
#include "../engine/input.h"
|
||||
#include "inventar.h"
|
||||
|
||||
typedef enum {
|
||||
IDLE,
|
||||
@@ -46,6 +47,7 @@ typedef struct {
|
||||
Sprite sprite;
|
||||
Animation animation;
|
||||
Physics physics;
|
||||
Inventar inventar;
|
||||
} Player;
|
||||
|
||||
Player CreatePlayer(PlayerAnimationState animState, SelectedTool selectedTool, Texture2D texture, float frameWidth, int maxFrame, int framesSpeed, Vector2 startPosition, float rotation, float speed){
|
||||
@@ -72,6 +74,9 @@ Player CreatePlayer(PlayerAnimationState animState, SelectedTool selectedTool, T
|
||||
.position = startPosition,
|
||||
.direction = (Vector2){0.0f,0.0f},
|
||||
.speed = speed
|
||||
},
|
||||
.inventar = {
|
||||
.seedCount = 6
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -111,6 +116,9 @@ void UpdatePlayerAnimationState(int *state, SelectedTool *selectedTool, Vector2
|
||||
}
|
||||
|
||||
void UpdatePlayer(Player* player){
|
||||
if (IsKeyPressed(KEY_SPACE) && player->inventar.seedCount >0){
|
||||
player->inventar.seedCount--;
|
||||
}
|
||||
Vector2 dir = GetDirectionVector();
|
||||
UpdatePlayerAnimationState(&player->animation.state, &player->selectedTool, &dir);
|
||||
UpdatePhysics(&player->physics, dir);
|
||||
|
||||
Reference in New Issue
Block a user