From 0ede5beef926151dd6c6ce8b0810b26225dae895 Mon Sep 17 00:00:00 2001 From: "U-DESKTOP-MR3JJV2\\niels" Date: Wed, 15 Mar 2023 10:01:50 +0100 Subject: precautions --- src/.gitignore | 14 +-- src/engine/sprite_controller.h | 212 ++++++++++++++++++++--------------------- 2 files changed, 113 insertions(+), 113 deletions(-) diff --git a/src/.gitignore b/src/.gitignore index 504b995..b0126dd 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,7 +1,7 @@ -*.o -main.elf -main.bin -main -main.exe -static/ -*.bin +*.o +main.elf +main.bin +main +main.exe +static/ +*.bin diff --git a/src/engine/sprite_controller.h b/src/engine/sprite_controller.h index 001a459..bb7e8d1 100644 --- a/src/engine/sprite_controller.h +++ b/src/engine/sprite_controller.h @@ -1,106 +1,106 @@ -#pragma once -#include - -#include "ppu/types.h" - -// handles sprites - -// Bg sprites - -// Fg or entity sprites - -//TODO: pack data inside of sprite_palette LUT -//HH_PPU_PALETTE_COUNT -#define HH_SPRITE_COUNT 40 -#define HH_PAL_IDX_SKY 0 -#define HH_PAL_IDX_BRICK 1 -const static uint8_t hh_g_sprite_palette[HH_SPRITE_COUNT] = { - 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 - //other palettes here: -}; - - -const static hh_ppu_loc_palette_table_t hh_g_palette = { - {//palette info here - {0x1,0x2,0x3}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {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}}, - {//slime - {0x1,0x2,0x3}, - {0x1,0x3,0x2}, - {0x4,0x8,0x3}, - {0x7,0xa,0x4}, - {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}, - {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}, - {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}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}, - {0x0,0x0,0x0}}, - { - {0x0,0xf,0xf}, - {0xf,0xf,0xf}, - {0xf,0x0,0xf}, - {0xf,0xf,0x0}, - {0xf,0x0,0x0}, - {0x0,0xf,0x0}, - {0x0,0x0,0xf}, - {0x0,0x0,0x0}} -}; - -void hh_setup_palettes(); - -/** @brief return palette index that belongs to tilemap index */ -uint8_t hh_get_palette(uint8_t tile_idx); - -bool hh_colidable(uint8_t tile_idx); +#pragma once +#include + +#include "ppu/types.h" + +// handles sprites + +// Bg sprites + +// Fg or entity sprites + +//TODO: pack data inside of sprite_palette LUT +//HH_PPU_PALETTE_COUNT +#define HH_SPRITE_COUNT 40 +#define HH_PAL_IDX_SKY 0 +#define HH_PAL_IDX_BRICK 1 +const static uint8_t hh_g_sprite_palette[HH_SPRITE_COUNT] = { + 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 + //other palettes here: +}; + + +const static hh_ppu_loc_palette_table_t hh_g_palette = { + {//palette info here + {0x1,0x2,0x3}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {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}}, + {//slime + {0x1,0x2,0x3}, + {0x1,0x3,0x2}, + {0x4,0x8,0x3}, + {0x7,0xa,0x4}, + {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}, + {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}, + {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}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}, + {0x0,0x0,0x0}}, + { + {0x0,0xf,0xf}, + {0xf,0xf,0xf}, + {0xf,0x0,0xf}, + {0xf,0xf,0x0}, + {0xf,0x0,0x0}, + {0x0,0xf,0x0}, + {0x0,0x0,0xf}, + {0x0,0x0,0x0}} +}; + +void hh_setup_palettes(); + +/** @brief return palette index that belongs to tilemap index */ +uint8_t hh_get_palette(uint8_t tile_idx); + +bool hh_colidable(uint8_t tile_idx); -- cgit v1.2.3 From 3891486b368f4cdd1c5e00019a2a66ca05e656e6 Mon Sep 17 00:00:00 2001 From: NielsCoding <48092678+heavydemon21@users.noreply.github.com> Date: Wed, 15 Mar 2023 15:37:21 +0100 Subject: game loop and bullet TODO game loop: -(startingscreen) read correct indexes -(shop) read correct indexes -gameplay still needs alot with different levels etc.. rest not yet done bullet needs testing and correct PAL and tilemap reading --- src/GameLoop/shop.c | 28 +++++++++++++++++++ src/GameLoop/shop.h | 15 ++++++++++ src/GameLoop/startingScreen.c | 30 ++++++++++++++++++++ src/GameLoop/startingScreen.h | 14 ++++++++++ src/demo.c | 62 ++++++++++++++++++++++++++++++++++++++---- src/engine/bullet.c | 39 ++++++++++++++++++++++++++ src/engine/bullet.h | 14 ++++++++++ src/engine/draw_screen.c | 49 ++++++++++++++++++++++++++++++++- src/engine/draw_screen.h | 5 ++++ src/engine/engine.c | 1 + src/engine/player_controller.c | 13 ++++++++- src/makefile | 6 +++- 12 files changed, 268 insertions(+), 8 deletions(-) create mode 100644 src/GameLoop/shop.c create mode 100644 src/GameLoop/shop.h create mode 100644 src/GameLoop/startingScreen.c create mode 100644 src/GameLoop/startingScreen.h create mode 100644 src/engine/bullet.c create mode 100644 src/engine/bullet.h diff --git a/src/GameLoop/shop.c b/src/GameLoop/shop.c new file mode 100644 index 0000000..31ff5ce --- /dev/null +++ b/src/GameLoop/shop.c @@ -0,0 +1,28 @@ +#include "shop.h" + + +bool hh_show_Shop(){ + static hh_e_ShopStates hh_e_Shop = hh_e_STATE_SHOW; + + switch (hh_e_Shop) + { + case hh_e_STATE_SHOW: + hh_setup_startingScreen(); + hh_e_Shop = hh_e_STATE_Input; + return false; + break; + case hh_e_STATE_Input: + if(g_hh_controller_p1.dpad_right){ + hh_e_Shop = hh_e_STATE_END; + } + break; + case hh_e_STATE_END: + hh_e_Shop = hh_e_STATE_SHOW; + return true; + break; + default: + hh_e_Shop = hh_e_STATE_SHOW; + break; + } + return false; +} diff --git a/src/GameLoop/shop.h b/src/GameLoop/shop.h new file mode 100644 index 0000000..35bb780 --- /dev/null +++ b/src/GameLoop/shop.h @@ -0,0 +1,15 @@ +#include "input.h" +#include "engine/draw_screen.h" + + +#include +#include + +typedef enum { + hh_e_STATE_SHOW, + hh_e_STATE_Input, + hh_e_STATE_END +} hh_e_ShopStates; + + +bool hh_show_Shop(); diff --git a/src/GameLoop/startingScreen.c b/src/GameLoop/startingScreen.c new file mode 100644 index 0000000..a0cd283 --- /dev/null +++ b/src/GameLoop/startingScreen.c @@ -0,0 +1,30 @@ +#include "startingScreen.h" +#include "input.h" +#include "engine/draw_screen.h" +// #include "engine/player_controller.h" + +bool hh_show_startingScreen(){ + static hh_e_screenStates hh_e_startingScreen = hh_e_STATE_SHOW; + + switch (hh_e_startingScreen) + { + case hh_e_STATE_SHOW: + hh_setup_startingScreen(); + hh_e_startingScreen = hh_e_STATE_Input; + return false; + break; + case hh_e_STATE_Input: + if(g_hh_controller_p1.dpad_left){ + hh_e_startingScreen = hh_e_STATE_END; + } + break; + case hh_e_STATE_END: + hh_e_startingScreen = hh_e_STATE_SHOW; + return true; + break; + default: + hh_e_startingScreen = hh_e_STATE_SHOW; + break; + } + return false; +} diff --git a/src/GameLoop/startingScreen.h b/src/GameLoop/startingScreen.h new file mode 100644 index 0000000..f51cc66 --- /dev/null +++ b/src/GameLoop/startingScreen.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +typedef enum { + hh_e_STATE_SHOW, + hh_e_STATE_Input, + hh_e_STATE_END +} hh_e_screenStates; + + +bool hh_show_startingScreen(); + diff --git a/src/demo.c b/src/demo.c index 95347cb..f5b5c29 100644 --- a/src/demo.c +++ b/src/demo.c @@ -13,6 +13,17 @@ #include "engine/sprite_controller.h" +#include "GameLoop/startingScreen.h" +#include "GameLoop/shop.h" +// states +typedef enum { + hh_e_STATE_startingScreen, + hh_e_STATE_Shop, + hh_e_STATE_Gameplay, + hh_e_STATE_GameOver, + hh_e_STATE_HighScore +} hh_e_GameState; +hh_e_GameState hh_gameStates; hh_s_entity_player g_hh_player_1 = { .pos_x = 31000, // 0b0000 0001 0011 0110 @@ -45,18 +56,59 @@ typedef struct { hh_entity hh_g_player, hh_g_player_new; -void hh_demo_setup() { - +void hh_demo_setup() { hh_setup_palettes(); - hh_setup_screen(); + //hh_setup_screen(); } - void hh_demo_loop(unsigned long frame) { // hh_player_movement(); + switch (hh_gameStates) + { + case hh_e_STATE_startingScreen: - hh_player_actions(); + if(hh_show_startingScreen()){ + hh_gameStates = hh_e_STATE_Shop; + } + break; + case hh_e_STATE_Shop: + // TODO: + + if(hh_show_Shop()){ + hh_gameStates = hh_e_STATE_Gameplay; + } + // function: new level is chosen goto level + break; + case hh_e_STATE_Gameplay: + static int run_test=0; + if(!run_test){ + hh_setup_screen(); + run_test=1; + + } + else{ + hh_player_actions(); + } + // TODO: + // function: if level complete goto shop + // function: if player is dead goto game over + break; + case hh_e_STATE_GameOver: + // TODO: + // function: show game over screen + // function: after time goto high score + break; + case hh_e_STATE_HighScore: + // TODO: + // fucntion: show all previously scored points + // function: button pressed goto starting screen + break; + default: + hh_gameStates = hh_e_STATE_startingScreen; + break; + } + } diff --git a/src/engine/bullet.c b/src/engine/bullet.c new file mode 100644 index 0000000..eafd4e7 --- /dev/null +++ b/src/engine/bullet.c @@ -0,0 +1,39 @@ +#include "bullet.h" +#include "engine/sprite_controller.h" + +void shootBullet(vec2 playerPos, Bullet* bullet){ + // Set bullet's x and y coordinates to player's coordinates + bullet->x = playerPos.x; + bullet->y = playerPos.y; + // Set bullet's velocity to a fixed value + bullet->velocity = 1; + // Set bullet's status to active + bullet->isActive = true; +} +void updateBullet(Bullet* bullet, int deltaTime){ + // Only update bullet if it is active + static int latestLocationBullet = 0; + if (bullet->isActive) { + // Move bullet based on velocity and deltaTime + bullet->x += bullet->velocity * deltaTime; + drawBullet(bullet); + // Check if bullet has moved 16 pixels + if (bullet->x - latestLocationBullet > 16) { + // Set bullet's status to inactive + bullet->isActive = false; + } + } + else{ + latestLocationBullet = bullet->x; + } +} +void drawBullet(Bullet* bullet){ + + hh_ppu_update_foreground(1, (hh_s_ppu_loc_fam_entry) + { + .horizontal_flip = false, + .vertical_flip = false, + .palette_index = 7, + .tilemap_index = 2, // change tilemap to the correct foreground index; + }); +} diff --git a/src/engine/bullet.h b/src/engine/bullet.h new file mode 100644 index 0000000..f119829 --- /dev/null +++ b/src/engine/bullet.h @@ -0,0 +1,14 @@ +#pragma once +#include "player_controller.h" + +typedef struct { + int x; + int y; + int velocity; + int isActive; +} Bullet; + +//Bullet* createBullet(float x, float y, float velocity, float direction); +void shootBullet(vec2 playerPos, Bullet* bullet); +void updateBullet(Bullet* bullet, int deltaTime); +void drawBullet(Bullet* bullet); diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c index c4f3389..205d4b6 100644 --- a/src/engine/draw_screen.c +++ b/src/engine/draw_screen.c @@ -19,7 +19,6 @@ uint8_t hh_world_to_tile(vec2 pos){ return tile; } - // remeber old value to know which part to update. vec2 previousViewport = { .x = 0, .y = 0 }; void hh_draw_screen(vec_cor viewport){ @@ -60,3 +59,51 @@ void hh_setup_screen(){ } free(tile); } + +void hh_setup_startingScreen(){ + int size = 300; // 40 x as tiles 30 y as tiles + FILE* level = fopen("../test/bin/startingScreen.bin", "rb"); /* open binary file */ + if (!level) { /* check if file opened successfully */ + fprintf(stderr, "Error: Failed to open file.\n"); + return; + } + fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET); + int* tile = (int*)malloc(size*sizeof(int)); + fread(tile, sizeof(int), size, level); // read 1 tile from binary + + fclose(level); + + for(int BAM_index = 0; BAM_index < size; BAM_index++){ + hh_ppu_update_background(BAM_index, (hh_s_ppu_loc_bam_entry){ + .horizontal_flip = false, + .vertical_flip = false, + .palette_index = hh_get_palette(tile[BAM_index]), + .tilemap_index = tile[BAM_index], + }); + } + free(tile); +} + +void hh_setup_shopScreen(){ + int size = 300; // 40 x as tiles 30 y as tiles + FILE* level = fopen("../test/bin/shopScreen.bin", "rb"); /* open binary file */ + if (!level) { /* check if file opened successfully */ + fprintf(stderr, "Error: Failed to open file.\n"); + return; + } + fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET); + int* tile = (int*)malloc(size*sizeof(int)); + fread(tile, sizeof(int), size, level); // read 1 tile from binary + + fclose(level); + + for(int BAM_index = 0; BAM_index < size; BAM_index++){ + hh_ppu_update_background(BAM_index, (hh_s_ppu_loc_bam_entry){ + .horizontal_flip = false, + .vertical_flip = false, + .palette_index = hh_get_palette(tile[BAM_index]), + .tilemap_index = tile[BAM_index], + }); + } + free(tile); +} diff --git a/src/engine/draw_screen.h b/src/engine/draw_screen.h index b181108..bfe8bf8 100644 --- a/src/engine/draw_screen.h +++ b/src/engine/draw_screen.h @@ -19,3 +19,8 @@ uint8_t hh_world_to_tile(vec2 pos); void hh_draw_screen(vec2 viewport); /** @brief send data to BAM memory from binary level */ void hh_setup_screen(); +/** @brief send starting screen data to BAM memory from binary level */ +void hh_setup_startingScreen(); + +/** @brief send shop screen data to BAM memory from binary level */ +void hh_setup_shopScreen(); diff --git a/src/engine/engine.c b/src/engine/engine.c index 799ee7c..3280892 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -1,4 +1,5 @@ #include "engine/draw_screen.h" +#include "engine/bullet.h"" #include "engine/level.h" #include "engine/maths.h" #include "engine/sprite_controller.h" diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c index 22f6eb6..f938844 100644 --- a/src/engine/player_controller.c +++ b/src/engine/player_controller.c @@ -3,7 +3,7 @@ #include "engine/draw_screen.h" #include "engine/sprite_controller.h" #include "engine/player_controller.h" - +#include "engine/bullet.h" #include "input.h" void hh_player_actions() { @@ -29,6 +29,17 @@ void hh_player_actions() { // hh_input_read(); player.vel = (vec2){.x = (-1 * g_hh_controller_p1.dpad_left) + (1 * g_hh_controller_p1.dpad_right), .y = (-1 * g_hh_controller_p1.dpad_up) + (1 * g_hh_controller_p1.dpad_down) }; + + // shooting code + static Bullet bullet; + if(g_hh_controller_p1.button_primary){ + bullet.isActive = false; + shootBullet(player.vel, &bullet); + } + else{ + updateBullet(&bullet, 1); + + } // const int8_t maa = 3; // const int8_t mbb = -3; // if (g_hh_controller_p1.dpad_up) diff --git a/src/makefile b/src/makefile index d7d9087..94406ca 100644 --- a/src/makefile +++ b/src/makefile @@ -37,7 +37,11 @@ LOCAL_SRCS += main.c \ engine/draw_screen.c \ engine/camera.c \ engine/maths.c \ - engine/entity.c + engine/bullet.c \ + engine/entity.c \ + GameLoop/shop.c \ + GameLoop/startingScreen.c + CFLAGS += $(SHARED_FLAGS) LFLAGS += $(SHARED_FLAGS) -- cgit v1.2.3 From 2588df5f89da62b857287344d6a7f2cc6951e938 Mon Sep 17 00:00:00 2001 From: NielsCoding <48092678+heavydemon21@users.noreply.github.com> Date: Wed, 15 Mar 2023 18:56:15 +0100 Subject: architecture docu --- .vscode/settings.json | 15 ++++++++++++++- assets/TopLevelArchi | 1 + assets/hh_introScreen.png | Bin 0 -> 130932 bytes docs/architecture.md | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 assets/TopLevelArchi create mode 100644 assets/hh_introScreen.png diff --git a/.vscode/settings.json b/.vscode/settings.json index d027762..7f37ba0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,5 +8,18 @@ } }, "cmake.configureOnOpen": false, - "files.eol": "\n" + "files.eol": "\n", + "nrf-connect.topdir": "${nrf-connect.sdk:2.1.2}", + "nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.1.2}", + "files.associations": { + "input.h": "c", + "draw_screen.h": "c", + "camera.h": "c", + "entity.h": "c", + "stdint.h": "c", + "player_controller.h": "c", + "sprite_controller.h": "c", + "types.h": "c", + "startingscreen.h": "c" + } } diff --git a/assets/TopLevelArchi b/assets/TopLevelArchi new file mode 100644 index 0000000..bd8c538 --- /dev/null +++ b/assets/TopLevelArchi @@ -0,0 +1 @@ +zVdNc5swEP01PrYDFlD76NhpOtN0yowPSY8KbECtYD3y4o/++kpGfDuJkzp1fTG72hXSe29XYsTm2e5G8VX6DWOQo7ET70ZsMRqPXT9w9J/x7EvP1JuUjkSJ2AY1jqX4DdZp85JCxLDuBBKiJLHqOiPMc4io4+NK4bYb9oiy+9YVT2DgWEZcDr13IqbUet1g2gx8AZGk9tWT8adyIONVsN3JOuUxblsudj1ic4VI5VO2m4M04FW4lHmfnxitF6Ygp1MSvPAuyxcOfL1NQr8QyfebOPzg27XRvtowxHr/1kRFKSaYc3ndeK8UFnkMZlZHW03MLeJKO13t/AlEe0smLwi1K6VM2lG9YLW/t/kH44cxPvqVudi1Bxd7a5VrNQt8EgLrWmOhInhm38xKiasE6Jk4ryZKKxwwA70enadAchKb7jq4lVpSxzVs6AdLyCvIsYvccFnYN4WS70ENONPSWpnHIpOziFBprDagSGgZ3/IHkCGuBQnMdcgDEmGmA6QZuOLRr+TA5xylydOzscfDrzXHTIrE5JLht00kFiRFDvO69hqWTC7snudpiKtN8G3J2J7hVSW0bVWgY31pq/jcKvHsVHgDKnTDIYVSHqGjWyDbVBAsV/ygx63ukl0MzwAXG3fx8t0hXpNjcLnvBdf0om3F7bYV1vu90GUOVghKaChAnb/1BCe2HnbJ1hMM9L6MFED+32md+ZMLa72auIXVghO/OFK+00OKHemi4yNQ1fidH6rhiTZsFHk8M/c2bUWSr9ci6lX5TtB967l1ddBWU9PGeIeLg3di9brOcXJa4PtHsK98J1e5fUOIQu+k5t7rnaBBn9JynzarfWnsTdQXUcB6E5VADCY6yKPe9l8oZnjwvl4xT5wL//C6WfWIF2UTXFI1bp/s6RtV4/bl551LNdpsvpjK8Oa7k13/AQ== \ No newline at end of file diff --git a/assets/hh_introScreen.png b/assets/hh_introScreen.png new file mode 100644 index 0000000..8b6e192 Binary files /dev/null and b/assets/hh_introScreen.png differ diff --git a/docs/architecture.md b/docs/architecture.md index 5001eed..94f17a4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,3 +1,38 @@ +# Hooded Havic: Miniboss Mania +![intro arcade game](../assets/hh_introScreen.png) + +# introduction +Welcome to Hooded Havoc: Miniboss Mania, an exciting 2D platformer game created by our team Joshua, Loek, Bjorn, Frenk and Niels! This game was developed using the STM32 microcontroller as the game engine and the FPGA as the Picture Processing Unit (PPU). + +In Hooded Havoc: Miniboss Mania, you will take on the role of a brave hero who must battle through multiple levels filled with challenging obstacles and formidable minibosses. With smooth gameplay and engaging graphics, you will feel immersed in a world of adventure and excitement. + +Our use of the STM32 microcontroller and FPGA PPU allowed us to create a unique and innovative gaming experience. The STM32 provides efficient and reliable processing power, while the FPGA ensures that our graphics are rendered smoothly and accurately. + +So get ready to embark on a thrilling journey through Hooded Havoc: Miniboss Mania, and see how far you can make it! +## Objective +The objective of Hooded Havoc: Miniboss Mania is to guide the hero through multiple levels, defeating minibosses and overcoming obstacles along the way. The ultimate goal is to reach the final boss and defeat them to retrieve the stolen staff. + +To achieve this objective, the player must use their platforming skills to jump, run, and dodge obstacles while also battling enemies and minibosses. Each level presents a unique challenge that will require the player to adapt and strategize to overcome. + +As the player progresses through the game, they will unlock new abilities and power-ups that will aid them in their journey. The player must use these abilities wisely to defeat the minibosses and ultimately save the world. + +So, the objective of Hooded Havoc: Miniboss Mania is not only to provide an exciting and engaging gaming experience but also to challenge players to use their skills and strategic thinking to overcome obstacles and emerge victorious. +## Problem statement +One potential problem that could arise in the development of Hooded Havoc: Miniboss Mania is related to the PPU and communication between the STM32 and PPU. + +The PPU is responsible for rendering the graphics and displaying them on the screen, while the STM32 is responsible for processing the game logic and input from the player. However, if there is a problem with the communication between these two components, it could lead to synchronization issues and graphical glitches that could affect the player's experience. + +For example, if the PPU is unable to keep up with the processing speed of the STM32, the graphics may lag or appear distorted, causing the game to become unplayable. Similarly, if there is a delay in communication between the STM32 and PPU, it could result in a mismatch between the game logic and the displayed graphics, leading to confusion for the player. + +To ensure a smooth and enjoyable gaming experience, it is essential to address any potential issues with the PPU and communication between the STM32 and PPU during the development process. This may involve optimizing the code for both components, adjusting the communication protocol, or adding buffer systems to prevent lag or synchronization issues. +### architecture ( top level) +![Top level architecture](../assets/TopLevelArchi); + + + + +### design document (mid-low level) + # General system architecture ![Top-down system architecture diagram](../assets/architecture-level-1.svg) -- cgit v1.2.3 From 2346a009fefb6e880bd7a36bb132cad833185080 Mon Sep 17 00:00:00 2001 From: NielsCoding <48092678+heavydemon21@users.noreply.github.com> Date: Wed, 15 Mar 2023 19:46:54 +0100 Subject: bob --- assets/TopLevel.PNG | Bin 0 -> 13919 bytes assets/TopLevelArchi | 1 - docs/BobSprint2.md | 19 +++++++++++++++++++ docs/architecture.md | 3 ++- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 assets/TopLevel.PNG delete mode 100644 assets/TopLevelArchi create mode 100644 docs/BobSprint2.md diff --git a/assets/TopLevel.PNG b/assets/TopLevel.PNG new file mode 100644 index 0000000..2a7b16d Binary files /dev/null and b/assets/TopLevel.PNG differ diff --git a/assets/TopLevelArchi b/assets/TopLevelArchi deleted file mode 100644 index bd8c538..0000000 --- a/assets/TopLevelArchi +++ /dev/null @@ -1 +0,0 @@ -zVdNc5swEP01PrYDFlD76NhpOtN0yowPSY8KbECtYD3y4o/++kpGfDuJkzp1fTG72hXSe29XYsTm2e5G8VX6DWOQo7ET70ZsMRqPXT9w9J/x7EvP1JuUjkSJ2AY1jqX4DdZp85JCxLDuBBKiJLHqOiPMc4io4+NK4bYb9oiy+9YVT2DgWEZcDr13IqbUet1g2gx8AZGk9tWT8adyIONVsN3JOuUxblsudj1ic4VI5VO2m4M04FW4lHmfnxitF6Ygp1MSvPAuyxcOfL1NQr8QyfebOPzg27XRvtowxHr/1kRFKSaYc3ndeK8UFnkMZlZHW03MLeJKO13t/AlEe0smLwi1K6VM2lG9YLW/t/kH44cxPvqVudi1Bxd7a5VrNQt8EgLrWmOhInhm38xKiasE6Jk4ryZKKxwwA70enadAchKb7jq4lVpSxzVs6AdLyCvIsYvccFnYN4WS70ENONPSWpnHIpOziFBprDagSGgZ3/IHkCGuBQnMdcgDEmGmA6QZuOLRr+TA5xylydOzscfDrzXHTIrE5JLht00kFiRFDvO69hqWTC7snudpiKtN8G3J2J7hVSW0bVWgY31pq/jcKvHsVHgDKnTDIYVSHqGjWyDbVBAsV/ygx63ukl0MzwAXG3fx8t0hXpNjcLnvBdf0om3F7bYV1vu90GUOVghKaChAnb/1BCe2HnbJ1hMM9L6MFED+32md+ZMLa72auIXVghO/OFK+00OKHemi4yNQ1fidH6rhiTZsFHk8M/c2bUWSr9ci6lX5TtB967l1ddBWU9PGeIeLg3di9brOcXJa4PtHsK98J1e5fUOIQu+k5t7rnaBBn9JynzarfWnsTdQXUcB6E5VADCY6yKPe9l8oZnjwvl4xT5wL//C6WfWIF2UTXFI1bp/s6RtV4/bl551LNdpsvpjK8Oa7k13/AQ== \ No newline at end of file diff --git a/docs/BobSprint2.md b/docs/BobSprint2.md new file mode 100644 index 0000000..6fff8fc --- /dev/null +++ b/docs/BobSprint2.md @@ -0,0 +1,19 @@ + + +# Proud of +Simulation: We're proud of the simulation that we created to test our game because it allows us to identify and address potential issues before the game is released. This helps ensure that the game is as polished and bug-free as possible. + +PPU: Our use of an FPGA-based PPU (Picture Processing Unit) in our game engine allows us to achieve high-quality graphics and smooth animation. This is important because it helps create an immersive and engaging gaming experience. + +Upscaling: We've implemented a sophisticated upscaling that allows us to scale up our game. This Ensures that our game runs smoothly and without any + +Collisions: We've put a lot of effort into making sure that our collision detection system is accurate and reliable. This ensures that the game mechanics work as intended and that players are able to navigate the game world without frustration. + +Artwork: We're proud of the artwork that was created which is stunning and imaginative artwork that brings the game world to life. From character designs to background artwork, every aspect of the game has been given careful attention to ensure that it looks as good as it plays. And more is coming! +# Challegens +Upscaling: While our upscaling algorithm is sophisticated, one of the challenges we faced was synchronization. Because we're upscaling in real-time, we had to ensure that the upscaling process didn't cause any lag or delay in the game. This required careful optimization of the algorithm and synchronization with other game components. + +PPU: While the use of an FPGA-based PPU allowed us to achieve high-quality graphics, it also presented some challenges. Specifically, the limited resources of the FPGA required us to optimize the PPU code to ensure that it could handle the demands of real-time gameplay. + +Communication bug fixes on the STM32: As with any complex system, we encountered some bugs in the communication between the STM32 microcontroller and the other components of the system. This required careful debugging and troubleshooting to identify and fix the issues. + diff --git a/docs/architecture.md b/docs/architecture.md index 94f17a4..d4632b5 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -25,8 +25,9 @@ The PPU is responsible for rendering the graphics and displaying them on the scr For example, if the PPU is unable to keep up with the processing speed of the STM32, the graphics may lag or appear distorted, causing the game to become unplayable. Similarly, if there is a delay in communication between the STM32 and PPU, it could result in a mismatch between the game logic and the displayed graphics, leading to confusion for the player. To ensure a smooth and enjoyable gaming experience, it is essential to address any potential issues with the PPU and communication between the STM32 and PPU during the development process. This may involve optimizing the code for both components, adjusting the communication protocol, or adding buffer systems to prevent lag or synchronization issues. + ### architecture ( top level) -![Top level architecture](../assets/TopLevelArchi); +![Top level architecture](../assets/TopLevel.PNG.); -- cgit v1.2.3 From 6a70bf52bc2ed5d28b7d08854fabfaee27be3e84 Mon Sep 17 00:00:00 2001 From: NielsCoding <48092678+heavydemon21@users.noreply.github.com> Date: Wed, 15 Mar 2023 20:08:12 +0100 Subject: architecture and design --- docs/architecture.md | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index d4632b5..cf4440f 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -26,14 +26,40 @@ For example, if the PPU is unable to keep up with the processing speed of the ST To ensure a smooth and enjoyable gaming experience, it is essential to address any potential issues with the PPU and communication between the STM32 and PPU during the development process. This may involve optimizing the code for both components, adjusting the communication protocol, or adding buffer systems to prevent lag or synchronization issues. -### architecture ( top level) +# architecture ( top level) ![Top level architecture](../assets/TopLevel.PNG.); - - - -### design document (mid-low level) - +## STM32 +### game engine +### user input +### PPU communication +### APU communication +### level editing pipeline + +## FPGA (PPU) +### PPU +### SPI +### APU + +## Screen +### VGA + + +# design document (mid-low level) +## STM32 +### game engine +### user input +### PPU communication +### APU communication +### level editing pipeline + +## FPGA (PPU) +### PPU +### SPI +### APU + +## Screen +### VGA # General system architecture ![Top-down system architecture diagram](../assets/architecture-level-1.svg) -- cgit v1.2.3 From 1c0cb0d1cf8c9cb6a11aa404d8c31def1087a586 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 15 Mar 2023 21:57:44 +0100 Subject: (UNCLEAN) partial merge of #37 --- .vscode/settings.json | 15 +-------------- src/GameLoop/shop.h | 4 ++-- src/GameLoop/startingScreen.h | 8 +++----- src/engine/draw_screen.c | 3 ++- src/engine/engine.c | 2 +- src/engine/entity.c | 4 ++++ 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7f37ba0..d027762 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,18 +8,5 @@ } }, "cmake.configureOnOpen": false, - "files.eol": "\n", - "nrf-connect.topdir": "${nrf-connect.sdk:2.1.2}", - "nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.1.2}", - "files.associations": { - "input.h": "c", - "draw_screen.h": "c", - "camera.h": "c", - "entity.h": "c", - "stdint.h": "c", - "player_controller.h": "c", - "sprite_controller.h": "c", - "types.h": "c", - "startingscreen.h": "c" - } + "files.eol": "\n" } diff --git a/src/GameLoop/shop.h b/src/GameLoop/shop.h index 35bb780..39db9fd 100644 --- a/src/GameLoop/shop.h +++ b/src/GameLoop/shop.h @@ -1,7 +1,8 @@ +#pragma once + #include "input.h" #include "engine/draw_screen.h" - #include #include @@ -11,5 +12,4 @@ typedef enum { hh_e_STATE_END } hh_e_ShopStates; - bool hh_show_Shop(); diff --git a/src/GameLoop/startingScreen.h b/src/GameLoop/startingScreen.h index f51cc66..5b4f15a 100644 --- a/src/GameLoop/startingScreen.h +++ b/src/GameLoop/startingScreen.h @@ -1,13 +1,11 @@ #pragma once +#include "GameLoop/shop.h" #include #include -typedef enum { - hh_e_STATE_SHOW, - hh_e_STATE_Input, - hh_e_STATE_END -} hh_e_screenStates; +// TODO: fix naming of enum consts +typedef hh_e_ShopStates hh_e_screenStates; bool hh_show_startingScreen(); diff --git a/src/engine/draw_screen.c b/src/engine/draw_screen.c index 205d4b6..43d3cd4 100644 --- a/src/engine/draw_screen.c +++ b/src/engine/draw_screen.c @@ -61,10 +61,11 @@ void hh_setup_screen(){ } void hh_setup_startingScreen(){ + return; int size = 300; // 40 x as tiles 30 y as tiles FILE* level = fopen("../test/bin/startingScreen.bin", "rb"); /* open binary file */ if (!level) { /* check if file opened successfully */ - fprintf(stderr, "Error: Failed to open file.\n"); + fprintf(stderr, "Error: Failed to open file. AAAA\n"); return; } fseek(level, (0* sizeof(int)) + sizeof(int), SEEK_SET); diff --git a/src/engine/engine.c b/src/engine/engine.c index 3280892..d852a99 100644 --- a/src/engine/engine.c +++ b/src/engine/engine.c @@ -1,5 +1,5 @@ #include "engine/draw_screen.h" -#include "engine/bullet.h"" +#include "engine/bullet.h" #include "engine/level.h" #include "engine/maths.h" #include "engine/sprite_controller.h" diff --git a/src/engine/entity.c b/src/engine/entity.c index 153e7e1..888539a 100644 --- a/src/engine/entity.c +++ b/src/engine/entity.c @@ -3,6 +3,10 @@ #include "engine/entity.h" #include "engine/maths.h" +#ifdef HH_TARGET_DESKTOP +#include +#endif + /* PLAYER: (pos on X) ,___, -- cgit v1.2.3 From 51ee4672d5f2f734eb40f4312a2aefd2f8c6dc03 Mon Sep 17 00:00:00 2001 From: BjornMartens <113104306+BjornMartens@users.noreply.github.com> Date: Thu, 16 Mar 2023 09:58:34 +0100 Subject: Added top level stm --- docs/architecture.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/architecture.md b/docs/architecture.md index cf4440f..3b4a877 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -31,6 +31,17 @@ To ensure a smooth and enjoyable gaming experience, it is essential to address a ## STM32 ### game engine +The game engine is designed to run a 2D platformer game. The game engine has to manage all the different game states. To do this it will utilize a finite state machine (FSM). The game engine will also cover de input handling from the player, the game logic for example enemy handling or the powerup handling it will also send out data to the APU (Audio processing unit) so that the right sounds will be played. + +FSM is a useful tool for managing game states and transitions. The game has many different states such as: title screen, shop and gameplay state. Each state represents a particular configuration from the with different logic and variables. + +The state machine is designed to have the following states: +1. Initialization: The initialization state will be responsible for initializing all game-related variables and subsystems, including the FPGA-based picture processing unit. +2. Title Screen: The title screen state will display the game's title screen and wait for user input to start the game or access the options menu. +3. Options: The options state will allow the user to configure game settings, such as sound and graphics options. +4. Game Play: The game play state will be responsible for running the game logic and updating the game state. +5. Game Over: The game over state will display the game over screen and wait for user input to restart the game or return to the title screen. + ### user input ### PPU communication ### APU communication -- cgit v1.2.3