aboutsummaryrefslogtreecommitdiff
path: root/src/engine/entity.c
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-04-06 12:32:23 +0200
committerGitHub <noreply@github.com>2023-04-06 12:32:23 +0200
commitd1c00c98ca0f2ca498284e60fa057a610cc5c461 (patch)
treea2efebcb9917d7f4f3666a722338f50b9590e843 /src/engine/entity.c
parent1771aaa12736b4dbc24419270cf595de6d345969 (diff)
parent93e9426d5642dfab7a13d5a34873b296de1d9642 (diff)
Merge pull request #58 from UnavailableDev/dev
Dynamic tilemap
Diffstat (limited to 'src/engine/entity.c')
-rw-r--r--src/engine/entity.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/engine/entity.c b/src/engine/entity.c
index 1cb88be..eba6481 100644
--- a/src/engine/entity.c
+++ b/src/engine/entity.c
@@ -43,6 +43,7 @@ void hh_solve_collision(vec2 pos_environment, hh_entity* entity){
// entity->vel.x = 0;
// }
}
+
hh_entity hh_background_collision (hh_entity temp_old_entity,hh_entity temp_new_entity){
temp_new_entity.is_grounded = false;
@@ -119,6 +120,7 @@ bool hh_background_collision_bulllet (hh_entity temp_old_entity){
// temp_old_entity.vel = temp_new_entity.vel;
return false;
}
+
hh_entity hh_enemy_collision(hh_entity temp_player, hh_entity temp_enemy){
bool collide = hh_distance_circles( temp_player.pos, temp_enemy.pos, temp_player.radius, temp_enemy.radius);
@@ -138,7 +140,7 @@ hh_entity hh_enemy_collision(hh_entity temp_player, hh_entity temp_enemy){
temp_player.vel.x = 8;
}
// ghost mode / invulnerable or other things on hit
- // temp_player.hp--;
+ temp_player.hp--;
} else {
temp_player.is_hit = false;
@@ -170,14 +172,35 @@ void hh_jump_entity(hh_entity* object_1){
}
}
void hh_gravity_entity(hh_entity* object_1){
- if (object_1->is_grounded == false && object_1->vel.y < 6) {
+ if (object_1->is_grounded == false) {
object_1->vel.y += 1; //gravity
}
}
-void hh_hit_entity(hh_entity* object_1, int8_t* hit_timer, int8_t* direction){
+
+void hh_movement_entity(hh_entity* object_1, int8_t* direction){
+ if(direction != 0){
+ if(object_1->vel.x > -1 * object_1->speed && object_1->vel.x < object_1->speed) {
+ object_1->vel.x = object_1->vel.x + direction;
+ } else {
+ if (object_1->vel.x > 0) {
+ object_1->vel.x--;
+ } else if(object_1->vel.x < 0) {
+ object_1->vel.x++;
+ }
+ }
+ } else {
+ if (object_1->vel.x > 0) {
+ object_1->vel.x--;
+ } else if(object_1->vel.x < 0) {
+ object_1->vel.x++;
+ }
+ }
+
+}
+void hh_player_move_hit(hh_entity* object_1, int8_t* hit_timer, int8_t* direction){
if(object_1->is_hit == true){
hit_timer = 9;
- object_1->is_hit = false;
+ //object_1->is_hit = false;
}
if(hit_timer > -10){
hit_timer--;