aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GameLoop/shop.c28
-rw-r--r--src/GameLoop/shop.h15
-rw-r--r--src/GameLoop/startingScreen.c30
-rw-r--r--src/GameLoop/startingScreen.h12
-rw-r--r--src/demo.c62
-rw-r--r--src/engine/bullet.c39
-rw-r--r--src/engine/bullet.h14
-rw-r--r--src/engine/draw_screen.c50
-rw-r--r--src/engine/draw_screen.h5
-rw-r--r--src/engine/engine.c1
-rw-r--r--src/engine/entity.c4
-rw-r--r--src/engine/player_controller.c13
-rw-r--r--src/makefile6
13 files changed, 8 insertions, 271 deletions
diff --git a/src/GameLoop/shop.c b/src/GameLoop/shop.c
deleted file mode 100644
index 31ff5ce..0000000
--- a/src/GameLoop/shop.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#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
deleted file mode 100644
index 39db9fd..0000000
--- a/src/GameLoop/shop.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#include "input.h"
-#include "engine/draw_screen.h"
-
-#include <stdint.h>
-#include <stdbool.h>
-
-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
deleted file mode 100644
index a0cd283..0000000
--- a/src/GameLoop/startingScreen.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#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
deleted file mode 100644
index 5b4f15a..0000000
--- a/src/GameLoop/startingScreen.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#pragma once
-
-#include "GameLoop/shop.h"
-#include <stdint.h>
-#include <stdbool.h>
-
-// TODO: fix naming of enum consts
-typedef hh_e_ShopStates hh_e_screenStates;
-
-
-bool hh_show_startingScreen();
-
diff --git a/src/demo.c b/src/demo.c
index f5b5c29..95347cb 100644
--- a/src/demo.c
+++ b/src/demo.c
@@ -13,17 +13,6 @@
#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
@@ -56,59 +45,18 @@ 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:
- 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;
- }
-
+ hh_player_actions();
}
diff --git a/src/engine/bullet.c b/src/engine/bullet.c
deleted file mode 100644
index eafd4e7..0000000
--- a/src/engine/bullet.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#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
deleted file mode 100644
index f119829..0000000
--- a/src/engine/bullet.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#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 43d3cd4..c4f3389 100644
--- a/src/engine/draw_screen.c
+++ b/src/engine/draw_screen.c
@@ -19,6 +19,7 @@ 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){
@@ -59,52 +60,3 @@ void hh_setup_screen(){
}
free(tile);
}
-
-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. AAAA\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 bfe8bf8..b181108 100644
--- a/src/engine/draw_screen.h
+++ b/src/engine/draw_screen.h
@@ -19,8 +19,3 @@ 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 d852a99..799ee7c 100644
--- a/src/engine/engine.c
+++ b/src/engine/engine.c
@@ -1,5 +1,4 @@
#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/entity.c b/src/engine/entity.c
index 888539a..153e7e1 100644
--- a/src/engine/entity.c
+++ b/src/engine/entity.c
@@ -3,10 +3,6 @@
#include "engine/entity.h"
#include "engine/maths.h"
-#ifdef HH_TARGET_DESKTOP
-#include <stdio.h>
-#endif
-
/*
PLAYER: (pos on X)
,___,
diff --git a/src/engine/player_controller.c b/src/engine/player_controller.c
index f938844..22f6eb6 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,17 +29,6 @@ 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 94406ca..d7d9087 100644
--- a/src/makefile
+++ b/src/makefile
@@ -37,11 +37,7 @@ LOCAL_SRCS += main.c \
engine/draw_screen.c \
engine/camera.c \
engine/maths.c \
- engine/bullet.c \
- engine/entity.c \
- GameLoop/shop.c \
- GameLoop/startingScreen.c
-
+ engine/entity.c
CFLAGS += $(SHARED_FLAGS)
LFLAGS += $(SHARED_FLAGS)