aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUnavailableDev <ggwildplay@gmail.com>2023-03-24 20:21:16 +0100
committerUnavailableDev <ggwildplay@gmail.com>2023-03-24 20:21:16 +0100
commitcd41b5310bc3cb14dc41f6abe7923ad14339fc9f (patch)
tree49d40c1df67edc1e8d344ca982525f534d6d233b /src
parentba830f93a15299fd578b00969eff3c403456950c (diff)
a little clean up of player_controller.c
Diffstat (limited to 'src')
-rw-r--r--src/engine/player_controller.c88
1 files changed, 11 insertions, 77 deletions
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
index 647b00c..5027655 100644
--- a/src/engine/player_controller.c
+++ b/src/engine/player_controller.c
@@ -3,9 +3,9 @@
#include "engine/draw_screen.h"
#include "engine/sprite_controller.h"
#include "engine/player_controller.h"
-
#include "input.h"
+#include "engine/animator.h"
#include "engine/bullet.h"
void hh_player_actions() {
static Bullet bullet ={
@@ -19,15 +19,14 @@ void hh_player_actions() {
.radius = 8,
.pos = (vec2){32,32},
.vel = (vec2){0,0},
- .vec = (vec2){0,0},
.render = {
.frame0 = 80,
.palette = 3,
.fam = (hh_s_ppu_loc_fam_entry){
.horizontal_flip = false,
.vertical_flip = false,
- .palette_index = 2,
- .tilemap_index = 60,
+ .palette_index = 3,
+ .tilemap_index = 80,
}
}
}, player_new = {0};
@@ -41,7 +40,6 @@ void hh_player_actions() {
.radius = 8,
.pos = (vec2){128,48},
.vel = (vec2){0,0},
- .vec = (vec2){0,0},
.render = {
.frame0 = 20,
.palette = 7,
@@ -140,29 +138,8 @@ void hh_player_actions() {
.y = player.vel.y,
};
- player_new = hh_enemy_collision(player, enemy);
-
+ player_new = hh_enemy_collision(player, enemy);
- // const int8_t maa = 3;
- // const int8_t mbb = -3;
- // if (g_hh_controller_p1.dpad_up)
- //
- // if (g_hh_controller_p1.dpad_down)
- //
- // if (g_hh_controller_p1.dpad_left) {
- // player.vel.x += mbb;
- // // g_hh_demo_balls[0].horizontal_flip = true;
- // }
- // if (g_hh_controller_p1.dpad_right) {
- // player.vel.x += maa;
- // // g_hh_demo_balls[0].horizontal_flip = true;
- // }
- // if (g_hh_controller_p1.button_primary /*&& player.is_grounded*/) //JUMP
- // player.vel.y += -6;
- // // // if (g_hh_controller_p1.button_secondary)
-
- // player.vel.y += 1; //gravity
-
//END OF VECTOR CHANGES
// player.vel.y = CLAMP(player.vel.y,-32,32);
@@ -174,52 +151,14 @@ void hh_player_actions() {
};
-
- // const uint8_t empty = 0;
- // hh_s_tiles tiles[9];
- // const vec2 tile_offset[9] = {
- // (vec2){-16,-16},(vec2){0,-16},(vec2){+16,-16},
- // (vec2){-16,0}, (vec2){0,0}, (vec2){+16,0},
- // (vec2){-16,+16},(vec2){0,+16},(vec2){+16,+16},
- // };
- // for (int i = 0; i < 9; i++) {
- // vec2 temp_pos = vec_add(player.pos, tile_offset[i]);
- // temp_pos =(vec2){
- // .x = temp_pos.x,
- // .y = temp_pos.y,
- // };
- // hh_s_tiles tile = {
- // .pos = temp_pos,
- // .idx = hh_world_to_tile(temp_pos)
- // };
- // if(hh_colidable(tile.idx)) {
- // tiles[i]=tile;
- // // printf(" collidable near!");
- // } else {
- // tiles[i].idx = 0;
- // }
- // }
- /*
- 012
- 345
- 678
- */
- // for (int i = 0; i < 9; i++)
- // {
- // if (tiles[i].idx != 0){
- // hh_solve_collision(tiles[i].pos, &player);
- // }
- // }
-
- player = hh_background_collision ( player, player_new);
+ player = hh_background_collision( player, player_new);
- //player = player_new;
-
vec_cor cam_pos;//value in tiles
- // cam_pos = (vec2){0,0};
cam_pos = hh_update_camera(player.pos,(vec2){0,0},(vec2){.x=20*16,.y=30*16});//TODO: remove magic number(s)
- // printf("%i, %i:%i, %i\n",player.pos.x,player.pos.y,cam_pos.x,cam_pos.y);
+ hh_update_sprite(&player);
hh_draw_screen(cam_pos);
+
+ // TODO: make this a function call
// update player sprite on ppu
player.render.fam.position_x = (player.pos.x-cam_pos.x);
player.render.fam.position_y = (player.pos.y-cam_pos.y);
@@ -227,22 +166,17 @@ void hh_player_actions() {
enemy.render.fam.position_x = (enemy.pos.x-cam_pos.x);
enemy.render.fam.position_y = (enemy.pos.y-cam_pos.y);
- player.render.fam.tilemap_index = 2;//TODO: these two lines should be redundant
- player.render.fam.palette_index = 7;
- // hh_ppu_update_foreground(0, player.render.fam);
-
+ // TODO: make this loop a function call
for (int i = 0; i < 4; i++)
{
hh_s_ppu_loc_fam_entry temp = player.render.fam;
temp.position_x = player.render.fam.position_x+(!(player.vel.x>0)?-1:1)*(i%2?8:-8);
temp.position_y = player.render.fam.position_y+(i>1?0:-16);
- temp.tilemap_index = player.render.frame0 + i;
- temp.palette_index = player.render.palette;
+ temp.tilemap_index = player.render.fam.tilemap_index + i;
+ temp.palette_index = player.render.fam.palette_index;
temp.horizontal_flip = !(player.vel.x>0);
hh_ppu_update_foreground(i,temp);
}
-
-
hh_ppu_update_foreground(4, enemy.render.fam);