aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlenk008 <frenk_0_0@hotmail.com>2023-03-11 20:56:26 +0100
committerFlenk008 <frenk_0_0@hotmail.com>2023-03-11 20:56:26 +0100
commitc12ff10740927c6040c83b3399ad35e94117131c (patch)
tree6b72ba187f57f13d61e2ed3683d8e7601527382f /src
parentb707ac24673ec20aa04fcd8dc1c022d36bc3a49a (diff)
Fixed movement
Adjusted movement speed otherwise wouldnt show any movement. Also changed input testing lines so it does work
Diffstat (limited to 'src')
-rw-r--r--src/demo.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/demo.c b/src/demo.c
index b9bba17..baaf73d 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -12,7 +12,7 @@ hh_s_entity_player g_hh_player_1 = {
.pos_x = 31000, // 0b0000 0001 0011 0110
.pos_y = 21000,
.radius = 8,
- .speed = 1,
+ .speed = 100,
.direction_x = 1,
.rotation = 8,
.in_air = false,
@@ -66,14 +66,17 @@ void hh_demo_setup() {
void hh_demo_loop(unsigned long frame) {
hh_player_movement();
+ // input testing (no hitbox stuff)
+ // g_hh_player_1.pos_x += ((-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right)) * g_hh_player_1.speed; // -1 = L || 1 == R
+ // g_hh_player_1.pos_y += ((-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down)) * g_hh_player_1.speed; // -1 = D || 1 == U
+
// adjust map size
g_hh_pos_x = g_hh_player_1.pos_x / 100;
g_hh_pos_y = g_hh_player_1.pos_y / 100;
- // input testing (no hitbox stuff)
- // pos_x += (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right); // -1 = L || 1 == R
- // pos_y += (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down); // -1 = D || 1 == U
+
+
// update player sprite on ppu
g_hh_demo_balls[0].position_x = g_hh_pos_x;
@@ -102,7 +105,7 @@ void hh_demo_loop(unsigned long frame) {
void hh_player_movement() {
int8_t directionX = (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right); // -1 = L || 1 == R
- int8_t directionY = (-1 * g_hh_controller_p1.dpad_down) + (1 * g_hh_controller_p1.dpad_up); // -1 = D || 1 == U
+ int8_t directionY = (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down); // -1 = D || 1 == U
uint8_t i, j;
uint8_t rotation = 0; // 0-7
@@ -140,11 +143,11 @@ void hh_player_movement() {
if (g_hh_player_1.in_air == false && directionX != 0) {
if (directionX == 1) {
- tileColX = ((g_hh_player_1.pos_x / 100) + g_hh_player_1.radius) / 20;
- modTileX = (g_hh_player_1.pos_x + (100 * g_hh_player_1.radius)) % 2000;
+ tileColX = ((g_hh_player_1.pos_x / 100) + g_hh_player_1.radius) / 16;
+ modTileX = (g_hh_player_1.pos_x + (100 * g_hh_player_1.radius)) % 1600;
} else if (directionX == -1) {
- tileColX = ((g_hh_player_1.pos_x / 100) - g_hh_player_1.radius) / 20;
- modTileX = (g_hh_player_1.pos_x - (100 * g_hh_player_1.radius)) % 2000;
+ tileColX = ((g_hh_player_1.pos_x / 100) - g_hh_player_1.radius) / 16;
+ modTileX = (g_hh_player_1.pos_x - (100 * g_hh_player_1.radius)) % 1600;
}
if (HH_DEMO_HITBOX_TILEMAP[tileColY][tileColX + directionX] != 1) {
@@ -163,6 +166,11 @@ void hh_player_movement() {
{
}
+
+ if(directionY != 0)
+ {
+ // g_hh_player_1.pos_y = g_hh_player_1.pos_y + (directionY * g_hh_player_1.speed * 2); // NEW x set
+ }
// collision map floor (y-axis) (falling)
// if falling no jump press (implement)
/*