aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-03-14 17:28:26 +0100
committerGitHub <noreply@github.com>2023-03-14 17:28:26 +0100
commit51a49f8844705ea3bff95b3c25ba3adc96f5d652 (patch)
treeb192162ea7ce9fd5c6f9d7b96cba435d790efd50
parent5a747929ed2099755fb03c930ea68c77fda805b3 (diff)
parent6ddf430391b577a5e5d1449511f65aa57a2c0b0e (diff)
Merge pull request #35 from UnavailableDev/game-engine
Camera controller
-rw-r--r--src/engine/camera.c5
-rw-r--r--src/engine/player_controller.c17
2 files changed, 3 insertions, 19 deletions
diff --git a/src/engine/camera.c b/src/engine/camera.c
index e756bd4..2c3e517 100644
--- a/src/engine/camera.c
+++ b/src/engine/camera.c
@@ -6,10 +6,10 @@
vec_cor hh_update_camera(vec_cen new, vec2 min, vec2 max){
//TODO: change floating point math to fix point math
- //TODO: fix buggy y-axis ??
+ //TODO: remove magic number at y camera offset
// new = vec_cen2cor(new,(vec2){.x=max.x/2,.y=max.y/2});
- new = vec_cen2cor((vec2){.x=new.x+(HH_PPU_SPRITE_WIDTH/2),.y=(new.y+(HH_PPU_SPRITE_HEIGHT/2))*2},(vec2){.x=max.x/2,.y=max.y/2});
+ new = vec_cen2cor((vec2){.x=new.x+(HH_PPU_SPRITE_WIDTH),.y=new.y+(HH_PPU_SPRITE_HEIGHT*8)},(vec2){.x=max.x/2,.y=max.y/2});
// new.x = new.x << HH_MATH_FIXED_POINT;
// new.y = new.y << HH_MATH_FIXED_POINT;
static vec_cor old;
@@ -19,6 +19,7 @@ vec_cor hh_update_camera(vec_cen new, vec2 min, vec2 max){
// int16_t some = 0;
// some = some <<= HH_MATH_FIXED_POINT-1;
+ // Camera smoothing
new.x = (int)((float)new.x*0.1f + (float)old.x*0.9f);
new.y = (int)((float)new.y*0.1f + (float)old.y*0.9f);
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
index 6735620..22f6eb6 100644
--- a/src/engine/player_controller.c
+++ b/src/engine/player_controller.c
@@ -4,9 +4,6 @@
#include "engine/sprite_controller.h"
#include "engine/player_controller.h"
-#include "demo.h"
-#include <stdio.h>
-
#include "input.h"
void hh_player_actions() {
@@ -50,11 +47,6 @@ void hh_player_actions() {
// player.vel.y += -6;
// // // if (g_hh_controller_p1.button_secondary)
- // player.render.fam.palette_index = 7;
- // player.render.fam.tilemap_index = 7;
-
- // printf("%x ",player.render.fam.palette_index);
-
// player.vel.y += 1; //gravity
@@ -154,14 +146,5 @@ void hh_player_actions() {
player.render.fam.palette_index = 7;
hh_ppu_update_foreground(0, player.render.fam);
-
- hh_s_ppu_loc_fam_entry sprite = {
- .position_x = 16,
- .position_y = 16,
- .palette_index = 7,
- .tilemap_index = 2,
- };
- hh_ppu_update_foreground(1, sprite);
-
}