aboutsummaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
authorUnavailableDev <ggwildplay@gmail.com>2023-04-03 13:27:36 +0200
committerUnavailableDev <ggwildplay@gmail.com>2023-04-03 13:27:36 +0200
commitb125ec41bfc18c9beb652cff1a58e567304c9c32 (patch)
treefd5bb02af1876ff11b38c3a747b8f13326a50b85 /src/engine
parent433cbd970797d4472d12c704163719aec7340202 (diff)
hh_update_sprite is now a void function
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/animator.c28
-rw-r--r--src/engine/animator.h2
-rw-r--r--src/engine/player_controller.c7
3 files changed, 12 insertions, 25 deletions
diff --git a/src/engine/animator.c b/src/engine/animator.c
index 1af8dde..3d46ea0 100644
--- a/src/engine/animator.c
+++ b/src/engine/animator.c
@@ -23,33 +23,19 @@ void hh_animate(hh_s_rendering* in, uint16_t start, uint16_t end, uint8_t step)
}
}
-//TODO: if entity not inside of screen, don't update idx
-uint16_t hh_update_sprite(uint16_t idx, hh_entity* in, vec_cor cam) {
+//TODO: if entity not inside of screen, don't update idx (problems with old idx not being overwritten anymore)
+void hh_update_sprite(uint16_t *idx, hh_entity* in, vec_cor cam) {
hh_animate_hit(&in->render, in->is_hit);
hh_s_ppu_loc_fam_entry temp = in->render.fam;
for (int y = 0; y < CEILI(in->size.y,16); y++) {
temp.position_y = CLAMP(in->pos.y - cam.y + y*HH_PPU_SPRITE_HEIGHT, -16, HH_PPU_SCREEN_HEIGHT);
for (int x = 0; x < CEILI(in->size.x,16); x++) {
temp.position_x = CLAMP(in->pos.x - cam.x + x*HH_PPU_SPRITE_WIDTH, -16, HH_PPU_SCREEN_WIDTH);
- hh_ppu_update_foreground(++idx, temp);
- temp.tilemap_index++;
+ // if (temp.position_x != -16 && temp.position_y != -16) {// removes redundant sprites
+ hh_ppu_update_foreground(++*idx, temp);
+ temp.tilemap_index++;
+ // hh_animate(&in->render, start+counter,end+counter,4);
+ // }
}
}
- return idx;
}
-
-
-// void hh_update_sprite(hh_entity* in, vec_cor cam) {
-// hh_animate_hit(&in->render, in->is_hit);
-// // uint16_t idx = in->render.ppu_foreground_index;
-// uint16_t idx = 0;
-// hh_s_ppu_loc_fam_entry temp = in->render.fam;
-// for (int y = 0; y < CEILI(in->size.y,16); y++) {
-// temp.position_y = CLAMP(in->pos.y - cam.y + y*HH_PPU_SPRITE_HEIGHT, -16, HH_PPU_SCREEN_HEIGHT);
-// for (int x = 0; x < CEILI(in->size.x,16); x++) {
-// temp.position_x = CLAMP(in->pos.x - cam.x + x*HH_PPU_SPRITE_WIDTH, -16, HH_PPU_SCREEN_WIDTH);
-// hh_ppu_update_foreground(idx++, temp);
-// temp.tilemap_index++;
-// }
-// }
-// }
diff --git a/src/engine/animator.h b/src/engine/animator.h
index 10fa321..2f6e00d 100644
--- a/src/engine/animator.h
+++ b/src/engine/animator.h
@@ -11,4 +11,4 @@ void hh_animate_hit(hh_s_rendering*, bool hit);
void hh_animate(hh_s_rendering*, uint16_t start, uint16_t end, uint8_t step);
/** @brief passively updates sprite*/
-uint16_t hh_update_sprite(uint16_t idx, hh_entity* in, vec_cor cam);
+void hh_update_sprite(uint16_t* idx, hh_entity* in, vec_cor cam);
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
index cec28df..0fed82d 100644
--- a/src/engine/player_controller.c
+++ b/src/engine/player_controller.c
@@ -13,7 +13,7 @@ void hh_player_actions() {
.speed = 6,
.is_grounded = false,
.is_hit = false,
- .radius = 8,
+ .radius = 16,
.pos = (vec2){128+16,32},
.vel = (vec2){0,0},
.size = (vec2){32,32},
@@ -165,8 +165,9 @@ void hh_player_actions() {
cam_pos = hh_draw_screen(player.pos);
hh_shoot_bullet(player.pos, cam_pos ,&bullet);
uint16_t idx = 16;
- idx = hh_update_sprite(idx, &player, cam_pos);
- idx = hh_update_sprite(idx, &enemy, cam_pos);
+ // hh_clear_sprite();
+ hh_update_sprite(&idx, &enemy, cam_pos);
+ hh_update_sprite(&idx, &player, cam_pos);
idx =16;