Refactoring structs Part 1

This commit is contained in:
2021-05-20 22:20:52 -07:00
parent c19f7c1083
commit 5ae1f1c0d4
56 changed files with 484 additions and 422 deletions

View File

@ -7,6 +7,10 @@
#include "libs.h"
// Display / Rendering
#include "display/debug/grid.h"
#include "display/gui/font.h"
#include "display/camera.h"
#include "display/framebuffer.h"
#include "display/primitive.h"
@ -16,26 +20,26 @@
#include "display/texture.h"
#include "display/tileset.h"
#include "display/debug/grid.h"
#include "display/debug/position.h"
// Game Engine
#include "engine/engine.h"
#include "display/gui/font.h"
// Time Management
#include "epoch/epoch.h"
// File / Asset Management
#include "file/asset.h"
// Game Logic / Game Time Management
// Game Logic
#include "game/game.h"
#include "game/gametime.h"
// Player Input
#include "input/input.h"
// Poker Game Logic
#include "poker/action.h"
#include "poker/card.h"
#include "poker/chip.h"
#include "poker/player.h"
#include "poker/poker.h"
#include "poker/render.h"
// Utility Objects

View File

@ -1,27 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../../libs.h"
#include "../primitive.h"
#include "../texture.h"
#include "../tileset.h"
#define POSITION_DEBUG_FONT_CHARS_MAX 256
/** Struct representing a positionable object in space */
typedef struct {
primitive_t *primitive;
spritebatch_t *textBatch;
texture_t *textTexture;
tileset_t *textTileset;
float x, y, z;
float pitch, yaw, roll;
float scaleX, scaleY, scaleZ;
} positiondebug_t;

View File

@ -12,5 +12,5 @@
typedef struct {
GLuint fboId;
GLuint rboId;
texture_t *texture;
texture_t texture;
} framebuffer_t;

View File

@ -13,7 +13,4 @@
typedef struct {
/** Resolution (in pixels) */
int32_t width, height;
} render_t;
/** Current render state */
extern render_t RENDER_STATE;
} render_t;

View File

@ -17,5 +17,5 @@ typedef struct {
int32_t currentSprite;
/** Internal primitive */
primitive_t *primitive;
primitive_t primitive;
} spritebatch_t;

View File

@ -0,0 +1,22 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../display/render.h"
#include "../input/input.h"
#include "../epoch/epoch.h"
typedef struct {
/** Time Manager for the game */
epoch_t time;
/** Render Manager for the game */
render_t render;
/** Input Manager for the game */
input_t input;
} engine_t;

View File

@ -7,9 +7,8 @@
#pragma once
#define GAMETIME_FIXED_STEP 0.016
#define GAMETIME_SMALLEST_STEP 0.001
#define EPOCH_FIXED_STEP 0.016
#define EPOCH_SMALLEST_STEP 0.001
typedef struct {
/**
@ -39,6 +38,4 @@ typedef struct {
* Fixed timestep that is not affected by framerate but remains consistent.
*/
float fixedDelta;
} gametime_t;
extern gametime_t TIME_STATE;
} epoch_t;

View File

@ -5,72 +5,22 @@
#pragma once
#include "../libs.h"
#include "../display/shader.h"
#include "../display/camera.h"
#include "../poker/card.h"
#include "../poker/player.h"
#include "../poker/render.h"
#include "../poker/action.h"
#include "../display/render.h"
#include "../display/spritebatch.h"
#include "../display/texture.h"
#include "../display/tileset.h"
#include "../display/framebuffer.h"
#include "../engine/engine.h"
#include "../poker/poker.h"
/** Name of the current game */
#define GAME_NAME "Dawn"
/** Describes the current game */
typedef struct {
char *name;
/** Current Card Deck */
card_t deck[CARD_DECK_SIZE];
uint8_t deckSize;
/** Dealer Money */
uint32_t blindSmall;
uint32_t blindBig;
uint32_t pot;
/** Engine for the game */
engine_t engine;
/** Dealer Hand */
card_t cards[HOLDEM_DEALER_HAND];
uint8_t cardsFacing;
/** Player States */
pokerplayer_t players[POKER_PLAYER_COUNT];
/** Action Queue */
pokeraction_t actionQueue[POKER_ACTION_QUEUE_SIZE];
void *actionData[POKER_ACTION_DATA_SIZE*POKER_ACTION_QUEUE_SIZE];
bool actionInitState[POKER_ACTION_DATA_SIZE];
/** Rendering Assets */
texture_t *kagamiTexture;
tileset_t *kagamiTileset;
primitive_t *kagamiQuad;
primitive_t *chipPrimitive;
texture_t *chipTexture;
primitive_t *tablePrimitive;
texture_t *tableTexture;
texture_t *cardTexture;
tileset_t *cardTileset;
primitive_t *cardPrimitive;
texture_t *fontTexture;
tileset_t *fontTileset;
spritebatch_t *fontBatch;
shader_t *shaderWorld;
framebuffer_t *frameLeft;
framebuffer_t *frameRight;
primitive_t *quadLeft;
primitive_t *quadRight;
camera_t cameraMain;
camera_t cameraLeft;
camera_t cameraRight;
/** Poker Game State */
poker_t poker;
} game_t;
/** The current running game state. */

