Joining the two logics together slowly.
This commit is contained in:
@ -8,16 +8,45 @@
|
||||
#include "pokergame.h"
|
||||
|
||||
bool pokerGameInit(game_t *game) {
|
||||
pokergame_t *pokerGame = &game->pokerGame;
|
||||
|
||||
// Init the game
|
||||
game->name = POKER_GAME_NAME;
|
||||
|
||||
// Load the Assets
|
||||
pokerGameAssetsInit(&pokerGame->assets);
|
||||
|
||||
// Hand off to the poker logic.
|
||||
pokerInit(&game->pokerGame.poker, &game->engine);
|
||||
}
|
||||
// Prep the VN Conversation Engine.
|
||||
vnSceneInit(&pokerGame->scene, &pokerGame->assets.font);
|
||||
|
||||
vnConversationTalk(&pokerGame->scene.conversation, "Start Match", NULL);
|
||||
pokerActionMatchAdd(&pokerGame->scene.conversation.actionQueue, &pokerGame->poker);
|
||||
vnConversationTalk(&pokerGame->scene.conversation, "Start Round", NULL);
|
||||
pokerActionRoundAdd(&pokerGame->scene.conversation.actionQueue, &pokerGame->poker);
|
||||
vnConversationTalk(&pokerGame->scene.conversation, "Betting Round", NULL);
|
||||
|
||||
// Begin the VN conversation queue.
|
||||
queueNext(&pokerGame->scene.conversation.actionQueue);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void pokerGameUpdate(game_t *game) {
|
||||
pokergame_t *pokerGame;
|
||||
pokerGame = &game->pokerGame;
|
||||
|
||||
// Update the scene
|
||||
vnSceneUpdate(&pokerGame->scene, &game->engine);
|
||||
|
||||
// Bind the shader.
|
||||
shaderUse(&pokerGame->assets.shader);
|
||||
|
||||
// Render the visual novel scene
|
||||
vnSceneRenderWorld(&pokerGame->scene, &game->engine, &pokerGame->assets.shader);
|
||||
vnSceneRenderGui(&pokerGame->scene, &game->engine, &pokerGame->assets.shader);
|
||||
}
|
||||
|
||||
void pokerGameDispose(game_t *game) {
|
||||
|
||||
vnSceneDispose(&game->pokerGame.scene);
|
||||
pokerGameAssetsDispose(&game->pokerGame.assets);
|
||||
}
|
@ -7,7 +7,13 @@
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "pokergameassets.h"
|
||||
#include "../../poker/poker.h"
|
||||
#include "../../vn/conversation/talk.h"
|
||||
#include "../../vn/vnscene.h"
|
||||
|
||||
#include "../../poker/actions/match.h"
|
||||
#include "../../poker/actions/round.h"
|
||||
|
||||
/**
|
||||
* Initializes the game state for the poker game.
|
||||
|
20
src/game/poker/pokergameassets.c
Normal file
20
src/game/poker/pokergameassets.c
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include "pokergameassets.h"
|
||||
|
||||
bool pokerGameAssetsInit(pokergameassets_t *assets) {
|
||||
assetFontLoad(&assets->font, "fonts/opensans/OpenSans-Bold.ttf");
|
||||
assetShaderLoad(&assets->shader,
|
||||
"shaders/textured.vert", "shaders/textured.frag"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
void pokerGameAssetsDispose(pokergameassets_t *assets) {
|
||||
shaderDispose(&assets->shader);
|
||||
fontDispose(&assets->font);
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "../player.h"
|
||||
#include "../winner.h"
|
||||
#include "../../file/asset.h"
|
||||
|
||||
void pokerWinnerInit(poker_t *poker);
|
||||
bool pokerGameAssetsInit(pokergameassets_t *assets);
|
||||
void pokerGameAssetsDispose(pokergameassets_t *assets);
|
@ -4,11 +4,15 @@
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "match.h"
|
||||
|
||||
void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
||||
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i){
|
||||
poker_t *poker;
|
||||
uint8_t x;
|
||||
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
// Reset the main game state. This does not init the round.
|
||||
pokerBetInit(&poker->bet);
|
||||
poker->roundDealer = POKER_PLAYER_COUNT-2;
|
||||
@ -19,8 +23,13 @@ void pokerMatchInit(poker_t *poker, engine_t *engine) {
|
||||
poker->players[x].chips = POKER_BET_PLAYER_CHIPS_DEFAULT;
|
||||
}
|
||||
printf("Match Start\n");
|
||||
pokerStartInit(poker);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
void pokerMatchUpdate(poker_t *poker, engine_t *engine) {
|
||||
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionMatchOnStart;
|
||||
return action;
|
||||
}
|
20
src/poker/actions/match.h
Normal file
20
src/poker/actions/match.h
Normal file
@ -0,0 +1,20 @@
|
||||
// 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 "../../display/animation/queue.h"
|
||||
|
||||
/** Callback for when the poker match aciton starts */
|
||||
void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
|
||||
|
||||
/**
|
||||
* Adds a Poker Match Begin Action onto a queue.
|
||||
*
|
||||
* @param queue Queue to add to
|
||||
* @param poker Poker game instance to use.
|
||||
* @return The queued match start action.
|
||||
*/
|
||||
queueaction_t * pokerActionMatchAdd(queue_t *queue, poker_t *poker);
|
@ -5,12 +5,15 @@
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "start.h"
|
||||
#include "round.h"
|
||||
|
||||
void pokerStartInit(poker_t *poker) {
|
||||
uint8_t i, indexDealer, indexSmallBlind, indexBigBlind;
|
||||
void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
|
||||
uint8_t j, indexDealer, indexSmallBlind, indexBigBlind;
|
||||
bool foundDealer, foundSmallBlind;
|
||||
pokerplayer_t *player;
|
||||
poker_t *poker;
|
||||
|
||||
poker = (poker_t *)action->data;
|
||||
|
||||
poker->round = POKER_ROUND_START;
|
||||
|
||||
@ -28,23 +31,23 @@ void pokerStartInit(poker_t *poker) {
|
||||
poker->roundDealer = (poker->roundDealer+1) % POKER_PLAYER_COUNT;
|
||||
|
||||
// Find the players.
|
||||
i = poker->roundDealer;
|
||||
j = poker->roundDealer;
|
||||
foundDealer = false;
|
||||
foundSmallBlind = false;
|
||||
while(true) {
|
||||
player = poker->players + i;
|
||||
player = poker->players + j;
|
||||
if(!pokerPlayerIsAlive(player)) continue;
|
||||
if(!foundDealer) {
|
||||
indexDealer = i;
|
||||
indexDealer = j;
|
||||
foundDealer = true;
|
||||
} else if(!foundSmallBlind) {
|
||||
indexSmallBlind = i;
|
||||
indexSmallBlind = j;
|
||||
foundSmallBlind = true;
|
||||
} else {
|
||||
indexBigBlind = i;
|
||||
indexBigBlind = j;
|
||||
break;
|
||||
}
|
||||
i = (i + 1) % POKER_PLAYER_COUNT;
|
||||
j = (j + 1) % POKER_PLAYER_COUNT;
|
||||
}
|
||||
|
||||
// Update players for the round.
|
||||
@ -53,5 +56,13 @@ void pokerStartInit(poker_t *poker) {
|
||||
poker->roundSmallBlind = indexSmallBlind;
|
||||
|
||||
printf("Round Start\n");
|
||||
pokerBlindsInit(poker);
|
||||
queueNext(queue);
|
||||
}
|
||||
|
||||
queueaction_t * pokerActionRoundAdd(queue_t *queue, poker_t *poker) {
|
||||
queueaction_t *action;
|
||||
action = queueAdd(queue);
|
||||
action->data = (void *)poker;
|
||||
action->onStart = &_pokerActionRoundOnStart;
|
||||
return action;
|
||||
}
|
25
src/poker/actions/round.h
Normal file
25
src/poker/actions/round.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 "../../display/animation/queue.h"
|
||||
#include "../bet.h"
|
||||
#include "../player.h"
|
||||
|
||||
/** Callback for when the poker round start aciton begins. */
|
||||
void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action, uint8_t i);
|
||||
|
||||
/**
|
||||
* Queues the round action onto a queue. Round action should be queued at the
|
||||
* start of every poker round.
|
||||
*
|
||||
* @param queue Queue to add to.
|
||||
* @param poker Poker game instance.
|
||||
* @return The queued action.
|
||||
*/
|
||||
queueaction_t * pokerActionRoundAdd(queue_t *queue, poker_t *poker);
|
@ -6,27 +6,3 @@
|
||||
*/
|
||||
|
||||
#include "poker.h"
|
||||
|
||||
void pokerInit(poker_t *poker) {
|
||||
|
||||
}
|
||||
|
||||
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
||||
// Game Logic
|
||||
switch(poker->round) {
|
||||
case POKER_ROUND_MATCH:
|
||||
pokerMatchUpdate(poker, engine);
|
||||
break;
|
||||
case POKER_ROUND_BET0:
|
||||
case POKER_ROUND_BET1:
|
||||
case POKER_ROUND_BET2:
|
||||
case POKER_ROUND_BET3:
|
||||
pokerRoundBetUpdate(poker);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void pokerDispose(poker_t * poker) {
|
||||
}
|
@ -6,24 +6,4 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "round/match.h"
|
||||
|
||||
/**
|
||||
* Initializes the poker context for the first time.
|
||||
* @param poker Poker context to initialize.
|
||||
*/
|
||||
void pokerInit(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Updates the poker context.
|
||||
* @param poker Poker game context.
|
||||
* @param engine Engine that is running the game.
|
||||
*/
|
||||
void pokerUpdate(poker_t *poker, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Cleans an existing poker game instance.
|
||||
* @param poker Poker instance to cleanup
|
||||
*/
|
||||
void pokerDispose(poker_t *poker);
|
||||
#include <dawn/dawn.h>
|
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "bet.h"
|
||||
|
||||
void pokerRoundBetPlayerNext(poker_t *poker) {
|
||||
// Go to next player, keep contained.
|
||||
poker->bet.better = (poker->bet.better + 1) % POKER_PLAYER_COUNT;
|
||||
|
||||
// Did we go full circle?
|
||||
if(poker->bet.better == poker->roundSmallBlind) {
|
||||
if(poker->round == POKER_ROUND_BET3) {
|
||||
pokerWinnerInit(poker);
|
||||
return;
|
||||
}
|
||||
|
||||
pokerFlopInit(poker);
|
||||
return;
|
||||
}
|
||||
|
||||
// Init the next player
|
||||
pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better);
|
||||
}
|
||||
|
||||
|
||||
void pokerRoundBetPlayerInit(poker_t *poker, pokerplayer_t *player) {
|
||||
// Check the player state (to see if we even can init, e.g. folded/not)
|
||||
if(!pokerPlayerIsAlive(player)) {
|
||||
pokerRoundBetPlayerNext(poker);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Betting round player %u\n", poker->bet.better);
|
||||
if(pokerPlayerIsHuman(poker, player)) {
|
||||
pokerRoundBetPlayerNext(poker);
|
||||
return;
|
||||
}
|
||||
|
||||
pokerRoundBetPlayerNext(poker);
|
||||
}
|
||||
|
||||
void pokerRoundBetPlayerUpdate(poker_t *poker, pokerplayer_t *player) {
|
||||
|
||||
}
|
||||
|
||||
void pokerRoundBetInit(poker_t *poker) {
|
||||
printf("Betting round start\n");
|
||||
|
||||
if(poker->round == POKER_ROUND_DEAL) {
|
||||
poker->round = POKER_ROUND_BET0;
|
||||
printf("Betting 0\n");
|
||||
} else if(poker->round == POKER_ROUND_FLOP) {
|
||||
poker->round = POKER_ROUND_BET1;
|
||||
printf("Betting 1\n");
|
||||
} else if(poker->round == POKER_ROUND_TURN) {
|
||||
poker->round = POKER_ROUND_BET2;
|
||||
printf("Betting 2\n");
|
||||
} else if(poker->round == POKER_ROUND_RIVER) {
|
||||
poker->round = POKER_ROUND_BET3;
|
||||
printf("Betting 3\n");
|
||||
}
|
||||
|
||||
// Set the inital player
|
||||
poker->bet.better = poker->roundSmallBlind;
|
||||
pokerRoundBetPlayerInit(poker, poker->players + poker->bet.better);
|
||||
}
|
||||
|
||||
void pokerRoundBetUpdate(poker_t *poker) {
|
||||
// Take the current player
|
||||
pokerRoundBetPlayerUpdate(poker, poker->players + poker->bet.better);
|
||||
}
|
@ -1,19 +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 "flop.h"
|
||||
#include "winner.h"
|
||||
#include "../player.h"
|
||||
|
||||
void pokerRoundBetPlayerNext(poker_t *poker);
|
||||
void pokerRoundBetPlayerInit(poker_t *poker, pokerplayer_t *player);
|
||||
void pokerRoundBetPlayerUpdate(poker_t *poker, pokerplayer_t *player);
|
||||
|
||||
void pokerRoundBetInit(poker_t *poker);
|
||||
void pokerRoundBetUpdate(poker_t *poker);
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "blinds.h"
|
||||
|
||||
void pokerBlindsInit(poker_t *poker) {
|
||||
poker->round = POKER_ROUND_BLINDS;
|
||||
|
||||
// Now take blinds
|
||||
pokerBetTakeBlinds(poker);
|
||||
|
||||
printf("Blinds Taken\n");
|
||||
pokerDealInit(poker);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include <dawn/dawn.h>
|
||||
#include "deal.h"
|
||||
#include "../bet.h"
|
||||
|
||||
/**
|
||||
* Initializes the blinds round.
|
||||
* @param poker The poker game conetxt.
|
||||
*/
|
||||
void pokerBlindsInit(poker_t *poker);
|
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include "deal.h"
|
||||
|
||||
void pokerDealInit(poker_t *poker) {
|
||||
poker->round = POKER_ROUND_DEAL;
|
||||
|
||||
// Shuffle the deck
|
||||
cardShuffle(poker->dealer.deck, CARD_DECK_SIZE);
|
||||
|
||||
// Deal 2 card to each player
|
||||
pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH);
|
||||
|
||||
// Deal 2 card to each player
|
||||
pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH);
|
||||
|
||||
printf("Cards Dealt\n");
|
||||
pokerRoundBetInit(poker);
|
||||
}
|
@ -1,19 +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 "../../util/array.h"
|
||||
#include "../dealer.h"
|
||||
#include "../card.h"
|
||||
#include "bet.h"
|
||||
|
||||
/**
|
||||
* Resets a poker game for the new round.
|
||||
* @param poker Poker game to reset to a new round.
|
||||
*/
|
||||
void pokerDealInit(poker_t *poker);
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "flop.h"
|
||||
|
||||
void pokerFlopInit(poker_t *poker) {
|
||||
uint8_t count;
|
||||
|
||||
if(poker->round == POKER_ROUND_BET0) {
|
||||
printf("Poker Flop Start\n");
|
||||
poker->round = POKER_ROUND_FLOP;
|
||||
count = POKER_FLOP_CARD_COUNT;
|
||||
} else if(poker->round == POKER_ROUND_BET1) {
|
||||
printf("Poker Turn\n");
|
||||
poker->round = POKER_ROUND_TURN;
|
||||
count = POKER_TURN_CARD_COUNT;
|
||||
} else if(poker->round == POKER_ROUND_BET2) {
|
||||
printf("Poker River\n");
|
||||
poker->round = POKER_ROUND_RIVER;
|
||||
count = POKER_RIVER_CARD_COUNT;
|
||||
}
|
||||
|
||||
// Burn and flop.
|
||||
pokerDealerBurn(&poker->dealer, 1);
|
||||
pokerDealerTurn(&poker->dealer, count);
|
||||
|
||||
pokerRoundBetInit(poker);
|
||||
}
|
@ -1,14 +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 "../dealer.h"
|
||||
#include "../card.h"
|
||||
#include "bet.h"
|
||||
|
||||
void pokerFlopInit(poker_t *poker);
|
@ -1,23 +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 "start.h"
|
||||
|
||||
/**
|
||||
* Init the poker match round.
|
||||
* @param poker The poker game context.
|
||||
* @param engine The engine context.
|
||||
*/
|
||||
void pokerMatchInit(poker_t *poker, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Update the poker match round.
|
||||
* @param poker The poker match to update for.
|
||||
*/
|
||||
void pokerMatchUpdate(poker_t *poker, engine_t *engine);
|
@ -1,14 +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 "blinds.h"
|
||||
#include "../bet.h"
|
||||
#include "../player.h"
|
||||
|
||||
void pokerStartInit(poker_t *poker);
|
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
#include "winner.h"
|
||||
|
||||
void pokerWinnerInit(poker_t *poker) {
|
||||
pokerWinnerCalculate(poker);
|
||||
printf("Winner Count %u\n", poker->winner.winnerCount);
|
||||
}
|
@ -10,7 +10,10 @@
|
||||
void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||
vnconversationitemdata_t *data;
|
||||
data = (vnconversationitemdata_t *)action->data;
|
||||
|
||||
|
||||
printf("Speaking ");
|
||||
printf(data->text);
|
||||
printf("\n");
|
||||
vnTextBoxSetText(&data->conversation->textbox, data->text);
|
||||
|
||||
if(data->character != NULL) {
|
||||
@ -21,8 +24,9 @@ void _vnConversationTalkStart(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||
void _vnConversationTalkUpdate(queue_t *queue,queueaction_t *action,uint8_t i) {
|
||||
vnconversationitemdata_t *data;
|
||||
data = (vnconversationitemdata_t *)action->data;
|
||||
|
||||
|
||||
if(data->conversation->textbox.state & VN_TEXTBOX_STATE_CLOSED) {
|
||||
printf("Spoke\n");
|
||||
if(data->character != NULL) data->character->talking = false;
|
||||
queueNext(queue);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ void vnTextBoxSetText(vntextbox_t *box, char *text) {
|
||||
box->text = text;
|
||||
box->lineCurrent = 0;
|
||||
box->state = 0;
|
||||
box->textScroll = 0;
|
||||
vnTextBoxRebuffer(box);
|
||||
}
|
||||
|
||||
@ -35,6 +36,7 @@ void vnTextBoxRebuffer(vntextbox_t *box) {
|
||||
fontTextClamp(box->font, &box->textInfo, box->text, box->widthMax);
|
||||
fontTextInit(box->font, &box->primitive, &box->textInfo);
|
||||
|
||||
// Test "Background"
|
||||
quadInit(&box->testPrimitive, 0,
|
||||
0, 0, 0.3, 0.3,
|
||||
box->textInfo.width, box->textInfo.height, 0.6, 0.6
|
||||
|
84
src/vn/vnscene.c
Normal file
84
src/vn/vnscene.c
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "vnscene.h"
|
||||
|
||||
void vnSceneInit(vnscene_t *scene, font_t *font) {
|
||||
// Init the conversation
|
||||
vnConversationInit(&scene->conversation, font);
|
||||
scene->conversation.textbox.linesMax = 3;
|
||||
|
||||
// Reset character count
|
||||
scene->characterCount = 0x00;
|
||||
}
|
||||
|
||||
void vnSceneUpdate(vnscene_t *scene, engine_t *engine) {
|
||||
uint8_t i;
|
||||
|
||||
// Update the conversation
|
||||
vnConversationUpdate(&scene->conversation, engine);
|
||||
|
||||
// Update the character states
|
||||
for(i = 0; i < scene->characterCount; i++) {
|
||||
vnCharacterUpdate(scene->characters + i, engine);
|
||||
}
|
||||
}
|
||||
|
||||
void vnSceneDispose(vnscene_t *scene) {
|
||||
vnConversationDispose(&scene->conversation);
|
||||
}
|
||||
|
||||
void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
||||
uint8_t i;
|
||||
|
||||
// Adjust 3D Space position
|
||||
cameraLookAt(&scene->camera,
|
||||
0.5, 0.5, 0.75,
|
||||
0.5, 0.5, -0.5
|
||||
);
|
||||
|
||||
// Set Camera Perspective
|
||||
cameraPerspective(&scene->camera, 75,
|
||||
engine->render.width/engine->render.height,
|
||||
0.01, 1000.0
|
||||
);
|
||||
|
||||
// Update Shader
|
||||
shaderUseCamera(shader, &scene->camera);
|
||||
|
||||
// Render each character
|
||||
for(i = 0; i < scene->characterCount; i++) {
|
||||
vnCharacterRender(scene->characters + i, shader);
|
||||
}
|
||||
}
|
||||
|
||||
void vnSceneRenderGui(vnscene_t *scene, engine_t *engine, shader_t *shader) {
|
||||
// Do we need to update the width of the GUI element(s) ?
|
||||
if(engine->render.width != scene->conversation.textbox.widthMax) {
|
||||
scene->conversation.textbox.widthMax = engine->render.width;
|
||||
vnTextBoxRebuffer(&scene->conversation.textbox);
|
||||
}
|
||||
|
||||
// Move the camera in space
|
||||
cameraLookAt(&scene->camera,
|
||||
0, 0, 10,
|
||||
0, 0, 0
|
||||
);
|
||||
|
||||
// Orthogonalize Camera
|
||||
cameraOrtho(&scene->camera,
|
||||
0, engine->render.width,
|
||||
engine->render.height, 0,
|
||||
0.01, 1000.0
|
||||
);
|
||||
|
||||
// Update Shader
|
||||
shaderUseCamera(shader, &scene->camera);
|
||||
|
||||
// Render Conversation Element
|
||||
vnConversationRender(&scene->conversation, shader);
|
||||
}
|
24
src/vn/vnscene.h
Normal file
24
src/vn/vnscene.h
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 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 "vncharacter.h"
|
||||
#include "conversation/vnconversation.h"
|
||||
#include "gui/vntextbox.h"
|
||||
#include "../display/camera.h"
|
||||
#include "../display/shader.h"
|
||||
|
||||
void vnSceneInit(vnscene_t *scene, font_t *font);
|
||||
|
||||
void vnSceneUpdate(vnscene_t *scene, engine_t *engine);
|
||||
|
||||
void vnSceneDispose(vnscene_t *scene);
|
||||
|
||||
void vnSceneRenderWorld(vnscene_t *scene, engine_t *engine, shader_t *shader);
|
||||
|
||||
void vnSceneRenderGui(vnscene_t *scene, engine_t *engine, shader_t *shader);
|
Reference in New Issue
Block a user