aboutsummaryrefslogtreecommitdiff
path: root/src/engine/player_controller.c
blob: 7e2e6786e05e602fab09b62ebb3663ca84d081f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "ppu/types.h"
#include "engine/camera.h"
#include "engine/draw_screen.h"
#include "engine/sprite_controller.h"
#include "engine/player_controller.h"
#include "input.h"

#include "static/tilemap.h"

#include "engine/animator.h"
#include "engine/bullet.h"
void hh_player_actions(hh_entity* player){

	static hh_entity player_new = {0};
	player_new = *player;

	int8_t hit_timer = 0;
	int8_t direction_x = (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right);
	int8_t direction_y = (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down);

	hh_player_move_hit(player,hit_timer,direction_x);
	hh_gravity_entity(player);
	if(g_hh_controller_p1.button_primary){
		hh_jump_entity(player);
	}


		player_new.vel = (vec2){
		.x = player->vel.x,
		.y = player->vel.y,
	};
	
	player_new.pos = (vec2){
		.x = player->pos.x + player_new.vel.x,
		.y = player->pos.y + player_new.vel.y,
	};


	*player =  hh_background_collision ( *player, player_new);
	
	if (direction_x != 0) {
		player->render.fam.horizontal_flip = (direction_x > 0 ?0:1);
	}

}