Begin refactor.

This commit is contained in:
2021-09-18 23:13:05 -07:00
parent 98daedced9
commit 6904a46bec
143 changed files with 1706 additions and 2345 deletions

View File

@ -6,7 +6,12 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../libs.h"
#include "../game.h"
typedef struct {
int32_t INeedSomePropertyToStopCompilerComplaining;
} dawngame_t;
/**
* Initializes the Dawn Game instance.

View File

@ -4,7 +4,7 @@
// https://opensource.org/licenses/MIT
#pragma once
#include <dawn/dawn.h>
#include "../libs.h"
#include "../engine/engine.h"
#include "../locale/language.h"
@ -16,6 +16,20 @@
#include "sandbox/sandboxscene.h"
#endif
/** Describes the current game */
typedef struct {
/** Engine for the game */
engine_t engine;
#if SETTING_GAME == SETTING_GAME_POKER
pokergame_t pokerGame;
#elif SETTING_GAME == SETTING_GAME_DAWN
dawngame_t dawnGame;
#elif SETTING_GAME == SETTING_GAME_SANDBOX
sandboxscene_t sandboxScene;
#endif
} game_t;
/**
* Initialize the game context.
*

View File

@ -6,8 +6,9 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "../../../display/animation/queue.h"
#include "../pokergame.h"
/**
* Adds an action to the poker game scene's queue.

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "action.h"
#include "restack.h"
#include "../../../poker/turn.h"

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "action.h"
#include "../../../display/animation/queue.h"
#include "../pokerworld.h"

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "action.h"
#include "../../../display/animation/queue.h"
#include "../pokergame.h"

View File

@ -4,7 +4,7 @@
// https://opensource.org/licenses/MIT
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "action.h"
#include "../../../poker/bet.h"
#include "../../../poker/actions/round.h"

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "../../../vn/conversation/talk.h"
#include "../../../display/animation/queue.h"
#include "../../../poker/actions/match.h"

View File

@ -1,26 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../vn/conversation/vnconversation.h"
#include "../../../vn/conversation/talk.h"
#include "../actions/look.h"
/**
* Retreives the discussion based on some discussion data.
* @param disc The discussion data to buffer into.
* @param data The discussion data.
*/
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);
/**
* Queue a discussion data result onto the conversation stack.
*
* @param data The discussion data.
*/
void pokerDiscussionQueue(pokerdiscussiondata_t *data);

View File

