Dawn/src/poker/poker.c

65 lines
1.5 KiB
C

/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "poker.h"
void pokerInit(poker_t *poker, engine_t *engine) {
// Load the main shader
assetShaderLoad(&poker->shader,
"shaders/textured.vert", "shaders/textured.frag"
);
// Load the main font
assetFontLoad(&poker->font, "fonts/opensans/OpenSans-Bold.ttf");
// Initialize the render stuffs.
pokerFrameInit(poker, &engine->render);
pokerWorldInit(poker);
pokerCardInit(poker);
pokerPlayerInit(poker);
pokerTalkInit(poker);
// Hand over to the deal for the first time.
pokerMatchInit(poker);
}
void pokerUpdate(poker_t *poker, engine_t *engine) {
// Game Logic
switch(poker->round) {
case POKER_ROUND_MATCH:
pokerMatchUpdate(poker);
break;
case POKER_ROUND_BET0:
case POKER_ROUND_BET1:
case POKER_ROUND_BET2:
case POKER_ROUND_BET3:
pokerBetUpdate(poker);
break;
default:
break;
}
shaderUse(&poker->shader);
pokerFrameWorld(poker, &engine->render);
pokerWorldRender(poker);
for(uint8_t pi = 0; pi < POKER_PLAYER_COUNT; pi++) {
uint8_t seat = pokerPlayerGetSeatForPlayer(pi);
pokerPlayerRender(poker, poker->players + pi, seat);
}
pokerFrameGui(poker, &engine->render);
pokerTalkRender(poker, &engine->input);
poker->textLastWidth = poker->guiWidth;
}
void pokerDispose(poker_t * poker) {
pokerTalkDispose(poker);
pokerWorldDispose(poker);
shaderDispose(&poker->shader);
}