From e3e0feb56340a72545b6fd38f22e134cf2e3509a Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Fri, 10 Mar 2023 14:23:05 +0100 Subject: fixed code styles --- src/engine/TODO/combat.h | 9 +++++++++ src/engine/TODO/draw_screen.h | 1 + src/engine/TODO/entity.c | 41 ++++++++++++++++++++++++++++++++++++++++ src/engine/TODO/entity.h | 24 +++++++++++++++++++++++ src/engine/TODO/hh_combat.h | 9 --------- src/engine/TODO/hh_draw_screen.h | 1 - src/engine/TODO/hh_entity.c | 41 ---------------------------------------- src/engine/TODO/hh_entity.h | 24 ----------------------- src/engine/TODO/hh_level.h | 1 - src/engine/TODO/hh_rand.h | 1 - src/engine/TODO/level.h | 4 ++++ src/engine/TODO/maths.c | 1 - src/engine/TODO/maths.h | 3 ++- 13 files changed, 81 insertions(+), 79 deletions(-) create mode 100644 src/engine/TODO/combat.h create mode 100644 src/engine/TODO/draw_screen.h create mode 100644 src/engine/TODO/entity.c create mode 100644 src/engine/TODO/entity.h delete mode 100644 src/engine/TODO/hh_combat.h delete mode 100644 src/engine/TODO/hh_draw_screen.h delete mode 100644 src/engine/TODO/hh_entity.c delete mode 100644 src/engine/TODO/hh_entity.h delete mode 100644 src/engine/TODO/hh_level.h delete mode 100644 src/engine/TODO/hh_rand.h create mode 100644 src/engine/TODO/level.h delete mode 100644 src/engine/TODO/maths.c (limited to 'src/engine') diff --git a/src/engine/TODO/combat.h b/src/engine/TODO/combat.h new file mode 100644 index 0000000..16c41f5 --- /dev/null +++ b/src/engine/TODO/combat.h @@ -0,0 +1,9 @@ +#include "hh_entity.h" + + +// attacktypes: + +/// @brief basic attack +/// @param dmg damage number +/// @param target entity under attack (damage changes this hp value) +void hh_attack_basic( int8_t dmg, hh_entity* target ); diff --git a/src/engine/TODO/draw_screen.h b/src/engine/TODO/draw_screen.h new file mode 100644 index 0000000..f5d7507 --- /dev/null +++ b/src/engine/TODO/draw_screen.h @@ -0,0 +1 @@ +// every function call for drawing the screen goes here. diff --git a/src/engine/TODO/entity.c b/src/engine/TODO/entity.c new file mode 100644 index 0000000..fa550d5 --- /dev/null +++ b/src/engine/TODO/entity.c @@ -0,0 +1,41 @@ +#include + +#include "hh_entity.h" +#include "maths.h" + +/* + PLAYER: (pos on X) + ,___, + | | + | X | + |___| + +*/ + +bool hh_collision(vec2* pos1, vec2* pos2){ + if (pos2->x == CLAMP(pos2->x,pos1->x,pos1->x+1.0f)){// hit x + return true; + } + + if (pos2->y == CLAMP(pos2->y,pos1->y,pos1->y+0.99f)){// hit y + return true; + } + return false; +} + +void hh_solve_collision(vec2* pos_environment, hh_entity* entity){ + if (entity->vec.x > 0.0f){ + entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f); + entity->vec.x = 0.0f; + } else if (entity->vec.x < 0.0f){ + entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f); + entity->vec.x = 0.0f; + } else if (entity->vec.y > 0.0f){ + entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f); + entity->vec.x = 0.0f; + } else if (entity->vec.y < 0.0f){ + entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f); + entity->vec.x = 0.0f; + } +} + diff --git a/src/engine/TODO/entity.h b/src/engine/TODO/entity.h new file mode 100644 index 0000000..fdbeb8a --- /dev/null +++ b/src/engine/TODO/entity.h @@ -0,0 +1,24 @@ +#pragma once + +#include + +#include "maths.h" + +typedef struct { + vec2 pos, vec; + bool is_grounded; + int8_t hp; + //armor/block? +}hh_entity; + +/// @brief detect for collision enity and eviroment +/// @param pos1 position of environment tile to be checked +/// @param pos2 position entity +/// @return true if collision between enity and environment +bool hh_collision(vec2* pos1, vec2* pos2); + +/// @brief solve collisions +/// @param environment position +/// @param entity position +/// @return solved new entity position +void hh_solve_collision(vec2* pos_environment, hh_entity* entity); diff --git a/src/engine/TODO/hh_combat.h b/src/engine/TODO/hh_combat.h deleted file mode 100644 index 16c41f5..0000000 --- a/src/engine/TODO/hh_combat.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "hh_entity.h" - - -// attacktypes: - -/// @brief basic attack -/// @param dmg damage number -/// @param target entity under attack (damage changes this hp value) -void hh_attack_basic( int8_t dmg, hh_entity* target ); diff --git a/src/engine/TODO/hh_draw_screen.h b/src/engine/TODO/hh_draw_screen.h deleted file mode 100644 index f5d7507..0000000 --- a/src/engine/TODO/hh_draw_screen.h +++ /dev/null @@ -1 +0,0 @@ -// every function call for drawing the screen goes here. diff --git a/src/engine/TODO/hh_entity.c b/src/engine/TODO/hh_entity.c deleted file mode 100644 index fa550d5..0000000 --- a/src/engine/TODO/hh_entity.c +++ /dev/null @@ -1,41 +0,0 @@ -#include - -#include "hh_entity.h" -#include "maths.h" - -/* - PLAYER: (pos on X) - ,___, - | | - | X | - |___| - -*/ - -bool hh_collision(vec2* pos1, vec2* pos2){ - if (pos2->x == CLAMP(pos2->x,pos1->x,pos1->x+1.0f)){// hit x - return true; - } - - if (pos2->y == CLAMP(pos2->y,pos1->y,pos1->y+0.99f)){// hit y - return true; - } - return false; -} - -void hh_solve_collision(vec2* pos_environment, hh_entity* entity){ - if (entity->vec.x > 0.0f){ - entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f); - entity->vec.x = 0.0f; - } else if (entity->vec.x < 0.0f){ - entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f); - entity->vec.x = 0.0f; - } else if (entity->vec.y > 0.0f){ - entity->pos.x = MIN(entity->pos.x,pos_environment->x-1.0f); - entity->vec.x = 0.0f; - } else if (entity->vec.y < 0.0f){ - entity->pos.x = MAX(entity->pos.x,pos_environment->x+1.0f); - entity->vec.x = 0.0f; - } -} - diff --git a/src/engine/TODO/hh_entity.h b/src/engine/TODO/hh_entity.h deleted file mode 100644 index fdbeb8a..0000000 --- a/src/engine/TODO/hh_entity.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -#include - -#include "maths.h" - -typedef struct { - vec2 pos, vec; - bool is_grounded; - int8_t hp; - //armor/block? -}hh_entity; - -/// @brief detect for collision enity and eviroment -/// @param pos1 position of environment tile to be checked -/// @param pos2 position entity -/// @return true if collision between enity and environment -bool hh_collision(vec2* pos1, vec2* pos2); - -/// @brief solve collisions -/// @param environment position -/// @param entity position -/// @return solved new entity position -void hh_solve_collision(vec2* pos_environment, hh_entity* entity); diff --git a/src/engine/TODO/hh_level.h b/src/engine/TODO/hh_level.h deleted file mode 100644 index 43b19a3..0000000 --- a/src/engine/TODO/hh_level.h +++ /dev/null @@ -1 +0,0 @@ -//deal with loading/saving the correct level diff --git a/src/engine/TODO/hh_rand.h b/src/engine/TODO/hh_rand.h deleted file mode 100644 index ea7c1d4..0000000 --- a/src/engine/TODO/hh_rand.h +++ /dev/null @@ -1 +0,0 @@ -// deal with Pseudo random number generation here. diff --git a/src/engine/TODO/level.h b/src/engine/TODO/level.h new file mode 100644 index 0000000..09f77e7 --- /dev/null +++ b/src/engine/TODO/level.h @@ -0,0 +1,4 @@ +//deal with loading/saving the correct level + +/** @brief */ +void hh_map_load(); diff --git a/src/engine/TODO/maths.c b/src/engine/TODO/maths.c deleted file mode 100644 index d1bb089..0000000 --- a/src/engine/TODO/maths.c +++ /dev/null @@ -1 +0,0 @@ -#include "maths.h" diff --git a/src/engine/TODO/maths.h b/src/engine/TODO/maths.h index 032e56d..c7f1b44 100644 --- a/src/engine/TODO/maths.h +++ b/src/engine/TODO/maths.h @@ -9,7 +9,8 @@ typedef struct { typedef vec2 vec_cen;//centered typedef vec2 vec_cor;//left upper corner -#define HH_MATH_FIXED_POINT 7 //fixed point at decimal 7lsb (world positions in pixels (with fixed decimal point)) +//fixed point at decimal 7lsb (world positions in pixels (with fixed decimal point)) +#define HH_MATH_FIXED_POINT 7 #define MIN(a,b) (((a)<(b))?(a):(b)) #define MAX(a,b) (((a)>(b))?(a):(b)) -- cgit v1.2.3