From 84e4fc0c0083f928d78f76b7dbabbf84509353d7 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 19 Sep 2021 22:02:14 -0700 Subject: [PATCH] Even more refactoring. --- src/display/render.c | 6 +- src/display/render.h | 9 +- src/display/renderlist.c | 5 +- src/display/renderlist.h | 1 + src/game/game.c | 34 +---- src/game/game.h | 6 +- src/game/poker/actions/round.h | 2 +- src/game/poker/actions/start.h | 2 + src/game/poker/{pokergame.c => game.c} | 10 +- src/game/poker/game.h | 45 ++++++ src/game/poker/pokergame.h | 55 +------ src/game/poker/pokerui.c | 200 +++++++++++++++++++++++++ src/game/poker/pokerui.h | 87 +++++++++++ src/game/poker/pokerworld.c | 20 ++- src/game/poker/pokerworld.h | 40 ++++- src/game/poker/ui/pokercardui.c | 23 --- src/game/poker/ui/pokercardui.h | 13 -- src/game/poker/ui/pokerplayerui.c | 133 ---------------- src/game/poker/ui/pokerplayerui.h | 55 ------- src/game/poker/ui/pokerui.c | 89 ----------- src/game/poker/ui/pokerui.h | 48 ------ src/poker/actions/blinds.c | 7 +- src/poker/actions/blinds.h | 3 +- src/poker/actions/deal.c | 2 +- src/poker/actions/deal.h | 1 + src/poker/actions/flop.h | 2 + src/poker/actions/match.h | 1 + src/poker/actions/round.h | 2 +- src/poker/bet.c | 7 +- src/poker/bet.h | 3 +- src/script/scripter.c | 3 - src/script/scripter.h | 1 - src/vn/conversation/talk.c | 2 +- src/vn/conversation/talk.h | 1 + src/vn/conversation/vnconversation.c | 2 +- src/vn/conversation/vnconversation.h | 2 + 36 files changed, 436 insertions(+), 486 deletions(-) rename src/game/poker/{pokergame.c => game.c} (88%) create mode 100644 src/game/poker/game.h create mode 100644 src/game/poker/pokerui.c create mode 100644 src/game/poker/pokerui.h delete mode 100644 src/game/poker/ui/pokercardui.c delete mode 100644 src/game/poker/ui/pokercardui.h delete mode 100644 src/game/poker/ui/pokerplayerui.c delete mode 100644 src/game/poker/ui/pokerplayerui.h delete mode 100644 src/game/poker/ui/pokerui.c delete mode 100644 src/game/poker/ui/pokerui.h diff --git a/src/display/render.c b/src/display/render.c index 8801c3aa..78940637 100644 --- a/src/display/render.c +++ b/src/display/render.c @@ -24,7 +24,7 @@ void renderInit() { void renderFrameStart(render_t *render) { // Clear the frame buffer. - frameBufferUnbind(render->width, render->height, true); + renderResetFramebuffer(render); } void renderDispose() { @@ -34,4 +34,8 @@ void renderDispose() { void renderSetResolution(render_t *render, float width, float height) { render->width = width; render->height = height; +} + +void renderResetFramebuffer(render_t *render) { + frameBufferUnbind(render->width, render->height, true); } \ No newline at end of file diff --git a/src/display/render.h b/src/display/render.h index 29731f3f..f2269609 100644 --- a/src/display/render.h +++ b/src/display/render.h @@ -40,4 +40,11 @@ void renderDispose(); * @param width Width of the display (in pixels). * @param height Height of the display (in pixels). */ -void renderSetResolution(render_t *render, float width, float height); \ No newline at end of file +void renderSetResolution(render_t *render, float width, float height); + +/** + * Reset the framebuffer back to the original backbuffer. + * + * @param render Render to reset the backbuffer to. + */ +void renderResetFramebuffer(render_t *render); \ No newline at end of file diff --git a/src/display/renderlist.c b/src/display/renderlist.c index 555d5b07..91417bef 100644 --- a/src/display/renderlist.c +++ b/src/display/renderlist.c @@ -51,7 +51,7 @@ void renderListRenderPass( item->onRender(list, renderPass, engine, i); } - frameBufferUnbind(engine->render.width, engine->render.height, false); + renderResetFramebuffer(&engine->render); } void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) { @@ -78,6 +78,5 @@ void renderListRender(renderlist_t *list, engine_t *engine, shader_t *shader) { primitiveDraw(&list->quad, 0, -1); } - // Unbind the framebuffer. - frameBufferUnbind(engine->render.width, engine->render.height, false); + renderResetFramebuffer(&engine->render); } \ No newline at end of file diff --git a/src/display/renderlist.h b/src/display/renderlist.h index 14050030..27e10002 100644 --- a/src/display/renderlist.h +++ b/src/display/renderlist.h @@ -14,6 +14,7 @@ #include "../engine/engine.h" #include "primitives/quad.h" #include "../util/dynarray.h" +#include "render.h" typedef struct { framebuffer_t frame; diff --git a/src/game/game.c b/src/game/game.c index 0e22998b..474faeb0 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -9,44 +9,26 @@ bool gameInit(game_t *game) { // Init the engine and the rendering pipeline - engineInit(&game->engine, game); + engineInit(&game->engine); // Send off to the game instance - #if SETTING_GAME == SETTING_GAME_POKER - return pokerGameInit(&game->pokerGame, &game->engine); - #elif SETTING_GAME == SETTING_GAME_DAWN - return dawnGameInit(game); - #elif SETTING_GAME == SETTING_GAME_SANDBOX - return sandboxSceneInit(&game->sandboxScene, &game->engine); - #endif + return gameInstanceInit(game); } bool gameUpdate(game_t *game, float platformDelta) { // Let the engine do its thing. - engineUpdateStart(&game->engine, game, platformDelta); + engineUpdateStart(&game->engine, platformDelta); - // Hand off to the game's logic - #if SETTING_GAME == SETTING_GAME_POKER - pokerGameUpdate(&game->pokerGame, &game->engine); - #elif SETTING_GAME == SETTING_GAME_DAWN - dawnGameUpdate(game); - #elif SETTING_GAME == SETTING_GAME_SANDBOX - sandboxSceneUpdate(&game->sandboxScene, &game->engine); - #endif + // Hand off to the game to update + gameInstanceUpdate(game); // Hand back to the engine. - return engineUpdateEnd(&game->engine, game); + return engineUpdateEnd(&game->engine); } void gameDispose(game_t *game) { // Cleanup the game - #if SETTING_GAME == SETTING_GAME_POKER - pokerGameDispose(&game->pokerGame); - #elif SETTING_GAME == SETTING_GAME_DAWN - dawnGameDispose(game); - #elif SETTING_GAME == SETTING_GAME_SANDBOX - return sandboxSceneDispose(&game->sandboxScene); - #endif + gameInstanceDispose(game); - engineDispose(&game->engine, game); + engineDispose(&game->engine); } \ No newline at end of file diff --git a/src/game/game.h b/src/game/game.h index 50c558f4..b1bfad15 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -10,13 +10,13 @@ /** Describes the current game */ #if SETTING_GAME == SETTING_GAME_POKER - #include "poker/pokergame.h" + #include "poker/game.h" typedef pokergame_t game_t; #elif SETTING_GAME == SETTING_GAME_DAWN - #include "dawn/dawngame.h" + #include "dawn/game.h" typedef dawngame_t game_t; #elif SETTING_GAME == SETTING_GAME_SANDBOX - #include "sandbox/sandboxscene.h" + #include "sandbox/game.h" typedef sandboxscene_t game_t; #endif diff --git a/src/game/poker/actions/round.h b/src/game/poker/actions/round.h index 915b0fde..63e55a44 100644 --- a/src/game/poker/actions/round.h +++ b/src/game/poker/actions/round.h @@ -10,7 +10,7 @@ #include "../../../poker/actions/round.h" #include "../../../poker/actions/blinds.h" #include "../../../poker/actions/deal.h" -#include "../discussion/pokerdiscussion.h" +#include "../pokerdiscussion.h" #include "bet.h" /** Callback that is fired when the round start event starts. */ diff --git a/src/game/poker/actions/start.h b/src/game/poker/actions/start.h index 08ae216b..b018d727 100644 --- a/src/game/poker/actions/start.h +++ b/src/game/poker/actions/start.h @@ -10,6 +10,8 @@ #include "../../../vn/conversation/talk.h" #include "../../../display/animation/queue.h" #include "../../../poker/actions/match.h" +#include "../pokerdiscussion.h" +#include "round.h" #include "action.h" /** Callback fired when the game action first starts */ diff --git a/src/game/poker/pokergame.c b/src/game/poker/game.c similarity index 88% rename from src/game/poker/pokergame.c rename to src/game/poker/game.c index 927d008d..1c1c6831 100644 --- a/src/game/poker/pokergame.c +++ b/src/game/poker/game.c @@ -5,11 +5,9 @@ * https://opensource.org/licenses/MIT */ -#include "pokergame.h" - -bool pokerGameInit(pokergame_t *game, engine_t *engine) { - game->engine = engine; +#include "game.h" +bool gameInstanceInit(pokergame_t *game) { // Load the Assets. pokerGameAssetsInit(&game->assets); @@ -32,7 +30,7 @@ bool pokerGameInit(pokergame_t *game, engine_t *engine) { return true; } -void pokerGameUpdate(pokergame_t *game, engine_t *engine) { +void gameInstanceUpdate(pokergame_t *game, engine_t *engine) { // Update the VN Engine. vnSceneUpdate(&game->scene, engine); @@ -54,7 +52,7 @@ void pokerGameUpdate(pokergame_t *game, engine_t *engine) { pokerUiRender(game, engine); } -void pokerGameDispose(pokergame_t *game) { +void gameInstanceDispose(pokergame_t *game) { //Cleanup the UI pokerUiDispose(game); diff --git a/src/game/poker/game.h b/src/game/poker/game.h new file mode 100644 index 00000000..f2e72908 --- /dev/null +++ b/src/game/poker/game.h @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2021 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "pokergame.h" +#include "../../libs.h" +#include "pokergameassets.h" +#include "../../poker/poker.h" +#include "../../vn/conversation/talk.h" +#include "../../vn/vnscene.h" +#include "../../util/array.h" +#include "pokerui.h" +#include "pokerworld.h" +#include "pokergameaction.h" + +/** + * Initializes the game state for the poker game. + * + * @param game Game to initialize. + * @returns True if successful, otherwise false. + */ +bool gameInstanceInit(pokergame_t *game); + +/** + * Updates the poker game instance. + * @param game Poker game to update for. + */ +void gameInstanceUpdate(pokergame_t *game); + +/** + * Disposes a previously initialized poker game instance. + * @param game Game to dispose. + */ +void gameInstanceDispose(pokergame_t *game); + +/** + * Restacks the poker game's stack. + * + * @param game Poker game to restack + */ +void pokerGameQueueRestack(pokergame_t *game); \ No newline at end of file diff --git a/src/game/poker/pokergame.h b/src/game/poker/pokergame.h index 4b1c6c7e..4dfe8f50 100644 --- a/src/game/poker/pokergame.h +++ b/src/game/poker/pokergame.h @@ -12,32 +12,10 @@ #include "../../vn/conversation/talk.h" #include "../../vn/vnscene.h" #include "../../util/array.h" -#include "ui/pokerui.h" +#include "pokerui.h" #include "pokerworld.h" #include "pokergameaction.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 { /** Game Engine Instance */ engine_t engine; @@ -59,33 +37,4 @@ typedef struct { /** Data for the actions */ pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX]; -} pokergame_t; - -/** - * Initializes the game state for the poker game. - * - * @param game Game to initialize. - * @param engine Engine to use when initializing. - * @returns True if successful, otherwise false. - */ -bool pokerGameInit(pokergame_t *game, engine_t *engine); - -/** - * Updates the poker game instance. - * @param game Poker game to update for. - * @param engine Engine to use during update. - */ -void pokerGameUpdate(pokergame_t *game, engine_t *engine); - -/** - * Disposes a previously initialized poker game instance. - * @param game Game to dispose. - */ -void pokerGameDispose(pokergame_t *game); - -/** - * Restacks the poker game's stack. - * - * @param pokerGame Poker game to restack - */ -void pokerGameQueueRestack(pokergame_t *pokerGame); \ No newline at end of file +} pokergame_t; \ No newline at end of file diff --git a/src/game/poker/pokerui.c b/src/game/poker/pokerui.c new file mode 100644 index 00000000..5d13e02d --- /dev/null +++ b/src/game/poker/pokerui.c @@ -0,0 +1,200 @@ +/** + * Copyright (c) 2021 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#include "pokerui.h" + +void pokerUiInit(pokerui_t *ui) { + uint8_t i; + + // Initialize card render(s) + imageInit(&ui->card); + + // Initialize the player face quad. + quadInit(&ui->quad, 0, + 0, 0, 0, 1, + POKER_UI_PLAYER_IMAGE_SIZE, POKER_UI_PLAYER_IMAGE_SIZE, 1, 0 + ); + + // Initialize the grid + gridInit(&ui->grid); + + ui->grid.gutterX = POKER_UI_PLAYER_PADDING; + ui->grid.columns = 2; + ui->grid.rows = 2; + ui->grid.columnDefinitions[1] = POKER_UI_PLAYER_IMAGE_SIZE; + ui->grid.rowDefinitions[0] = POKER_UI_PLAYER_IMAGE_SIZE / 2.0f; + ui->grid.rowDefinitions[1] = POKER_UI_PLAYER_IMAGE_SIZE / 2.0f; + + gridResize(&ui->grid, POKER_UI_PLAYER_WIDTH, POKER_UI_PLAYER_HEIGHT); + + // Initialize the label + labelInit(&ui->label); + + // Initialize the frames for each player. + for(i = 0; i < POKER_PLAYER_COUNT; i++) { + frameBufferInit(ui->frames + i, + POKER_UI_PLAYER_IMAGE_RESOLUTION, + POKER_UI_PLAYER_IMAGE_RESOLUTION + ); + } +} + +void pokerUiUpdate( + pokerui_t *ui, engine_t *engine, shader_t *shader, + vncharacter_t *characters, pokerplayer_t *players +) { + uint8_t i, j; + camera_t camera; + uint8_t seat; + float x, y, z; + pokerplayer_t *player; + + // Set up the camera perspective + cameraPerspective(&camera, 45, + (float)POKER_UI_PLAYER_IMAGE_SIZE / (float)POKER_UI_PLAYER_IMAGE_SIZE, + 0.03f, 10.0f + ); + + // Render the face of each player. + j = 0; + for(i = 0; i < POKER_PLAYER_COUNT; i++) { + if(i == POKER_PLAYER_HUMAN_INDEX) continue; + player = players + j; + + // Locate the XYZ position of the camera to look at the player + seat = pokerGameSeatFromIndex(i); + x = POKER_WORLD_SEAT_POSITION_X(seat); + y = POKER_UI_PLAYER_IMAGE_Y; + z = POKER_WORLD_SEAT_POSITION_Z(seat); + + cameraLookAt(&camera, + x * POKER_UI_PLAYER_IMAGE_DIST, y, z * POKER_UI_PLAYER_IMAGE_DIST, + x, y, z + ); + + // Bind the frame buffer + frameBufferUse(&ui->frames + j, true); + + // Render the VN character + shaderUse(shader); + shaderUseCamera(shader, &camera); + shaderUsePosition(shader, 0,0,0, 0,0,0); + vnCharacterRender(characters + playerIndex, shader); + + // Increment + j++; + } + + renderResetFramebuffer(&engine->render); +} + +void pokerUiRender(pokerui_t *ui, engine_t *engine, shader_t *shader) { + uint8_t i, j; + pokerplayerui_t *ui; + pokerplayer_t *player; + char message[128]; + float scale; + align_t align; + float gx, gy, gw, gh, x, y; + + // Get the default font scale size. + scale = fontGetScale(FONT_SIZE_DEFAULT); + + // + if(pokerGame->poker.state >= POKER_STATE_DEALING) { + for(j = 0; j < POKER_PLAYER_COUNT; j++) { + player = pokerGame->poker.players + j; + for(i = 0; i < player->cardCount; i++) { + pokerCardSetImage(&pokerGame->ui.card, &pokerGame->assets.cardTexture, player->cards[i]); + imageRender(&pokerGame->ui.card, &pokerGame->assets.shader, i * 64.0f, j * 100); + } + } + } + + player = pokerGame->poker.players + POKER_PLAYER_HUMAN_INDEX; + if(pokerGame->poker.bet.better == POKER_PLAYER_HUMAN_INDEX) { + sprintf(message, "Press down to fold, up to bet, right to check/call."); + labelSetText(&pokerGame->ui.player->label, &pokerGame->assets.font, message); + labelRender(&pokerGame->ui.player->label, &pokerGame->assets.shader, 300, 100); + } + // + j = 0; + for(i = 0; i < POKER_PLAYER_COUNT; i++) { + if(i == POKER_PLAYER_HUMAN_INDEX) continue; + + // Get the player. + player = game->poker.players + i; + + // Position the grid itself. + x = 0; + y = POKER_UI_PLAYER_HEIGHT * j; + + // Render face + gridGetChild(&ui->grid, 1, 0, 1, 2, &gx, &gy, &gw, &gh); + shaderUseTexture(shader, &ui->frames + j); + shaderUsePosition(shader, x + gx, y + gy, 0, 0,0,0); + primitiveDraw(&ui->quad, 0, -1); + + // Render chips + sprintf(buffer, "$%i", player->chips); + ui->label.maxWidth = -1; + labelSetText(&ui->label, font, buffer); + align = gridGetAndAlignChild( + &ui->grid, 0, 0, 1, 1, + ALIGN_POS_END|ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER|ALIGN_SIZE_ORIGINAL, + ui->label.info.width, ui->label.info.height + ); + labelRender(&ui->label, shader, x+align.x, y+align.y); + + // Render state + if(player->state & POKER_PLAYER_STATE_OUT) { + sprintf(buffer, "Out"); + } else if(player->state & POKER_PLAYER_STATE_FOLDED) { + sprintf(buffer, "Folded"); + } else if(player->state & POKER_PLAYER_STATE_SHOWING) { + sprintf(buffer, "Showing"); + } else if(game->poker.bet.better == playerIndex) { + sprintf(buffer, "Thinking"); + } else { + sprintf(buffer, "Whatever"); + } + labelSetText(&ui->label, font, buffer); + align = gridGetAndAlignChild( + &ui->grid, 0, 1, 1, 1, + ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL, + ui->label.info.width, ui->label.info.height + ); + labelRender(&ui->label, shader, x+align.x, y+align.y); + + // Increment. + j++; + } +} + +void pokerUiDispose(pokerui_t *ui) { + uint8_t i; + + for(i = 0; i < POKER_PLAYER_COUNT; i++) frameBufferDispose(ui->frames + i); + labelDispose(&ui->label); + primitiveDispose(&ui->quad); + imageDispose(&ui->card); +} + +void pokerUiSetImageToCard(image_t *image, texture_t *texture, card_t card) { + uint8_t cardImageIndex = ( + cardGetNumber(card) == CARD_ACE ? ( + card - CARD_COUNT_PER_SUIT + 1 + ) : card+0x01 + ); + + imageSetTextureAndCrop( + image, texture, + cardGetNumber(cardImageIndex) * 71, + cardGetSuit(card) * 96, + 71, 96 + ); +} \ No newline at end of file diff --git a/src/game/poker/pokerui.h b/src/game/poker/pokerui.h new file mode 100644 index 00000000..08318c82 --- /dev/null +++ b/src/game/poker/pokerui.h @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2021 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "../../libs.h" +#include "../../ui/label.h" +#include "../../ui/image.h" +#include "../../display/framebuffer.h" +#include "../../display/primitive.h" +#include "../../display/primitives/quad.h" +#include "../../display/primitives/cube.h" +#include "../../display/shader.h" +#include "../../engine/engine.h" +#include "../../display/camera.h" +#include "../../vn/vncharacter.h" +#include "../../ui/grid.h" +#include "../../ui/align.h" +#include "../../poker/player.h" +#include "../../poker/poker.h" +#include "../../vn/vnscene.h" + +#define POKER_UI_PLAYER_IMAGE_SIZE 64 +#define POKER_UI_PLAYER_WIDTH 300 +#define POKER_UI_PLAYER_HEIGHT POKER_UI_PLAYER_IMAGE_SIZE + +#define POKER_UI_PLAYER_IMAGE_RESOLUTION POKER_UI_PLAYER_IMAGE_SIZE * 2 +#define POKER_UI_PLAYER_IMAGE_DIST 0.8f +#define POKER_UI_PLAYER_IMAGE_Y 0.1f +#define POKER_UI_PLAYER_PADDING 8 +#define POKER_UI_PLAYER_CHIPS_ANIMATION_SPEED 0.5f + +typedef struct { + primitive_t quad; + label_t label; + grid_t grid; + image_t card; + framebuffer_t frames[POKER_PLAYER_COUNT]; +} pokerui_t; + +/** + * Initializes the UI Module. + * + * @param ui UI to initialize. + */ +void pokerUiInit(pokerui_t *ui); + +/** + * Update the Poker Game UI. + * + * @param ui UI to update. + * @param engine Engine to use for updating. + * @param shader Shader to use for rendering. + * @param characters Visual Novel characters to render. + * @param players Array of poker players. + */ +void pokerUiUpdate( + pokerui_t *ui, engine_t *engine, shader_t *shader, + vncharacter_t *characters, pokerplayer_t *players +); + +/** + * Render the Poker Game UI. + * + * @param ui UI to render. + * @param engine Engine to use for the render. + */ +void pokerUiRender(pokerui_t *ui, engine_t *engine); + +/** + * Cleanup only the UI elements for a poker game. + * + * @param ui UI to dispose. + */ +void pokerUiDispose(pokerui_t *ui); + +/** + * Updates the given image to represent a card UI image. + * + * @param image Image to update. + * @param texture Texture to use. + * @param card Card to set to. + */ +void pokerCardSetImage(image_t *image, texture_t *texture, card_t card); \ No newline at end of file diff --git a/src/game/poker/pokerworld.c b/src/game/poker/pokerworld.c index 5da65666..3917858b 100644 --- a/src/game/poker/pokerworld.c +++ b/src/game/poker/pokerworld.c @@ -7,17 +7,21 @@ #include "pokerworld.h" -void pokerWorldInit(pokergame_t *game) { +void pokerWorldInit( + pokerworld_t *world, + vnscene_t *scene, + pokergameassets_t *assets +) { vncharacter_t *character; uint8_t i; // Initialize the skywal - skywallInit(&game->world.skywall); + skywallInit(&world->skywall); // Initialize the players for(i = 0x00; i < POKER_PLAYER_COUNT; i++) { - character = game->scene.characters + game->scene.characterCount; - vnCharacterInit(character, &game->assets.pennyTexture, + character = scene->characters + scene->characterCount; + vnCharacterInit(character, &assets->pennyTexture, POKER_GAME_PENNY_BASE_WIDTH, POKER_GAME_PENNY_BASE_HEIGHT, POKER_GAME_PENNY_FACE_X, POKER_GAME_PENNY_FACE_Y, POKER_GAME_PENNY_FACE_WIDTH, POKER_GAME_PENNY_FACE_HEIGHT @@ -26,7 +30,7 @@ void pokerWorldInit(pokergame_t *game) { character->y = POKER_WORLD_SEAT_POSITION_Y; character->z = POKER_WORLD_SEAT_POSITION_Z(POKER_GAME_SEAT_FOR_PLAYER(i)); character->yaw = POKER_WORLD_SEAT_ROTATION(POKER_GAME_SEAT_FOR_PLAYER(i)); - game->scene.characterCount++; + scene->characterCount++; } } @@ -38,7 +42,7 @@ void pokerWorldLookAtPlayer(vnscene_t *scene, uint8_t playerIndex) { } void pokerWorldRender( - pokerworld_t *world, engine_t *engine, pokergameassets_t *assets + pokerworld_t *world, pokergameassets_t *assets ) { // Render the wall shaderUseTexture(&assets->shader, &assets->roomTexture); @@ -46,6 +50,6 @@ void pokerWorldRender( primitiveDraw(&world->skywall, 0, -1); } -void pokerWorldDispose(pokergame_t *game) { - primitiveDispose(&game->world.skywall); +void pokerWorldDispose(pokerworld_t *world) { + primitiveDispose(&world->skywall); } \ No newline at end of file diff --git a/src/game/poker/pokerworld.h b/src/game/poker/pokerworld.h index 661bfac8..3dae9894 100644 --- a/src/game/poker/pokerworld.h +++ b/src/game/poker/pokerworld.h @@ -12,9 +12,11 @@ #include "../../display/primitives/skywall.h" #include "../../vn/vnscene.h" #include "../../vn/vncharacter.h" -#include "pokergame.h" +#include "../../poker/player.h" +#include "../../poker/dealer.h" #include "pokergameassets.h" + #define POKER_WORLD_SEAT_DISTANCE -1 #define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f)) @@ -26,16 +28,41 @@ POKER_WORLD_SEAT_DISTANCE * (float)cos(POKER_WORLD_SEAT_ROTATION(n)) \ ) +#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) + +#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 { primitive_t skywall; } pokerworld_t; + /** * Initialize the poker renderer. * - * @param game Game to initialize for. + * @param world Pointer to the world to initialize. + * @param scene Visual Novel Engine scene to initialize. + * @param assets Assets to use for initialization. */ -void pokerWorldInit(pokergame_t *game); +void pokerWorldInit( + pokerworld_t *world, + vnscene_t *scene, + pokergameassets_t *assets +); /** * Adjusts the camera to look at a specific player. You can use this to look at @@ -50,15 +77,14 @@ void pokerWorldLookAtPlayer(vnscene_t *scene, uint8_t playerIndex); * Render the poker world. * * @param world Poker Game World. - * @param engine Game engine. * @param assets Assets to use. */ void pokerWorldRender( - pokerworld_t *world, engine_t *engine, pokergameassets_t *assets + pokerworld_t *world, pokergameassets_t *assets ); /** * Cleanup the poker world. - * @param game Game to clean up for. + * @param world World to clean up. */ -void pokerWorldDispose(pokergame_t *game); \ No newline at end of file +void pokerWorldDispose(pokerworld_t *world); \ No newline at end of file diff --git a/src/game/poker/ui/pokercardui.c b/src/game/poker/ui/pokercardui.c deleted file mode 100644 index 75a77f4d..00000000 --- a/src/game/poker/ui/pokercardui.c +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2021 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "pokercardui.h" - -void pokerCardSetImage(image_t *image, texture_t *texture, card_t card) { - uint8_t cardImageIndex = ( - cardGetNumber(card) == CARD_ACE ? ( - card - CARD_COUNT_PER_SUIT + 1 - ) : card+0x01 - ); - - imageSetTextureAndCrop( - image, texture, - cardGetNumber(cardImageIndex) * 71, - cardGetSuit(card) * 96, - 71, 96 - ); -} \ No newline at end of file diff --git a/src/game/poker/ui/pokercardui.h b/src/game/poker/ui/pokercardui.h deleted file mode 100644 index 534896bc..00000000 --- a/src/game/poker/ui/pokercardui.h +++ /dev/null @@ -1,13 +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 "../../../ui/image.h" -#include "../../../poker/card.h" - -void pokerCardSetImage(image_t *image, texture_t *texture, card_t card); \ No newline at end of file diff --git a/src/game/poker/ui/pokerplayerui.c b/src/game/poker/ui/pokerplayerui.c deleted file mode 100644 index 7b5d5d4f..00000000 --- a/src/game/poker/ui/pokerplayerui.c +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (c) 2021 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "pokerplayerui.h" - -void pokerPlayerUiInit(pokerplayerui_t *ui) { - gridInit(&ui->grid); - labelInit(&ui->label); - frameBufferInit(&ui->frame, - POKER_PLAYER_UI_IMAGE_RESOLUTION, POKER_PLAYER_UI_IMAGE_RESOLUTION - ); - quadInit(&ui->quad, 0, - 0, 0, 0, 1, - POKER_PLAYER_UI_IMAGE_SIZE, POKER_PLAYER_UI_IMAGE_SIZE, 1, 0 - ); - - // Set up the grid - ui->grid.gutterX = POKER_PLAYER_UI_PADDING; - ui->grid.columns = 2; - ui->grid.rows = 2; - ui->grid.columnDefinitions[1] = POKER_PLAYER_UI_IMAGE_SIZE; - ui->grid.rowDefinitions[0] = POKER_PLAYER_UI_IMAGE_SIZE / 2.0f; - ui->grid.rowDefinitions[1] = POKER_PLAYER_UI_IMAGE_SIZE / 2.0f; -} - -void pokerPlayerUiUpdate( - pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex, - engine_t *engine -) { - camera_t camera; - uint8_t seat; - pokerplayer_t *player; - float x, y, z; - - player = game->poker.players + playerIndex; - - // Bind the frame buffer - frameBufferUse(&ui->frame, true); - - // Set up the camera perspective - cameraPerspective(&camera, 45, - (float)POKER_PLAYER_UI_IMAGE_SIZE / (float)POKER_PLAYER_UI_IMAGE_SIZE, - 0.03f, 10.0f - ); - - // Locate the XYZ position of the camera to look at the player - seat = pokerGameSeatFromIndex(playerIndex); - x = POKER_WORLD_SEAT_POSITION_X(seat); - y = POKER_PLAYER_UI_IMAGE_Y; - z = POKER_WORLD_SEAT_POSITION_Z(seat); - - // Actually look at the player, we need to get close. - cameraLookAt(&camera, - x * POKER_PLAYER_UI_IMAGE_DIST, y, z * POKER_PLAYER_UI_IMAGE_DIST, - x, y, z - ); - - // Render the VN character - shaderUse(shader); - shaderUseCamera(shader, &camera); - shaderUsePosition(shader, 0,0,0, 0,0,0); - vnCharacterRender(game->scene.characters + playerIndex, shader); - - // Unbind the frame buffer. - frameBufferUnbind(&engine->render, false); -} - -void pokerPlayerUiRender( - pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font, - engine_t *engine, - int32_t playerIndex, float x, float y -) { - pokerplayer_t *player; - char buffer[32]; - float scale; - align_t align; - - float gx, gy, gw, gh; - - // Font crap. - scale = fontGetScale(FONT_SIZE_DEFAULT); - player = game->poker.players + playerIndex; - - // Align the grid itself. - gridResize(&ui->grid, POKER_PLAYER_UI_WIDTH, POKER_PLAYER_UI_HEIGHT); - - // Render face - gridGetChild(&ui->grid, 1, 0, 1, 2, &gx, &gy, &gw, &gh); - shaderUseTexture(shader, &ui->frame.texture); - shaderUsePosition(shader, x+gx, y+gy, 0, 0,0,0); - primitiveDraw(&ui->quad, 0, -1); - - // Render chips - sprintf(buffer, "$%i", player->chips); - ui->label.maxWidth = -1; - labelSetText(&ui->label, font, buffer); - align = gridGetAndAlignChild( - &ui->grid, 0, 0, 1, 1, - ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL, - ui->label.info.width, ui->label.info.height - ); - labelRender(&ui->label, shader, x+align.x, y+align.y); - - // Render state - if(player->state & POKER_PLAYER_STATE_OUT) { - sprintf(buffer, "Out"); - } else if(player->state & POKER_PLAYER_STATE_FOLDED) { - sprintf(buffer, "Folded"); - } else if(player->state & POKER_PLAYER_STATE_SHOWING) { - sprintf(buffer, "Showing"); - } else if(game->poker.bet.better == playerIndex) { - sprintf(buffer, "Thinking"); - } else { - sprintf(buffer, "Whatever"); - } - labelSetText(&ui->label, font, buffer); - align = gridGetAndAlignChild( - &ui->grid, 0, 1, 1, 1, - ALIGN_POS_END | ALIGN_SIZE_ORIGINAL, ALIGN_POS_CENTER | ALIGN_SIZE_ORIGINAL, - ui->label.info.width, ui->label.info.height - ); - labelRender(&ui->label, shader, x+align.x, y+align.y); -} - -void pokerPlayerUiDispose(pokerplayerui_t *ui) { - primitiveDispose(&ui->quad); - frameBufferDispose(&ui->frame); - labelDispose(&ui->label); -} \ No newline at end of file diff --git a/src/game/poker/ui/pokerplayerui.h b/src/game/poker/ui/pokerplayerui.h deleted file mode 100644 index e793252c..00000000 --- a/src/game/poker/ui/pokerplayerui.h +++ /dev/null @@ -1,55 +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 "../../../ui/label.h" -#include "../../../ui/image.h" -#include "../../../display/framebuffer.h" -#include "../../../display/primitive.h" -#include "../../../display/primitives/quad.h" -#include "../../../display/primitives/cube.h" -#include "../../../display/shader.h" -#include "../../../engine/engine.h" -#include "../../../display/camera.h" -#include "../../../vn/vncharacter.h" -#include "../../../ui/grid.h" -#include "../../../ui/align.h" -#include "../pokergame.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( - pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex, - engine_t *engine -); - -void pokerPlayerUiRender( - pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font, - engine_t *engine, - int32_t playerIndex, float x, float y -); - -void pokerPlayerUiDispose(pokerplayerui_t *ui); \ No newline at end of file diff --git a/src/game/poker/ui/pokerui.c b/src/game/poker/ui/pokerui.c deleted file mode 100644 index 881eb208..00000000 --- a/src/game/poker/ui/pokerui.c +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2021 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "pokerui.h" - -void pokerUiInit(pokergame_t *pokerGame) { - uint8_t i, j; - - // Initialize card render(s) - imageInit(&pokerGame->ui.card); - - // Initialize players - j = 0; - for(i = 0; i < POKER_PLAYER_COUNT; i++) { - if(i == POKER_PLAYER_HUMAN_INDEX) continue; - pokerPlayerUiInit(pokerGame->ui.player + j); - j++; - } -} - -void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine) { - uint8_t i, j; - pokerplayerui_t *ui; - - j = 0; - for(i = 0; i < POKER_PLAYER_COUNT; i++) { - if(i == POKER_PLAYER_HUMAN_INDEX) continue; - ui = pokerGame->ui.player + j; - pokerPlayerUiUpdate(ui, pokerGame, &pokerGame->assets.shader, i, engine); - j++; - } -} - -void pokerUiRender(pokergame_t *pokerGame, engine_t *engine) { - uint8_t i, j; - pokerplayerui_t *ui; - pokerplayer_t *player; - - char message[128]; - - // cards - if(pokerGame->poker.state >= POKER_STATE_DEALING) { - for(j = 0; j < POKER_PLAYER_COUNT; j++) { - player = pokerGame->poker.players + j; - for(i = 0; i < player->cardCount; i++) { - pokerCardSetImage(&pokerGame->ui.card, &pokerGame->assets.cardTexture, player->cards[i]); - imageRender(&pokerGame->ui.card, &pokerGame->assets.shader, i * 64.0f, j * 100); - } - } - } - - // show uh - player = pokerGame->poker.players + POKER_PLAYER_HUMAN_INDEX; - if(pokerGame->poker.bet.better == POKER_PLAYER_HUMAN_INDEX) { - sprintf(message, "Press down to fold, up to bet, right to check/call."); - labelSetText(&pokerGame->ui.player->label, &pokerGame->assets.font, message); - labelRender(&pokerGame->ui.player->label, &pokerGame->assets.shader, 300, 100); - } - - - j = 0; - for(i = 0; i < POKER_PLAYER_COUNT; i++) { - if(i == POKER_PLAYER_HUMAN_INDEX) continue; - ui = pokerGame->ui.player + j; - - pokerPlayerUiRender( - ui, pokerGame, &pokerGame->assets.shader, &pokerGame->assets.font, engine, - i, engine->render.width - ui->grid.width, j * 75.0f - ); - j++; - } -} - -void pokerUiDispose(pokergame_t *pokerGame) { - uint8_t i, j; - - imageDispose(&pokerGame->ui.card); - - j = 0; - for(i = 0; i < POKER_PLAYER_COUNT; i++) { - if(i == POKER_PLAYER_HUMAN_INDEX) continue; - pokerPlayerUiDispose(pokerGame->ui.player + j); - j++; - } -} \ No newline at end of file diff --git a/src/game/poker/ui/pokerui.h b/src/game/poker/ui/pokerui.h deleted file mode 100644 index 5dc7bef5..00000000 --- a/src/game/poker/ui/pokerui.h +++ /dev/null @@ -1,48 +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 "../../../ui/label.h" -#include "pokerplayerui.h" -#include "pokercardui.h" -#include "../pokergame.h" - -typedef struct { - pokerplayerui_t player[POKER_PLAYER_COUNT]; - image_t card; -} pokerui_t; - -/** - * Initializes the UI Module. - * - * @param pokerGame Poker game to initialize the UI for. - */ -void pokerUiInit(pokergame_t *pokerGame); - -/** - * Update the Poker Game UI. - * - * @param pokerGame Game to update. - * @param engine Engine to use for updating. - */ -void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine); - -/** - * Render the Poker Game UI. - * - * @param pokerGame Game to render the UI for. - * @param engine Engine to use for the render. - */ -void pokerUiRender(pokergame_t *pokerGame, engine_t *engine); - -/** - * Cleanup only the UI elements for a poker game. - * - * @param pokerGame Game to dispose the UI for. - */ -void pokerUiDispose(pokergame_t *pokerGame); \ No newline at end of file diff --git a/src/poker/actions/blinds.c b/src/poker/actions/blinds.c index 4d365725..3c15ecd5 100644 --- a/src/poker/actions/blinds.c +++ b/src/poker/actions/blinds.c @@ -13,7 +13,12 @@ void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i) { poker->state = POKER_STATE_TAKING_BLINDS; - pokerBetTakeBlinds(poker); + pokerBetTakeBlinds( + &poker->bet, + poker->players, + poker->roundSmallBlind, + poker->roundBigBlind + ); printf("Taken Blinds\n"); queueNext(queue); } diff --git a/src/poker/actions/blinds.h b/src/poker/actions/blinds.h index bea08f52..20c67e60 100644 --- a/src/poker/actions/blinds.h +++ b/src/poker/actions/blinds.h @@ -6,9 +6,10 @@ */ #pragma once +#include "../bet.h" +#include "../poker.h" #include "../../libs.h" #include "../../display/animation/queue.h" -#include "../bet.h" /** Callback for the blinds action */ void _pokerActionBlindsOnStart(queue_t *queue,queueaction_t *action,uint8_t i); diff --git a/src/poker/actions/deal.c b/src/poker/actions/deal.c index ea39e736..0f91103c 100644 --- a/src/poker/actions/deal.c +++ b/src/poker/actions/deal.c @@ -17,7 +17,7 @@ void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i) { cardShuffle(poker->dealer.deck, CARD_DECK_SIZE); // Deal 2 card to each player - pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH); + pokerDealerDealAll(&poker->dealer, poker->players, POKER_DEAL_CARD_EACH); printf("Cards Dealt\n"); queueNext(queue); diff --git a/src/poker/actions/deal.h b/src/poker/actions/deal.h index a8ad54ac..dc433c5f 100644 --- a/src/poker/actions/deal.h +++ b/src/poker/actions/deal.h @@ -9,6 +9,7 @@ #include "../../libs.h" #include "../../display/animation/queue.h" #include "../dealer.h" +#include "../poker.h" /** Callback for the deal action */ void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i); diff --git a/src/poker/actions/flop.h b/src/poker/actions/flop.h index 5def9884..bf4ead8b 100644 --- a/src/poker/actions/flop.h +++ b/src/poker/actions/flop.h @@ -9,6 +9,8 @@ #include "../../libs.h" #include "../../display/animation/queue.h" #include "../dealer.h" +#include "../poker.h" +#include "../turn.h" /** * Shorthand action callback parser. Takes the queue, action and the intended diff --git a/src/poker/actions/match.h b/src/poker/actions/match.h index cc3026ca..ef76cad5 100644 --- a/src/poker/actions/match.h +++ b/src/poker/actions/match.h @@ -7,6 +7,7 @@ #include "../../libs.h" #include "../../display/animation/queue.h" #include "../bet.h" +#include "../poker.h" /** Callback for when the poker match aciton starts */ void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i); diff --git a/src/poker/actions/round.h b/src/poker/actions/round.h index ba7fcf5b..fe927f9d 100644 --- a/src/poker/actions/round.h +++ b/src/poker/actions/round.h @@ -6,7 +6,7 @@ */ #pragma once -#include +#include "../../libs.h" #include "../../display/animation/queue.h" #include "../dealer.h" #include "../bet.h" diff --git a/src/poker/bet.c b/src/poker/bet.c index 178e26f9..e4f37bfb 100644 --- a/src/poker/bet.c +++ b/src/poker/bet.c @@ -64,9 +64,8 @@ uint8_t pokerBetGetRemainingPlayer( void pokerBetTakeBlinds( pokerbet_t *bet, pokerplayer_t *players, - uint8_t roundSmallBlind, uint8_t roundBigBlind, - int32_t blindSmall, int32_t blindBig + uint8_t roundSmallBlind, uint8_t roundBigBlind ) { - pokerBetPlayer(bet, players + roundSmallBlind, blindSmall); - pokerBetPlayer(bet, players + roundBigBlind, blindBig); + pokerBetPlayer(bet, players + roundSmallBlind, bet->blindSmall); + pokerBetPlayer(bet, players + roundBigBlind, bet->blindBig); } \ No newline at end of file diff --git a/src/poker/bet.h b/src/poker/bet.h index b8fdccb9..2c449065 100644 --- a/src/poker/bet.h +++ b/src/poker/bet.h @@ -102,6 +102,5 @@ uint8_t pokerBetGetRemainingPlayer( */ void pokerBetTakeBlinds( pokerbet_t *bet, pokerplayer_t *players, - uint8_t roundSmallBlind, uint8_t roundBigBlind, - int32_t blindSmall, int32_t blindBig + uint8_t roundSmallBlind, uint8_t roundBigBlind ); \ No newline at end of file diff --git a/src/script/scripter.c b/src/script/scripter.c index 26c958b1..cfc382c3 100644 --- a/src/script/scripter.c +++ b/src/script/scripter.c @@ -15,9 +15,6 @@ void scripterInit(scripter_t *scripter, engine_t *engine) { // Push the script self reference duk_push_pointer(scripter->context, scripter); duk_put_global_string(scripter->context, SCRIPTER_SELF_NAME); - - // Inject API - scriptsApiIo(scripter); } void scripterDispose(scripter_t *scripter) { diff --git a/src/script/scripter.h b/src/script/scripter.h index be1ee708..216705d3 100644 --- a/src/script/scripter.h +++ b/src/script/scripter.h @@ -7,7 +7,6 @@ #pragma once #include "../libs.h" -#include "api/io.h" #include "../engine/engine.h" /** Implies that the arguments the function will take is variable */ diff --git a/src/vn/conversation/talk.c b/src/vn/conversation/talk.c index 072c467b..2dc2313e 100644 --- a/src/vn/conversation/talk.c +++ b/src/vn/conversation/talk.c @@ -7,7 +7,7 @@ #include "talk.h" -void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) { +void _vnConversationTalkStart(queue_t *queue, queueaction_t *action,uint8_t i) { vnconversationitemdata_t *data; data = (vnconversationitemdata_t *)action->data; diff --git a/src/vn/conversation/talk.h b/src/vn/conversation/talk.h index 2e3320de..aeeb8ae2 100644 --- a/src/vn/conversation/talk.h +++ b/src/vn/conversation/talk.h @@ -9,6 +9,7 @@ #include "../../libs.h" #include "vnconversation.h" #include "../../display/animation/queue.h" +#include "../vncharacter.h" /** Event Callback for when the talk action starts */ void _vnConversationTalkStart(queue_t *q, queueaction_t *a, uint8_t i); diff --git a/src/vn/conversation/vnconversation.c b/src/vn/conversation/vnconversation.c index 65973247..40ee36e0 100644 --- a/src/vn/conversation/vnconversation.c +++ b/src/vn/conversation/vnconversation.c @@ -29,7 +29,7 @@ queueaction_t * vnConversationAdd(vnconversation_t *conversation) { void vnConversationUpdate(vnconversation_t *convo, engine_t *engine) { vnTextBoxUpdate(&convo->textbox, engine); - queueUpdate(&convo->actionQueue, engine); + queueUpdate(&convo->actionQueue, engine->time.delta); } void vnConversationRender( diff --git a/src/vn/conversation/vnconversation.h b/src/vn/conversation/vnconversation.h index 6865d69b..af14f38c 100644 --- a/src/vn/conversation/vnconversation.h +++ b/src/vn/conversation/vnconversation.h @@ -11,6 +11,8 @@ #include "../../util/array.h" #include "../../display/animation/timeline.h" #include "../../display/animation/queue.h" +#include "../vncharacter.h" +#include "../../engine/engine.h" typedef struct _vnconversation_t vnconversation_t;