aboutsummaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/animator.c28
-rw-r--r--src/engine/animator.h2
-rw-r--r--src/engine/level_const.c6
-rw-r--r--src/engine/player_controller.c2
-rw-r--r--src/engine/sprite_controller.h29
-rw-r--r--src/engine/title_screen.c6
6 files changed, 33 insertions, 40 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/level_const.c b/src/engine/level_const.c
index 896d0e0..642a474 100644
--- a/src/engine/level_const.c
+++ b/src/engine/level_const.c
@@ -7,16 +7,16 @@ hh_g_all_levels hh_init_game_levels(){
levels.current_level=0;
levels.level[0].size.x=40;
- levels.level[0].size.y=100;
+ levels.level[0].size.y=15;
levels.level[0].hh_level_completed=false;
levels.level[1].size.x=100;
levels.level[1].size.y=28;
levels.level[1].hh_level_completed=false;
- FILE *fp = fopen("../test/bin/level1_test.bin", "rb");
+ FILE *fp = fopen("static/shop_new.bin", "rb");
if (fp == NULL) {
- printf("level1_test.bin not found!\n");
+ printf("shop_new.bin not found!\n");
return levels;
}
fseek(fp, 0, SEEK_END);
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
index 83c5966..6400b02 100644
--- a/src/engine/player_controller.c
+++ b/src/engine/player_controller.c
@@ -5,6 +5,8 @@
#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){
diff --git a/src/engine/sprite_controller.h b/src/engine/sprite_controller.h
index fc6d3d3..d89b068 100644
--- a/src/engine/sprite_controller.h
+++ b/src/engine/sprite_controller.h
@@ -12,9 +12,10 @@
//TODO: pack data inside of sprite_palette LUT
//HH_PPU_PALETTE_COUNT
#define HH_SPRITE_COUNT 80
-#define HH_PAL_IDX_SKY 512
+#define HH_PAL_IDX_SKY 0
#define HH_PAL_IDX_BRICK 1
const static uint8_t hh_g_sprite_palette[HH_SPRITE_COUNT] = {
+ //TODO: FIGURE OUT HOW TO DEAL WITH DYNAMIC PALLETS
//TODO: make a buffer of 16 no-collider sprites (instead of the current 1)
0,1,1,1,1,1,1,1,1,1, //1+9
1,1,1,1,1,1,1,1,1,1, //6+4
@@ -47,13 +48,13 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = {
{0x0,0x0,0x0}},
{//Bricks
{0x1,0x2,0x3},//01
- {0xd,0x8,0xa},//24
{0x0,0x0,0x1},//25
{0x1,0x1,0x1},//26
{0x1,0x1,0x2},//27
{0x2,0x2,0x3},//28
{0x3,0x4,0x5},//29
- {0x5,0x1,0x7}},
+ {0x5,0x1,0x7},
+ {0xd,0x8,0xa}},//24
{//slime
{0x1,0x2,0x3},
{0x1,0x3,0x2},
@@ -69,19 +70,19 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = {
{0x4,0x2,0x5},
{0x7,0x3,0x7},
{0xe,0xe,0xe},
- {0xe,0xe,0xe}, //elemental
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
+ {0x7,0x2,0x3}, //elemental
+ {0xc,0x5,0x3},
+ {0xe,0xc,0x7}},
+ {//crates
+ {0x5,0x7,0x7},
+ {0x3,0x1,0x2},
+ {0x6,0x2,0x2},
+ {0x7,0x4,0x4},
+ {0xa,0x7,0x5},
{0x0,0x0,0x0},
{0x0,0x0,0x0},
{0x0,0x0,0x0}},
- {//elemental
+ {
{0x0,0x0,0x0},
{0x0,0x0,0x0},
{0x0,0x0,0x0},
@@ -112,7 +113,9 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = {
void hh_setup_palettes();
+//TODO: UPDATE THIS FUNCTION
/** @brief return palette index that belongs to tilemap index */
uint8_t hh_get_palette(uint8_t tile_idx);
+//TODO: UPDATE THIS FUNCTION
bool hh_colidable(uint8_t tile_idx);
diff --git a/src/engine/title_screen.c b/src/engine/title_screen.c
index 9c7ed48..1e9e586 100644
--- a/src/engine/title_screen.c
+++ b/src/engine/title_screen.c
@@ -2,6 +2,8 @@
#include "ppu/types.h"
#include "ppu/consts.h"
+#include "static/tilemap.h"
+
#include "engine/draw_screen.h"
#include "engine/entity.h"
@@ -12,7 +14,7 @@ void hh_init_title_screen(){
//send data
uint8_t idx = 0;
- const uint8_t tilemap_offset = 59;
+ const uint8_t tilemap_offset = HH_TM_TITLE_SCREEN_ICON_OFFSET;
int tiles_h = HH_PPU_BG_CANVAS_TILES_H;
int vp_h = HH_PPU_SCREEN_WIDTH/HH_PPU_SPRITE_WIDTH; //screen_h in tiles
int vert_offset = tiles_h*3;
@@ -45,7 +47,7 @@ void hh_init_title_screen(){
}
- const uint8_t letters_offset = 66;
+ const uint8_t letters_offset = HH_TM_TITLE_SCREEN_LETTERES_LARGE_OFFSET;
const int _size_hooded = 7, _size_v = 2;
// char* hh = "hooded";