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
EXTERNAL_ENGINE = -Iexternal/engine
EXTERNAL_RAYGUI = -Iexternal/raygui
EXTERNAL_RINI = -Iexternal/rini
EXTERNAL_FLAGS = \
$(EXTERNAL_ENGINE) \
$(EXTERNAL_RINI) \
$(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
+39 -91
View File
@@ -2,16 +2,15 @@
#define APPTYPES_H
// INCLUDES//
#include <raylib.h>
#include <engine.h>
#include <raylib.h>
// DEFINES//
#define TEXT_COLOR_DARK (Color){182, 137, 98, 255}
#define TEXT_COLOR_LIGHT (Color){243, 229, 194, 255}
// ENUMS//
typedef enum
{
typedef enum {
MENU_CURSOR_TEX,
MENU_BIG_BUTTONS_TEX,
MENU_BOARD_TEX,
@@ -21,61 +20,23 @@ typedef enum
MENU_TEX_COUNT
} MenuTextureID;
typedef enum
{
MENU_MUSIC,
MENU_SOUNDTRACK_COUNT
} MenuSoundtrackID;
typedef enum { MENU_MUSIC, MENU_SOUNDTRACK_COUNT } MenuSoundtrackID;
typedef enum
{
HOVER_SOUND,
CLICK_SOUND,
MENU_SOUND_COUNT
} MenuSoundID;
typedef enum { HOVER_SOUND, CLICK_SOUND, MENU_SOUND_COUNT } MenuSoundID;
typedef enum MenuView {
MAIN = 0,
SETTINGS = 1
} MenuView;
typedef enum MenuView { MAIN = 0, SETTINGS = 1 } MenuView;
typedef enum
{
START_SHIP,
PLAYER_TEX_COUNT
} playerTextureID;
typedef enum { START_SHIP, PLAYER_TEX_COUNT } playerTextureID;
typedef enum {
ANCHOR,
SLOW_AHEAD,
FAST_AHEAD,
SPEED_COUNT
} playerSpeedID;
typedef enum { ANCHOR, SLOW_AHEAD, FAST_AHEAD, SPEED_COUNT } playerSpeedID;
typedef enum { ISLAND, ISLANDS_TEX_COUNT } islandsTextureID;
typedef enum
{
ISLAND,
ISLANDS_TEX_COUNT
} islandsTextureID;
typedef enum { POST_FX, SHADER_COUNT } ShaderID;
typedef enum
{
POST_FX,
SHADER_COUNT
} ShaderID;
typedef enum { BEE_AMBIENT, SOUNDTRACK_COUNT } SoundtrackID;
typedef enum
{
BEE_AMBIENT,
SOUNDTRACK_COUNT
} SoundtrackID;
typedef enum View {
LOGO = 0,
MENU = 1,
GAMEPLAY = 2
} View;
typedef enum View { LOGO = 0, MENU = 1, GAMEPLAY = 2 } View;
// STRUCTS//
typedef struct {
@@ -115,52 +76,37 @@ typedef struct {
Background foreground;
} MenuMain;
typedef struct
{
typedef struct {
Button showFPS;
Button limitFPS;
Button soundtrackOn;
} MenuSettings;
typedef struct
{
typedef struct {
MenuView menuView;
MenuMain menuMain;
MenuSettings menuSettings;
} MenuState;
typedef struct
{
typedef struct {
Sprite sprite;
Rectangle bounds;
Shader shader;
float time;
} Floor;
typedef struct
{
typedef struct {
Sprite sprite;
Animation animation;
Physics physics;
float rotation;
} Player;
typedef enum
{
BOAT,
ENEMIES_TEX_COUNT
} enemiesTextureID;
typedef enum { BOAT, ENEMIES_TEX_COUNT } enemiesTextureID;
typedef enum
{
START,
SHIP_COUNT
} shipID;
typedef enum { START, SHIP_COUNT } shipID;
typedef struct
{
typedef struct {
int id;
char *assetPath;
int frameSize;
@@ -172,8 +118,7 @@ typedef struct
#define MAX_ENEMIES 100
typedef struct
{
typedef struct {
Config config;
int count;
Sprite sprite[MAX_ENEMIES];
@@ -183,11 +128,7 @@ typedef struct
Vector2 destPos[MAX_ENEMIES];
} Enemies;
typedef enum
{
FLYING,
BIRDS_TEX_COUNT
} birdsTextureID;
typedef enum { FLYING, BIRDS_TEX_COUNT } birdsTextureID;
#define MAX_BIRDS 100
@@ -206,8 +147,14 @@ typedef struct {
Physics physics;
} 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;
PostProcessing postFX[SHADER_COUNT];
Soundtrack soundtracks[SOUNDTRACK_COUNT];
@@ -218,6 +165,7 @@ typedef struct
Islands islands;
Mouse mouse;
Image image;
Projectiles projectiles;
} GameState;
typedef struct {
@@ -243,29 +191,25 @@ typedef struct {
GameState game;
} App;
#define MAX_PROJECTILES 10
typedef struct {
Physics physics[MAX_PROJECTILES];
bool active[MAX_PROJECTILES];
float radius[MAX_PROJECTILES];
} Projectile;
// FUNCTIONS//
void InitLogo(LogoState *l);
void UpdateLogo(LogoState *l, View *currentView, bool *running);
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 RenderBackground(Background *bg);
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 CleanupMenuMain(MenuMain *m);
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 CleanupMenuSettings(MenuSettings *s);
@@ -297,6 +241,10 @@ Islands CreateIslands(void);
void UpdateIslands(Islands *islands);
void RenderIslands(Islands *islands);
Projectiles CreateProjectiles(void);
void UpdateProjectiles(Projectiles *projectiles);
void RenderProjectiles(Projectiles *projectiles);
void InitGame(App *app);
void UpdateGame(App *app);
void RenderComponents(App *app);
+7 -12
View File
@@ -23,26 +23,22 @@ void UpdateApp(App *app){
app->state.running = true;
app->state.gameStarted = false;
while (app->state.running)
{
switch (app->state.currentView)
{
case LOGO:
{
while (app->state.running) {
switch (app->state.currentView) {
case LOGO: {
UpdateLogo(&app->logo, &app->state.currentView, &app->state.running);
RenderLogo(&app->logo, &app->flags);
} break;
case MENU:
{
case MENU: {
UpdateMenu(&app->menu, &app->state, &app->flags);
RenderMenu(&app->menu, &app->font, app->window.title, &app->flags);
} break;
case GAMEPLAY:
{
case GAMEPLAY: {
UpdateGame(app);
RenderGame(app);
} break;
default: break;
default:
break;
}
}
}
@@ -53,4 +49,3 @@ void CleanupApp(App *app){
CleanupFont(&app->font);
CleanUpConfig(&app->config);
}
+23 -48
View File
@@ -1,35 +1,24 @@
#include "app.h"
const ShaderAsset shaderAssets[SHADER_COUNT] = {
{"shaders/postfx.fs"}
};
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
{"assets/sea.mp3"}
};
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {{"assets/sea.mp3"}};
void InitGame(App *app)
{
void InitGame(App *app) {
SetRandomSeed(1234);
GameState *g = &app->game;
g->assets = (Assets){
.shaderAssets = shaderAssets,
.soundtrackAssets = soundtrackAssets
};
g->assets = (Assets){.shaderAssets = shaderAssets,
.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);
}
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->target = LoadRenderTexture(app->window.width, app->window.height);
CreatePlayer();
@@ -39,21 +28,19 @@ void InitGame(App *app)
g->enemies = CreateEnemies();
g->islands = CreateIslands();
g->floor = CreateFloor();
g->projectiles = CreateProjectiles();
Texture2D mouseTexture = LoadTexture("assets/mouse.png");
g->mouse = CreateMouse(0.10f, 5.0f, 10.0f, &mouseTexture);
}
void StartGame(App *app)
{
void StartGame(App *app) {
if (!app->state.gameStarted) {
app->state.gameStarted = true;
}
}
void UpdateGame(App *app)
{
void UpdateGame(App *app) {
GameState *g = &app->game;
if (app->flags.limitFPS) {
SetTargetFPS(60);
@@ -66,12 +53,10 @@ void UpdateGame(App *app)
OnEscapeChangeView(app, MENU);
OnWindowClosedStoppApp(app);
for (int i = 0; i < SHADER_COUNT; i++)
{
for (int i = 0; i < SHADER_COUNT; 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);
}
@@ -85,8 +70,7 @@ void UpdateGame(App *app)
UpdateIslands(&g->islands);
}
void RenderComponents(App *app)
{
void RenderComponents(App *app) {
GameState *g = &app->game;
RenderFloor(&g->floor);
RenderPlayer();
@@ -95,8 +79,7 @@ void RenderComponents(App *app)
RenderIslands(&g->islands);
}
void RenderGame(App *app)
{
void RenderGame(App *app) {
GameState *g = &app->game;
BeginTextureMode(g->target);
@@ -105,41 +88,33 @@ void RenderGame(App *app)
BeginMode2D(*camera);
RenderComponents(app);
EndMode2D();
DrawTextureRec
(
DrawTextureRec(
g->mouse.cursorTexture,
(Rectangle){0, 0, g->mouse.cursorTexture.width, g->mouse.cursorTexture.height},
(Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y},
WHITE
);
(Rectangle){0, 0, g->mouse.cursorTexture.width,
g->mouse.cursorTexture.height},
(Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, WHITE);
EndTextureMode();
BeginDrawing();
ClearBackground(BLACK);
for (int i = 0; i < SHADER_COUNT; i++)
{
for (int i = 0; i < SHADER_COUNT; i++) {
RenderPostFX(&g->postFX[i], &g->target);
}
if (app->flags.showFPS)
{
if (app->flags.showFPS) {
DrawFPS(10, 10);
}
EndDrawing();
}
void CleanupGame(App *app)
{
void CleanupGame(App *app) {
GameState *g = &app->game;
for (int i = 0; i < SHADER_COUNT; i++)
{
for (int i = 0; i < SHADER_COUNT; 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);
}
UnloadRenderTexture(g->target);
}
+10 -18
View File
@@ -1,8 +1,7 @@
#include "app.h"
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) {
TextureAsset islandAsset = islandsTextureAssets[ISLAND];
@@ -17,20 +16,13 @@ Islands CreateIslands(void){
.destRec = {GetScreenWidth() / 2, 0.0f, frameWidth, frameWidth},
.origin = {frameWidth / 2, frameWidth / 2},
.rotation = rotation,
.color = WHITE
};
.color = WHITE};
Physics islandPhysics = {
.position = (Vector2){-100.0f, 0.0f},
Physics islandPhysics = {.position = (Vector2){-100.0f, 0.0f},
.direction = (Vector2){0.0f, 0.0f},
.speed = 10.0f
};
return (Islands){
.sprite = islandSprite,
.physics = islandPhysics
};
.speed = 10.0f};
return (Islands){.sprite = islandSprite, .physics = islandPhysics};
}
void UpdateIslands(Islands *islands) {
@@ -38,10 +30,10 @@ void UpdateIslands(Islands *islands){
UpdatePhysics(&islands->physics, (Vector2){0.0f, 0.0f});
UpdateSpriteDestRec(&islands->sprite, &islands->physics.position);
UpdateAnimation(&islands->animation, GetFrameTime());
UpdateSpriteSourceRec(&islands->sprite, &(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame, islands->sprite.frameSize.y});
}
void RenderIslands(Islands *islands){
RenderSprite(&islands->sprite);
UpdateSpriteSourceRec(
&islands->sprite,
&(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame,
islands->sprite.frameSize.y});
}
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"