aboutsummaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/animator.c6
-rw-r--r--src/engine/bullet.c4
-rw-r--r--src/engine/level_const.c19
-rw-r--r--src/engine/level_const.h1
-rw-r--r--src/engine/sprite_controller.c12
-rw-r--r--src/engine/sprite_controller.h67
6 files changed, 74 insertions, 35 deletions
diff --git a/src/engine/animator.c b/src/engine/animator.c
index 3d46ea0..e293eb1 100644
--- a/src/engine/animator.c
+++ b/src/engine/animator.c
@@ -16,10 +16,10 @@ void hh_animate_hit(hh_s_rendering* in, bool hit) {
}
void hh_animate(hh_s_rendering* in, uint16_t start, uint16_t end, uint8_t step) {
- if (in->fam.palette_index >= start && in->fam.palette_index < end) {
- in->fam.palette_index += step;
+ if (in->fam.tilemap_index >= start && in->fam.tilemap_index < end) {
+ in->fam.tilemap_index += step;
} else {// rollover
- in->fam.palette_index = start;
+ in->fam.tilemap_index = start;
}
}
diff --git a/src/engine/bullet.c b/src/engine/bullet.c
index eb9a8bb..3251472 100644
--- a/src/engine/bullet.c
+++ b/src/engine/bullet.c
@@ -18,13 +18,13 @@ hh_entity* hh_init_bullets(int size) {
.vel = (vec2){0,0},
.size = (vec2) { 13,16},
.render = {
- .frame0 = 84,
+ .frame0 = HH_TM_BULLET_OFFSET,
.palette = 3,
.fam = (hh_s_ppu_loc_fam_entry){
.horizontal_flip = false,
.vertical_flip = false,
.palette_index = 7,
- .tilemap_index = 84,
+ .tilemap_index = HH_TM_BULLET_OFFSET,
}
}
};
diff --git a/src/engine/level_const.c b/src/engine/level_const.c
index 5d5f5e0..2522814 100644
--- a/src/engine/level_const.c
+++ b/src/engine/level_const.c
@@ -5,9 +5,13 @@
hh_g_all_levels hh_init_game_levels(){
hh_g_all_levels levels;
levels.current_level=1;
+
+ levels.shop.size.x=40;
+ levels.shop.size.y=15;
+ levels.shop.hh_level_completed=false;
levels.level[0].size.x=40;
- levels.level[0].size.y=15;
+ levels.level[0].size.y=100;
levels.level[0].hh_level_completed=false;
levels.level[1].size.x=100;
@@ -38,6 +42,19 @@ hh_g_all_levels hh_init_game_levels(){
fread(hh_game_level2, sizeof(int), size, lvl2);
fclose(lvl2);
+ FILE *shop = fopen("static/shop_new.bin", "rb");
+ if (shop == NULL) {
+ printf("shop.bin not found!\n");
+ return levels;
+ }
+ fseek(shop, 0, SEEK_END);
+ size = ftell(shop) / sizeof(int);
+ fseek(shop, (0 * sizeof(int)) + sizeof(int), SEEK_SET);
+ int* hh_game_shop = malloc(size * sizeof(int));
+ fread(hh_game_shop, sizeof(int), size, shop);
+ fclose(shop);
+
+ levels.shop.place = hh_game_shop;
levels.level[0].place = hh_game_level1;
levels.level[1].place = hh_game_level2;
diff --git a/src/engine/level_const.h b/src/engine/level_const.h
index 6275b72..a17993e 100644
--- a/src/engine/level_const.h
+++ b/src/engine/level_const.h
@@ -23,6 +23,7 @@ typedef struct {
typedef struct {
hh_level_entity level[2];
+ hh_level_entity shop;
int current_level;
diff --git a/src/engine/sprite_controller.c b/src/engine/sprite_controller.c
index b38b647..d386d0f 100644
--- a/src/engine/sprite_controller.c
+++ b/src/engine/sprite_controller.c
@@ -5,8 +5,18 @@
#include "ppu/consts.h"
#include "ppu/ppu.h"
+#include "static/tilemap.h"
+
+
uint8_t hh_get_palette(uint8_t tile_idx) {
- return hh_g_sprite_palette[tile_idx];
+ for (int i = 0; i < HH_TM_GROUPS; i++) {
+ if (hh_palette_lut[i] > tile_idx){
+ return hh_g_sprite_palette[i-1];
+ }
+ }
+
+ return 0; //not found
+ // return hh_g_sprite_palette[tile_idx];
}
void hh_setup_palettes(){
diff --git a/src/engine/sprite_controller.h b/src/engine/sprite_controller.h
index d89b068..3693850 100644
--- a/src/engine/sprite_controller.h
+++ b/src/engine/sprite_controller.h
@@ -3,6 +3,8 @@
#include "ppu/types.h"
+#include "static/tilemap.h"
+
// handles sprites
// Bg sprites
@@ -11,28 +13,29 @@
//TODO: pack data inside of sprite_palette LUT
//HH_PPU_PALETTE_COUNT
-#define HH_SPRITE_COUNT 80
+
#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
- 1,1,1,1,1,1,1,1,1, //9
- 7,7,7,2,7,7,1,2,7,
- 7,7,7,7, //??
+#define HH_PAL_IDX_SLIME 2
+#define HH_PAL_IDX_CRATE 4
+#define HH_PAL_IDX_SHOP 5
+#define HH_PAL_IDX_TITLE_SCREEN_ICON 3
+#define HH_PAL_IDX_FONT 6
+#define HH_PAL_IDX_DEV 7
+const static uint8_t hh_g_sprite_palette[HH_TM_GROUPS] = {
+ HH_PAL_IDX_SKY,
+ HH_PAL_IDX_BRICK,
+ HH_PAL_IDX_CRATE,
+ HH_PAL_IDX_SHOP,
+ // HH_PAL_IDX_SHOP,
+ HH_PAL_IDX_TITLE_SCREEN_ICON,
+ HH_PAL_IDX_FONT,
+ HH_PAL_IDX_SKY,
+ HH_PAL_IDX_DEV,
+ HH_PAL_IDX_SLIME,
+ HH_PAL_IDX_DEV
+ // HH_PAL_IDX_FONT
- 7,6,6,6,6,6,6,6, //baskets
- 7,7,7,7,7,7,7,7,7,7, //shop
- 7,7,7,7,7, //shop
- 6,6,6,6,6, //(hi-)score
-
- 3,3,3,3,3,3, //title_screen icon
- 6,6,6,6,/*6,6,6,6,6,6, //title_screen large letters
- 6,6,6,6,*/
- //other palettes here:
- // [HH_PAL_IDX_SKY] = 0,
};
@@ -82,15 +85,23 @@ const static hh_ppu_loc_palette_table_t hh_g_palette = {
{0x0,0x0,0x0},
{0x0,0x0,0x0},
{0x0,0x0,0x0}},
- {
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0},
- {0x0,0x0,0x0}},
+ {//shop
+ // {0x1,0x2,0x3},
+ // {0x0,0x0,0x1},
+ // {0x0,0x0,0x0},
+ // {0x0,0x0,0x0},
+ // {0x0,0x0,0x0},
+ // {0x0,0x0,0x0},
+ // {0x0,0x0,0x0},
+ // {0x0,0x0,0x0}},
+ {0x1, 0x2, 0x3},//0
+ {0x0, 0x0, 0x1},//1
+ {0x6, 0x2, 0x2},//2
+ {0x7, 0x4, 0x4},//3
+ {0xc, 0x9, 0x7},//4
+ {0xd, 0xb, 0x9},//5
+ {0x3, 0x4, 0x5},//6
+ {0x8, 0x9, 0x9}},
{//white
{0x1,0x2,0x3},
{0xf,0xf,0xf},