View File

@ -7,7 +7,6 @@
#include "../libs.h"
#include "../util/list.h"
/** Debug Inputs */
#define INPUT_NULL (inputbind_t)0x00
#define INPUT_DEBUG_UP (inputbind_t)0x01
@ -75,7 +74,4 @@ typedef struct {
/** Float of the GameTime that the input was actuated last. */
float times[INPUT_BIND_COUNT];
} input_t;
/** The current input state */
extern input_t INPUT_STATE;
} input_t;

View File

@ -1,25 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
/** How many actions the queue can hold */
#define POKER_ACTION_QUEUE_SIZE 12
/** How much data (in length of sizeof size_t) each action has available */
#define POKER_ACTION_DATA_SIZE 256
/** Callback for actions to use */
typedef void (*pokerActionCallback)(int32_t index, void *data);
/** Poker Game action that can be queued and executed */
typedef struct {
pokerActionCallback init;
pokerActionCallback update;
pokerActionCallback dispose;
} pokeraction_t;

View File

@ -7,9 +7,7 @@
#pragma once
#include "../libs.h"
/** How many cards the dealer can hold in their hand */
#define HOLDEM_DEALER_HAND 5
#include "card.h"
/** How many cards a player can hold in their hand */
#define POKER_PLAYER_HAND 2

View File

@ -0,0 +1,84 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../libs.h"
#include "player.h"
#include "card.h"
#include "../display/tileset.h"
#include "../display/primitive.h"
#include "../display/texture.h"
#include "../display/shader.h"
#include "../display/camera.h"
#include "../display/spritebatch.h"
/** Rounds that the game can be in */
#define POKER_ROUND_DEAL 0x00
#define POKER_ROUND_BLINDS 0x01
#define POKER_ROUND_BET0 0x02
#define POKER_ROUND_FLOP 0X03
#define POKER_ROUND_BET1 0x04
#define POKER_ROUND_TURN 0x05
#define POKER_ROUND_BET2 0x06
#define POKER_ROUND_RIVER 0x07
#define POKER_ROUND_BET3 0x08
#define POKER_ROUND_WINNER 0x09
/** How many cards the dealer can hold in their hand */
#define POKER_DEALER_HAND 5
typedef struct {
/** Current Card Deck */
card_t deck[CARD_DECK_SIZE];
uint8_t deckSize;
/** Dealer Money */
uint32_t blindSmall;
uint32_t blindBig;
/** Dealer Hand */
card_t cards[POKER_DEALER_HAND];
uint8_t cardsFacing;
/** Player States */
pokerplayer_t players[POKER_PLAYER_COUNT];
/** Game State */
uint8_t round;
uint8_t roundPlayer;
uint8_t roundDealer;
uint32_t pot;
uint32_t roundBet;
/** Rendering Assets */
texture_t *kagamiTexture;
tileset_t *kagamiTileset;
primitive_t *kagamiQuad;
primitive_t *chipPrimitive;
texture_t *chipTexture;
primitive_t *tablePrimitive;
texture_t *tableTexture;
texture_t *cardTexture;
tileset_t *cardTileset;
primitive_t *cardPrimitive;
texture_t *fontTexture;
tileset_t *fontTileset;
spritebatch_t *fontBatch;
shader_t *shaderWorld;
framebuffer_t *frameLeft;
framebuffer_t *frameRight;
primitive_t *quadLeft;
primitive_t *quadRight;
camera_t cameraMain;
camera_t cameraLeft;
camera_t cameraRight;
} poker_t;