final oop style

This commit is contained in:
huaqo
2026-03-01 12:57:09 +01:00
parent c064e80be2
commit e1596f633d
10 changed files with 1004 additions and 393 deletions
-2
View File
@@ -20,11 +20,9 @@ C_FLAGS = \
INCLUDE_FLAGS = -Iinclude INCLUDE_FLAGS = -Iinclude
EXTERNAL_ENGINE = -Iexternal/engine
EXTERNAL_RAYGUI = -Iexternal/raygui EXTERNAL_RAYGUI = -Iexternal/raygui
EXTERNAL_RINI = -Iexternal/rini EXTERNAL_RINI = -Iexternal/rini
EXTERNAL_FLAGS = \ EXTERNAL_FLAGS = \
$(EXTERNAL_ENGINE) \
$(EXTERNAL_RINI) \ $(EXTERNAL_RINI) \
$(EXTERNAL_RAYGUI) $(EXTERNAL_RAYGUI)
+684
View File
@@ -0,0 +1,684 @@
[
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/app.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/app.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameBirds.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameBirds.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGame.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGame.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameEnemies.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameEnemies.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameFloor.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameFloor.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameIslands.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameIslands.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGamePlayer.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGamePlayer.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameShip.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameShip.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appGameShoot.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appGameShoot.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appLogo.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appLogo.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appMenu.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appMenu.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appMenuMainBackground.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appMenuMainBackground.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appMenuMain.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appMenuMain.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appMenuSettings.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appMenuSettings.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/appState.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/appState.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineAnimation.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineAnimation.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineArray.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineArray.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineCamera.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineCamera.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineConfig.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineConfig.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineFont.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineFont.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineGamegui.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineGamegui.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineGui.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineGui.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineInput.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineInput.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineObject.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineObject.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/enginePhysics.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/enginePhysics.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/enginePostfx.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/enginePostfx.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineRectangle.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineRectangle.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineSoundtrack.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineSoundtrack.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineSprite.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineSprite.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/engineVector.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/engineVector.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
},
{
"arguments": [
"/usr/bin/gcc",
"-c",
"-std=c99",
"-g",
"-Wall",
"-Wpedantic",
"-Wshadow",
"-Wstrict-prototypes",
"-Wno-unknown-pragmas",
"-Iinclude",
"-Iexternal/rini",
"-Iexternal/raygui",
"-o",
"bin/osx/game",
"src/main.c"
],
"directory": "/home/huaqo/dev/the-last-hive",
"file": "/home/huaqo/dev/the-last-hive/src/main.c",
"output": "/home/huaqo/dev/the-last-hive/bin/osx/game"
}
]
+8
View File
@@ -0,0 +1,8 @@
# ship_start
start_id = 0
start_path = assets/ship_start.png
start_frameSize = 16
start_spped_0 = 0
start_speed_1 = 5
start_speed_2 = 10
start_rotationSpeed = 50
+50 -102
View File
@@ -1,17 +1,16 @@
#ifndef APPTYPES_H #ifndef APPTYPES_H
#define APPTYPES_H #define APPTYPES_H
//INCLUDES// // INCLUDES//
#include <raylib.h>
#include <engine.h> #include <engine.h>
#include <raylib.h>
//DEFINES// // DEFINES//
#define TEXT_COLOR_DARK (Color){ 182, 137, 98, 255} #define TEXT_COLOR_DARK (Color){182, 137, 98, 255}
#define TEXT_COLOR_LIGHT (Color){ 243, 229, 194, 255} #define TEXT_COLOR_LIGHT (Color){243, 229, 194, 255}
//ENUMS// // ENUMS//
typedef enum typedef enum {
{
MENU_CURSOR_TEX, MENU_CURSOR_TEX,
MENU_BIG_BUTTONS_TEX, MENU_BIG_BUTTONS_TEX,
MENU_BOARD_TEX, MENU_BOARD_TEX,
@@ -21,63 +20,25 @@ typedef enum
MENU_TEX_COUNT MENU_TEX_COUNT
} MenuTextureID; } MenuTextureID;
typedef enum typedef enum { MENU_MUSIC, MENU_SOUNDTRACK_COUNT } MenuSoundtrackID;
{
MENU_MUSIC,
MENU_SOUNDTRACK_COUNT
} MenuSoundtrackID;
typedef enum typedef enum { HOVER_SOUND, CLICK_SOUND, MENU_SOUND_COUNT } MenuSoundID;
{
HOVER_SOUND,
CLICK_SOUND,
MENU_SOUND_COUNT
} MenuSoundID;
typedef enum MenuView { typedef enum MenuView { MAIN = 0, SETTINGS = 1 } MenuView;
MAIN = 0,
SETTINGS = 1
} MenuView;
typedef enum typedef enum { START_SHIP, PLAYER_TEX_COUNT } playerTextureID;
{
START_SHIP,
PLAYER_TEX_COUNT
} playerTextureID;
typedef enum { typedef enum { ANCHOR, SLOW_AHEAD, FAST_AHEAD, SPEED_COUNT } playerSpeedID;
ANCHOR,
SLOW_AHEAD,
FAST_AHEAD,
SPEED_COUNT
} playerSpeedID;
typedef enum { ISLAND, ISLANDS_TEX_COUNT } islandsTextureID;
typedef enum typedef enum { POST_FX, SHADER_COUNT } ShaderID;
{
ISLAND,
ISLANDS_TEX_COUNT
} islandsTextureID;
typedef enum typedef enum { BEE_AMBIENT, SOUNDTRACK_COUNT } SoundtrackID;
{
POST_FX,
SHADER_COUNT
} ShaderID;
typedef enum typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View;
{
BEE_AMBIENT,
SOUNDTRACK_COUNT
} SoundtrackID;
typedef enum View { // STRUCTS//
LOGO = 0,
MENU = 1,
GAMEPLAY = 2
} View;
//STRUCTS//
typedef struct { typedef struct {
int frameCounter; int frameCounter;
int positionX; int positionX;
@@ -115,65 +76,49 @@ typedef struct {
Background foreground; Background foreground;
} MenuMain; } MenuMain;
typedef struct typedef struct {
{
Button showFPS; Button showFPS;
Button limitFPS; Button limitFPS;
Button soundtrackOn; Button soundtrackOn;
} MenuSettings; } MenuSettings;
typedef struct {
typedef struct
{
MenuView menuView; MenuView menuView;
MenuMain menuMain; MenuMain menuMain;
MenuSettings menuSettings; MenuSettings menuSettings;
} MenuState; } MenuState;
typedef struct {
typedef struct
{
Sprite sprite; Sprite sprite;
Rectangle bounds; Rectangle bounds;
Shader shader; Shader shader;
float time; float time;
} Floor; } Floor;
typedef struct typedef struct {
{
Sprite sprite; Sprite sprite;
Animation animation; Animation animation;
Physics physics; Physics physics;
float rotation; float rotation;
} Player; } Player;
typedef enum typedef enum { BOAT, ENEMIES_TEX_COUNT } enemiesTextureID;
{
BOAT,
ENEMIES_TEX_COUNT
} enemiesTextureID;
typedef enum typedef enum { START, SHIP_COUNT } shipID;
{
START,
SHIP_COUNT
} shipID;
typedef struct typedef struct {
{
int id; int id;
char* assetPath; char *assetPath;
int frameSize; int frameSize;
int speed0; int speed0;
int speed1; int speed1;
int speed2; int speed2;
int rotationSpeed; int rotationSpeed;
}Ship; } Ship;
#define MAX_ENEMIES 100 #define MAX_ENEMIES 100
typedef struct typedef struct {
{
Config config; Config config;
int count; int count;
Sprite sprite[MAX_ENEMIES]; Sprite sprite[MAX_ENEMIES];
@@ -183,11 +128,7 @@ typedef struct
Vector2 destPos[MAX_ENEMIES]; Vector2 destPos[MAX_ENEMIES];
} Enemies; } Enemies;
typedef enum typedef enum { FLYING, BIRDS_TEX_COUNT } birdsTextureID;
{
FLYING,
BIRDS_TEX_COUNT
} birdsTextureID;
#define MAX_BIRDS 100 #define MAX_BIRDS 100
@@ -206,8 +147,14 @@ typedef struct {
Physics physics; Physics physics;
} Islands; } Islands;
typedef struct #define MAX_PROJECTILES 10
{ typedef struct {
Physics physics[MAX_PROJECTILES];
bool active[MAX_PROJECTILES];
float radius[MAX_PROJECTILES];
} Projectiles;
typedef struct {
Assets assets; Assets assets;
PostProcessing postFX[SHADER_COUNT]; PostProcessing postFX[SHADER_COUNT];
Soundtrack soundtracks[SOUNDTRACK_COUNT]; Soundtrack soundtracks[SOUNDTRACK_COUNT];
@@ -218,6 +165,7 @@ typedef struct
Islands islands; Islands islands;
Mouse mouse; Mouse mouse;
Image image; Image image;
Projectiles projectiles;
} GameState; } GameState;
typedef struct { typedef struct {
@@ -243,29 +191,25 @@ typedef struct {
GameState game; GameState game;
} App; } App;
#define MAX_PROJECTILES 10 // FUNCTIONS//
typedef struct {
Physics physics[MAX_PROJECTILES];
bool active[MAX_PROJECTILES];
float radius[MAX_PROJECTILES];
} Projectile;
//FUNCTIONS//
void InitLogo(LogoState *l); void InitLogo(LogoState *l);
void UpdateLogo(LogoState *l, View *currentView, bool *running); void UpdateLogo(LogoState *l, View *currentView, bool *running);
void RenderLogo(const LogoState *l, Flags *flags); void RenderLogo(const LogoState *l, Flags *flags);
void InitBackground(float scrollSpeed, Background *bg, Texture2D *texture, const TextureAsset *backgroundAsset); void InitBackground(float scrollSpeed, Background *bg, Texture2D *texture,
const TextureAsset *backgroundAsset);
void UpdateBackground(Background *bg); void UpdateBackground(Background *bg);
void RenderBackground(Background *bg); void RenderBackground(Background *bg);
void InitMenuMain(MenuMain *m); void InitMenuMain(MenuMain *m);
void UpdateMenuMain(MenuMain *m, State *state, Flags *flags, MenuView *menuView); void UpdateMenuMain(MenuMain *m, State *state, Flags *flags,
MenuView *menuView);
void RenderMenuMain(MenuMain *m, Font *font, const char *title, Flags *flags); void RenderMenuMain(MenuMain *m, Font *font, const char *title, Flags *flags);
void CleanupMenuMain(MenuMain *m); void CleanupMenuMain(MenuMain *m);
void InitMenuSettings(MenuSettings *s); void InitMenuSettings(MenuSettings *s);
void UpdateMenuSettings(MenuSettings *s, MenuView *menuView, State *state, Flags *flags); void UpdateMenuSettings(MenuSettings *s, MenuView *menuView, State *state,
Flags *flags);
void RenderMenuSettings(MenuSettings *s, Flags *flags); void RenderMenuSettings(MenuSettings *s, Flags *flags);
void CleanupMenuSettings(MenuSettings *s); void CleanupMenuSettings(MenuSettings *s);
@@ -280,7 +224,7 @@ void RenderFloor(Floor *floor);
void UnloadFloor(Floor *floor); void UnloadFloor(Floor *floor);
playerSpeedID GetPlayerSpeedID(float speed); playerSpeedID GetPlayerSpeedID(float speed);
Player* GetPlayer(void); Player *GetPlayer(void);
void CreatePlayer(void); void CreatePlayer(void);
void UpdatePlayer(void); void UpdatePlayer(void);
void RenderPlayer(void); void RenderPlayer(void);
@@ -297,6 +241,10 @@ Islands CreateIslands(void);
void UpdateIslands(Islands *islands); void UpdateIslands(Islands *islands);
void RenderIslands(Islands *islands); void RenderIslands(Islands *islands);
Projectiles CreateProjectiles(void);
void UpdateProjectiles(Projectiles *projectiles);
void RenderProjectiles(Projectiles *projectiles);
void InitGame(App *app); void InitGame(App *app);
void UpdateGame(App *app); void UpdateGame(App *app);
void RenderComponents(App *app); void RenderComponents(App *app);
@@ -311,4 +259,4 @@ void InitApp(App *app);
void UpdateApp(App *app); void UpdateApp(App *app);
void CleanupApp(App *app); void CleanupApp(App *app);
#endif //APPTYPES_H #endif // APPTYPES_H
+14 -19
View File
@@ -1,6 +1,6 @@
#include "app.h" #include "app.h"
void ConfigApp(App* app){ void ConfigApp(App *app) {
InitConfig(&app->config, "config/config.ini"); InitConfig(&app->config, "config/config.ini");
app->state.currentView = GetConfigInt(&app->config, "startView"); app->state.currentView = GetConfigInt(&app->config, "startView");
app->flags.showFPS = GetConfigInt(&app->config, "showFPS"); app->flags.showFPS = GetConfigInt(&app->config, "showFPS");
@@ -11,46 +11,41 @@ void ConfigApp(App* app){
app->window.height = GetConfigInt(&app->config, "windowHeight"); app->window.height = GetConfigInt(&app->config, "windowHeight");
} }
void InitApp(App *app){ void InitApp(App *app) {
InitFont(&app->font, GetConfigString(&app->config, "fontPath")); InitFont(&app->font, GetConfigString(&app->config, "fontPath"));
InitLogo(&app->logo); InitLogo(&app->logo);
InitMenu(&app->menu); InitMenu(&app->menu);
InitGame(app); InitGame(app);
} }
void UpdateApp(App *app){ void UpdateApp(App *app) {
app->state.running = true; app->state.running = true;
app->state.gameStarted = false; app->state.gameStarted = false;
while (app->state.running) while (app->state.running) {
{ switch (app->state.currentView) {
switch (app->state.currentView) case LOGO: {
{
case LOGO:
{
UpdateLogo(&app->logo, &app->state.currentView, &app->state.running); UpdateLogo(&app->logo, &app->state.currentView, &app->state.running);
RenderLogo(&app->logo, &app->flags); RenderLogo(&app->logo, &app->flags);
}break; } break;
case MENU: case MENU: {
{
UpdateMenu(&app->menu, &app->state, &app->flags); UpdateMenu(&app->menu, &app->state, &app->flags);
RenderMenu(&app->menu, &app->font, app->window.title, &app->flags); RenderMenu(&app->menu, &app->font, app->window.title, &app->flags);
}break; } break;
case GAMEPLAY: case GAMEPLAY: {
{
UpdateGame(app); UpdateGame(app);
RenderGame(app); RenderGame(app);
}break; } break;
default: break; default:
break;
} }
} }
} }
void CleanupApp(App *app){ void CleanupApp(App *app) {
CleanupMenu(&app->menu); CleanupMenu(&app->menu);
CleanupGame(app); CleanupGame(app);
CleanupFont(&app->font); CleanupFont(&app->font);
CleanUpConfig(&app->config); CleanUpConfig(&app->config);
} }
+27 -52
View File
@@ -1,61 +1,48 @@
#include "app.h" #include "app.h"
const ShaderAsset shaderAssets[SHADER_COUNT] = { const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
{"shaders/postfx.fs"}
};
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = { const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {{"assets/sea.mp3"}};
{"assets/sea.mp3"}
};
void InitGame(App *app) {
void InitGame(App *app)
{
SetRandomSeed(1234); SetRandomSeed(1234);
GameState *g = &app->game; GameState *g = &app->game;
g->assets = (Assets){ g->assets = (Assets){.shaderAssets = shaderAssets,
.shaderAssets = shaderAssets, .soundtrackAssets = soundtrackAssets};
.soundtrackAssets = soundtrackAssets
};
for (int i = 0; i < SHADER_COUNT; i++) for (int i = 0; i < SHADER_COUNT; i++) {
{
g->postFX[i] = CreatePostFX(g->assets.shaderAssets[i].path); g->postFX[i] = CreatePostFX(g->assets.shaderAssets[i].path);
} }
for (int i = 0; i < SOUNDTRACK_COUNT; i++) for (int i = 0; i < SOUNDTRACK_COUNT; i++) {
{
g->soundtracks[i] = LoadSoundtrack(g->assets.soundtrackAssets[i].path); g->soundtracks[i] = LoadSoundtrack(g->assets.soundtrackAssets[i].path);
} }
g->target = LoadRenderTexture(app->window.width, app->window.height); g->target = LoadRenderTexture(app->window.width, app->window.height);
CreatePlayer(); CreatePlayer();
Player* player = GetPlayer(); Player *player = GetPlayer();
CreateCamera(player->physics.position, 10.0f); CreateCamera(player->physics.position, 10.0f);
g->birds = CreateBirds(); g->birds = CreateBirds();
g->enemies = CreateEnemies(); g->enemies = CreateEnemies();
g->islands = CreateIslands(); g->islands = CreateIslands();
g->floor = CreateFloor(); g->floor = CreateFloor();
g->projectiles = CreateProjectiles();
Texture2D mouseTexture = LoadTexture("assets/mouse.png"); Texture2D mouseTexture = LoadTexture("assets/mouse.png");
g->mouse = CreateMouse(0.10f, 5.0f, 10.0f, &mouseTexture); g->mouse = CreateMouse(0.10f, 5.0f, 10.0f, &mouseTexture);
} }
void StartGame(App *app) void StartGame(App *app) {
{ if (!app->state.gameStarted) {
if(!app->state.gameStarted){
app->state.gameStarted = true; app->state.gameStarted = true;
} }
} }
void UpdateGame(App *app) {
void UpdateGame(App *app)
{
GameState *g = &app->game; GameState *g = &app->game;
if (app->flags.limitFPS){ if (app->flags.limitFPS) {
SetTargetFPS(60); SetTargetFPS(60);
} else { } else {
SetTargetFPS(0); SetTargetFPS(0);
@@ -66,17 +53,15 @@ void UpdateGame(App *app)
OnEscapeChangeView(app, MENU); OnEscapeChangeView(app, MENU);
OnWindowClosedStoppApp(app); OnWindowClosedStoppApp(app);
for (int i = 0; i < SHADER_COUNT; i++) for (int i = 0; i < SHADER_COUNT; i++) {
{
UpdatePostFX(&g->postFX[i]); UpdatePostFX(&g->postFX[i]);
} }
for (int i = 0; i < SOUNDTRACK_COUNT; i++) for (int i = 0; i < SOUNDTRACK_COUNT; i++) {
{
UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn); UpdateSoundtrack(&g->soundtracks[i], app->flags.soundtrackOn);
} }
UpdateMouse(&g->mouse); UpdateMouse(&g->mouse);
Player* player = GetPlayer(); Player *player = GetPlayer();
UpdateCamera2D(&player->physics.position, &g->mouse); UpdateCamera2D(&player->physics.position, &g->mouse);
UpdateFloor(&g->floor); UpdateFloor(&g->floor);
UpdatePlayer(); UpdatePlayer();
@@ -85,8 +70,7 @@ void UpdateGame(App *app)
UpdateIslands(&g->islands); UpdateIslands(&g->islands);
} }
void RenderComponents(App *app) void RenderComponents(App *app) {
{
GameState *g = &app->game; GameState *g = &app->game;
RenderFloor(&g->floor); RenderFloor(&g->floor);
RenderPlayer(); RenderPlayer();
@@ -95,8 +79,7 @@ void RenderComponents(App *app)
RenderIslands(&g->islands); RenderIslands(&g->islands);
} }
void RenderGame(App *app) void RenderGame(App *app) {
{
GameState *g = &app->game; GameState *g = &app->game;
BeginTextureMode(g->target); BeginTextureMode(g->target);
@@ -105,41 +88,33 @@ void RenderGame(App *app)
BeginMode2D(*camera); BeginMode2D(*camera);
RenderComponents(app); RenderComponents(app);
EndMode2D(); EndMode2D();
DrawTextureRec DrawTextureRec(
(
g->mouse.cursorTexture, g->mouse.cursorTexture,
(Rectangle){0, 0, g->mouse.cursorTexture.width, g->mouse.cursorTexture.height}, (Rectangle){0, 0, g->mouse.cursorTexture.width,
(Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, g->mouse.cursorTexture.height},
WHITE (Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, WHITE);
);
EndTextureMode(); EndTextureMode();
BeginDrawing(); BeginDrawing();
ClearBackground(BLACK); ClearBackground(BLACK);
for (int i = 0; i < SHADER_COUNT; i++) for (int i = 0; i < SHADER_COUNT; i++) {
{
RenderPostFX(&g->postFX[i], &g->target); RenderPostFX(&g->postFX[i], &g->target);
} }
if (app->flags.showFPS) if (app->flags.showFPS) {
{
DrawFPS(10, 10); DrawFPS(10, 10);
} }
EndDrawing(); EndDrawing();
} }
void CleanupGame(App *app) void CleanupGame(App *app) {
{
GameState *g = &app->game; GameState *g = &app->game;
for (int i = 0; i < SHADER_COUNT; i++) for (int i = 0; i < SHADER_COUNT; i++) {
{
UnloadPostFX(&g->postFX[i]); UnloadPostFX(&g->postFX[i]);
} }
for (int i = 0; i < SOUNDTRACK_COUNT; i++) for (int i = 0; i < SOUNDTRACK_COUNT; i++) {
{
UnloadMusicStream(g->soundtracks[i].music); UnloadMusicStream(g->soundtracks[i].music);
} }
UnloadRenderTexture(g->target); UnloadRenderTexture(g->target);
} }
+14 -22
View File
@@ -1,10 +1,9 @@
#include "app.h" #include "app.h"
const TextureAsset islandsTextureAssets[ISLANDS_TEX_COUNT] = { const TextureAsset islandsTextureAssets[ISLANDS_TEX_COUNT] = {
{"assets/island.png", 16.0f, 16.0f, 0.0f} {"assets/island.png", 16.0f, 16.0f, 0.0f}};
};
Islands CreateIslands(void){ Islands CreateIslands(void) {
TextureAsset islandAsset = islandsTextureAssets[ISLAND]; TextureAsset islandAsset = islandsTextureAssets[ISLAND];
Texture2D texture = LoadTexture(islandAsset.path); Texture2D texture = LoadTexture(islandAsset.path);
float frameWidth = islandAsset.frameWidth; float frameWidth = islandAsset.frameWidth;
@@ -14,34 +13,27 @@ Islands CreateIslands(void){
.texture = texture, .texture = texture,
.frameSize = {frameWidth, frameWidth}, .frameSize = {frameWidth, frameWidth},
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth}, .sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
.destRec = {GetScreenWidth()/2, 0.0f, frameWidth, frameWidth}, .destRec = {GetScreenWidth() / 2, 0.0f, frameWidth, frameWidth},
.origin = {frameWidth / 2, frameWidth / 2}, .origin = {frameWidth / 2, frameWidth / 2},
.rotation = rotation, .rotation = rotation,
.color = WHITE .color = WHITE};
};
Physics islandPhysics = { Physics islandPhysics = {.position = (Vector2){-100.0f, 0.0f},
.position = (Vector2){-100.0f, 0.0f},
.direction = (Vector2){0.0f, 0.0f}, .direction = (Vector2){0.0f, 0.0f},
.speed = 10.0f .speed = 10.0f};
};
return (Islands){
.sprite = islandSprite,
.physics = islandPhysics
};
return (Islands){.sprite = islandSprite, .physics = islandPhysics};
} }
void UpdateIslands(Islands *islands){ void UpdateIslands(Islands *islands) {
UpdatePhysics(&islands->physics, (Vector2){0.0f,0.0f}); UpdatePhysics(&islands->physics, (Vector2){0.0f, 0.0f});
UpdateSpriteDestRec(&islands->sprite, &islands->physics.position); UpdateSpriteDestRec(&islands->sprite, &islands->physics.position);
UpdateAnimation(&islands->animation, GetFrameTime()); UpdateAnimation(&islands->animation, GetFrameTime());
UpdateSpriteSourceRec(&islands->sprite, &(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame, islands->sprite.frameSize.y}); UpdateSpriteSourceRec(
} &islands->sprite,
&(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame,
void RenderIslands(Islands *islands){ islands->sprite.frameSize.y});
RenderSprite(&islands->sprite);
} }
void RenderIslands(Islands *islands) { RenderSprite(&islands->sprite); }
+7
View File
@@ -0,0 +1,7 @@
#include "app.h"
Projectiles CreateProjectiles(void) {}
void UpdateProjectiles(Projectiles *projectiles) {}
void RenderProjectiles(Projectiles *projectiles) {}
+7
View File
@@ -0,0 +1,7 @@
#include "app.h"
Ship InitShip(int shipID) {
Config config;
InitConfig(&config, "config/ships.ini");
Ship ship;
}
-3
View File
@@ -1,3 +0,0 @@
#include "app.h"