@ -0,0 +1,55 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "../../libs.h"
#include "../../vn/conversation/vnconversation.h"
#include "../../vn/conversation/talk.h"
#include "actions/look.h"
/** Maximum number of messages that the discussion buffer can hold */
#define POKER_DISCUSSION_MESSAGE_COUNT_MAX 32
/** Why the discussion is happening */
#define POKER_DISCUSSION_REASON_TEST 0x00
#define POKER_DISCUSSION_REASON_MATCH_START 0x01
#define POKER_DISCUSSION_REASON_ROUND_START 0x02
#define POKER_DISCUSSION_REASON_BLINDS_TAKEN 0x03
#define POKER_DISCUSSION_REASON_PLAYER_FOLDING 0x04
#define POKER_DISCUSSION_REASON_PLAYER_CHECKING 0x05
#define POKER_DISCUSSION_REASON_PLAYER_CALLING 0x06
#define POKER_DISCUSSION_REASON_PLAYER_RAISING 0x07
#define POKER_DISCUSSION_REASON_FLOP 0x08
#define POKER_DISCUSSION_REASON_DEAL 0x09
typedef struct {
pokergame_t *poker;
uint8_t reason;
uint8_t playerCause;
uint8_t playerTarget;
} pokerdiscussiondata_t;
typedef struct {
char *messages[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
uint8_t players[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
uint8_t emotions[POKER_DISCUSSION_MESSAGE_COUNT_MAX];
uint8_t count;
} pokerdiscussion_t;
/**
* Retreives the discussion based on some discussion data.
* @param disc The discussion data to buffer into.
* @param data The discussion data.
*/
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);
/**
* Queue a discussion data result onto the conversation stack.
*
* @param data The discussion data.
*/
void pokerDiscussionQueue(pokerdiscussiondata_t *data);

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../libs.h"
#include "pokergameassets.h"
#include "../../poker/poker.h"
#include "../../vn/conversation/talk.h"
@ -17,6 +17,51 @@
#include "pokerworld.h"
#include "actions/start.h"
#define POKER_GAME_SEAT_COUNT 8
#define POKER_GAME_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
#define POKER_GAME_SEAT_DEALER POKER_GAME_SEAT_FOR_PLAYER(POKER_DEALER_INDEX)
/**
* Return the seat for a given player index, also works for the dealer index.
* @param i The players index.
* @return The players seat number.
*/
#define pokerGameSeatFromIndex(i) (\
i == POKER_DEALER_INDEX ? \
POKER_GAME_SEAT_DEALER : \
POKER_GAME_SEAT_FOR_PLAYER(i) \
)
#define POKER_GAME_PENNY_BASE_WIDTH 1000
#define POKER_GAME_PENNY_BASE_HEIGHT 1920
#define POKER_GAME_PENNY_FACE_X 367
#define POKER_GAME_PENNY_FACE_Y 256
#define POKER_GAME_PENNY_FACE_WIDTH 280
#define POKER_GAME_PENNY_FACE_HEIGHT 280
typedef struct {
/** Poker Game State */
poker_t poker;
/** Visual Novel Engine */
vnscene_t scene;
/** Assets (Files) for the game. */
pokergameassets_t assets;
/** Poker Game World. */
pokerworld_t world;
/** UI For the Game */
pokerui_t ui;
/** Data for the actions */
pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX];
/** Pointer back to the game engine */
engine_t *engine;
} pokergame_t;
/**
* Initializes the game state for the poker game.
*

View File

@ -0,0 +1,13 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <dawn/dawn.h>
typedef struct {
uint8_t lookAtPlayer;
} pokergameactiondata_t;

View File

@ -6,11 +6,23 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../libs.h"
#include "../../file/asset.h"
#include "../../locale/language.h"
#include "../../display/texture.h"
typedef struct {
font_t font;
shader_t shader;
language_t language;
texture_t testTexture;
texture_t roomTexture;
texture_t cardTexture;
texture_t pennyTexture;
} pokergameassets_t;
/**
* Load and initializes all the assets used by the poker game.
*

View File

@ -6,13 +6,28 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../libs.h"
#include "../../display/shader.h"
#include "../../display/primitive.h"
#include "../../display/primitives/skywall.h"
#include "../../vn/vnscene.h"
#include "../../vn/vncharacter.h"
#define POKER_WORLD_SEAT_DISTANCE -1
#define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f))
#define POKER_WORLD_SEAT_POSITION_X(n) ( \
POKER_WORLD_SEAT_DISTANCE * (float)sin(POKER_WORLD_SEAT_ROTATION(n)) \
)
#define POKER_WORLD_SEAT_POSITION_Y -0.2f
#define POKER_WORLD_SEAT_POSITION_Z(n) ( \
POKER_WORLD_SEAT_DISTANCE * (float)cos(POKER_WORLD_SEAT_ROTATION(n)) \
)
typedef struct {
primitive_t skywall;
} pokerworld_t;
/**
* Initialize the poker renderer.
*

View File

@ -6,9 +6,8 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "../../../ui/image.h"
#include "../../../poker/card.h"
void pokerCardSetImage(image_t *image, texture_t *texture, card_t card);

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "../../../ui/label.h"
#include "../../../ui/image.h"
#include "../../../display/framebuffer.h"
@ -15,10 +15,27 @@
#include "../../../display/primitives/cube.h"
#include "../../../display/camera.h"
#include "../../../vn/vncharacter.h"
#include "../../../ui/grid.h"
#include "../../../ui/align.h"
#define POKER_PLAYER_UI_IMAGE_SIZE 64
#define POKER_PLAYER_UI_WIDTH 300
#define POKER_PLAYER_UI_HEIGHT POKER_PLAYER_UI_IMAGE_SIZE
#define POKER_PLAYER_UI_IMAGE_RESOLUTION POKER_PLAYER_UI_IMAGE_SIZE * 2
#define POKER_PLAYER_UI_IMAGE_DIST 0.8f
#define POKER_PLAYER_UI_IMAGE_Y 0.1f
#define POKER_PLAYER_UI_PADDING 8
#define POKER_PLAYER_UI_CHIPS_ANIMATION_SPEED 0.5f
typedef struct {
framebuffer_t frame;
primitive_t quad;
label_t label;
grid_t grid;
} pokerplayerui_t;
void pokerPlayerUiInit(pokerplayerui_t *ui);
void pokerPlayerUiUpdate(

View File

@ -6,11 +6,16 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../../libs.h"
#include "../../../ui/label.h"
#include "pokerplayerui.h"
#include "pokercardui.h"
typedef struct {
pokerplayerui_t player[POKER_PLAYER_COUNT];
image_t card;
} pokerui_t;
/**
* Initializes the UI Module.
*

View File

@ -16,10 +16,6 @@ bool sandboxSceneInit(sandboxscene_t *game, engine_t *engine) {
"shaders/textured.vert", "shaders/textured.frag"
);
scripterInit(&scripter, engine);
assetScripterAppend(&scripter, "scripts/main.js");
scripterInvokeMethodSimple(&scripter, "init");
return true;
}
@ -48,5 +44,4 @@ void sandboxSceneUpdate(sandboxscene_t *game, engine_t *engine) {
}
void sandboxSceneDispose(sandboxscene_t *game) {
scripterDispose(&scripter);
}

View File

@ -6,7 +6,7 @@
*/
#pragma once
#include <dawn/dawn.h>
#include "../../libs.h"
#include "../../display/camera.h"
#include "../../display/shader.h"
#include "../../display/font.h"
@ -26,6 +26,15 @@
#include "../../ui/image.h"
#include "../../ui/framedtextmenu.h"
typedef struct {
camera_t camera;
primitive_t primitive;
texture_t texture;
shader_t shader;
font_t font;
} sandboxscene_t;
/**
* Initialize the sandbox scene test game.
*