diff options
author | UnavailableDev <ggwildplay@gmail.com> | 2023-03-10 14:08:14 +0100 |
---|---|---|
committer | UnavailableDev <ggwildplay@gmail.com> | 2023-03-10 14:08:14 +0100 |
commit | 19737533abb3eeb90c97691618336b5cead14656 (patch) | |
tree | 01963569ac9bb4cb7e90744b06bdd6aba0560421 /src/engine | |
parent | 1fdac4d8ab609e8d496918929eb963be3f3a824f (diff) | |
parent | 4a740898621dcfc16fe257b6fe8695c768ec4dd6 (diff) |
merge
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/TODO/hh_combat.h | 9 | ||||
-rw-r--r-- | src/engine/TODO/hh_draw_screen.h | 1 | ||||
-rw-r--r-- | src/engine/TODO/hh_entity.c | 41 | ||||
-rw-r--r-- | src/engine/TODO/hh_entity.h | 24 | ||||
-rw-r--r-- | src/engine/TODO/hh_level.h | 1 | ||||
-rw-r--r-- | src/engine/TODO/hh_rand.h | 1 | ||||
-rw-r--r-- | src/engine/TODO/maths.c | 1 | ||||
-rw-r--r-- | src/engine/TODO/maths.h | 16 | ||||
-rw-r--r-- | src/engine/TODO/player_controller.h | 4 | ||||
-rw-r--r-- | src/engine/TODO/sprite_controller.h | 6 |
10 files changed, 104 insertions, 0 deletions
diff --git a/src/engine/TODO/hh_combat.h b/src/engine/TODO/hh_combat.h new file mode 100644 index 0000000..16c41f5 --- /dev/null +++ b/src/engine/TODO/hh_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/hh_draw_screen.h b/src/engine/TODO/hh_draw_screen.h new file mode 100644 index 0000000..f5d7507 --- /dev/null +++ b/src/engine/TODO/hh_draw_screen.h @@ -0,0 +1 @@ +// 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 new file mode 100644 index 0000000..fa550d5 --- /dev/null +++ b/src/engine/TODO/hh_entity.c @@ -0,0 +1,41 @@ +#include <stdbool.h> + +#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 new file mode 100644 index 0000000..fdbeb8a --- /dev/null +++ b/src/engine/TODO/hh_entity.h @@ -0,0 +1,24 @@ +#pragma once + +#include <stdint.h> + +#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 new file mode 100644 index 0000000..43b19a3 --- /dev/null +++ b/src/engine/TODO/hh_level.h @@ -0,0 +1 @@ +//deal with loading/saving the correct level diff --git a/src/engine/TODO/hh_rand.h b/src/engine/TODO/hh_rand.h new file mode 100644 index 0000000..ea7c1d4 --- /dev/null +++ b/src/engine/TODO/hh_rand.h @@ -0,0 +1 @@ +// deal with Pseudo random number generation here. diff --git a/src/engine/TODO/maths.c b/src/engine/TODO/maths.c new file mode 100644 index 0000000..d1bb089 --- /dev/null +++ b/src/engine/TODO/maths.c @@ -0,0 +1 @@ +#include "maths.h" diff --git a/src/engine/TODO/maths.h b/src/engine/TODO/maths.h new file mode 100644 index 0000000..032e56d --- /dev/null +++ b/src/engine/TODO/maths.h @@ -0,0 +1,16 @@ +#pragma once +#include <stdint.h> +// #include <math.h> + +typedef struct { + uint32_t x,y; +} vec2; + +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)) + +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) +#define CLAMP(N,LOWER,UPPER) (MIN(MAX(LOWER, N), UPPER)) diff --git a/src/engine/TODO/player_controller.h b/src/engine/TODO/player_controller.h new file mode 100644 index 0000000..1e9b86c --- /dev/null +++ b/src/engine/TODO/player_controller.h @@ -0,0 +1,4 @@ +#include "maths.h" +#include "hh_entity.h" + +// inputs diff --git a/src/engine/TODO/sprite_controller.h b/src/engine/TODO/sprite_controller.h new file mode 100644 index 0000000..c1fadff --- /dev/null +++ b/src/engine/TODO/sprite_controller.h @@ -0,0 +1,6 @@ +// handles sprites + +// Bg sprites + + +// Fg or entity sprites |