aboutsummaryrefslogtreecommitdiff
path: root/src/engine/TODO
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-03-10 16:44:25 +0100
committerGitHub <noreply@github.com>2023-03-10 16:44:25 +0100
commit3c7f8d25c226510bd391c6b61e89e7f732ce3072 (patch)
treebd88048f7612af72a2ecd7643d2c4d677fb27a6a /src/engine/TODO
parent80e2732c8f208f3f225a2a5c0e540bc50fceab5d (diff)
parent877ac831461f35d00e0e0ab7d6afbe93768fc7c6 (diff)
Merge pull request #27 from UnavailableDev/game-engine
Game engine
Diffstat (limited to 'src/engine/TODO')
-rw-r--r--src/engine/TODO/combat.h9
-rw-r--r--src/engine/TODO/draw_screen.h1
-rw-r--r--src/engine/TODO/entity.c41
-rw-r--r--src/engine/TODO/entity.h24
-rw-r--r--src/engine/TODO/level.h4
-rw-r--r--src/engine/TODO/maths.h17
-rw-r--r--src/engine/TODO/player_controller.h4
-rw-r--r--src/engine/TODO/sprite_controller.h6
8 files changed, 106 insertions, 0 deletions
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 <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/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 <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/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.h b/src/engine/TODO/maths.h
new file mode 100644
index 0000000..c7f1b44
--- /dev/null
+++ b/src/engine/TODO/maths.h
@@ -0,0 +1,17 @@
+#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
+
+//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))
+#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