Still working on my scrolling text and bug fixing.

This commit is contained in:
2021-07-16 22:26:04 -07:00
parent 06202f6f7e
commit f619b7c9d2
26 changed files with 495 additions and 115 deletions

View File

@ -13,15 +13,12 @@ void pokerInit(poker_t *poker, engine_t *engine) {
"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);
// pokerTalkInit(poker);
// Hand over to the deal for the first time.
pokerMatchInit(poker, engine);
@ -53,13 +50,11 @@ void pokerUpdate(poker_t *poker, engine_t *engine) {
}
pokerFrameGui(poker, &engine->render);
pokerTalkRender(poker, &engine->input);
poker->textLastWidth = poker->guiWidth;
// pokerTalkRender(poker, &engine->input);
}
void pokerDispose(poker_t * poker) {
pokerTalkDispose(poker);
// pokerTalkDispose(poker);
pokerWorldDispose(poker);
shaderDispose(&poker->shader);
}

View File

@ -14,7 +14,6 @@
#include "render/card.h"
#include "render/player.h"
#include "render/look.h"
#include "render/talk.h"
#include "../file/asset.h"
#include "../display/shader.h"

View File

@ -1,63 +0,0 @@
/**
* Copyright (c) 2021 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "talk.h"
void pokerTalkInit(poker_t *poker) {
poker->talkText = NULL;
poker->talkTextInfo = NULL;
poker->textLastWidth = 0;
}
void pokerTalkDispose(poker_t *poker) {
if(poker->talkTextInfo == NULL) return;
fontTextInfoDispose(poker->talkTextInfo);
primitiveDispose(&poker->talkPrimitive);
}
void pokerTalkTextRebuffer(poker_t *poker) {
// Check if we need to force a redraw or not.
if(poker->talkText == NULL || poker->textLastWidth != poker->guiWidth) {
if(poker->talkTextInfo != NULL) {
fontTextInfoDispose(poker->talkTextInfo);
primitiveDispose(&poker->talkPrimitive);
poker->talkTextInfo = NULL;
}
}
if(poker->talkText == NULL) return;
// Rebuffer
poker->talkTextInfo = fontTextClamp(&poker->font, poker->talkText, poker->guiWidth);
fontTextInit(&poker->font, &poker->talkPrimitive, poker->talkTextInfo);
}
void pokerTalkRender(poker_t *poker, input_t *input) {
pokerTalkTextRebuffer(poker);
if(poker->talkTextInfo == NULL) return;
// Render text
shaderUsePosition(&poker->shader,
0,POKER_GUI_HEIGHT-poker->talkTextInfo->height,0,
0,0,0
);
shaderUseTexture(&poker->shader, &poker->font.texture);
primitiveDraw(&poker->talkPrimitive, 0, -1);
if(inputIsPressed(input, INPUT_ACCEPT)) {
poker->talkText = NULL;
}
}
void pokerTalk(poker_t *poker, char *text) {
poker->talkText = text;
poker->roundTextCounter++;
}
bool pokerTalkIsTalking(poker_t *poker) {
return poker->talkText != NULL || poker->talkTextInfo != NULL;
}

View File

@ -1,53 +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 "../../display/gui/font.h"
#include "../../display/primitive.h"
#include "../../display/shader.h"
#include "../../input/input.h"
/**
* Initializes the talk manager.
* @param poker The poker game context.
*/
void pokerTalkInit(poker_t *poker);
/**
* Disposes and cleans the talk manager context.
* @param poker Poker instance.
*/
void pokerTalkDispose(poker_t *poker);
/**
* Internal method. Checks for changes and rebuffers the talk text information
* when scene changes occur.
* @param poker Poker game context to buffer for.
*/
void pokerTalkTextRebuffer(poker_t *poker);
/**
* Tick render method for the poker talk manager.
* @param poker Poker manager context.
* @param input Input manager to listen to.
*/
void pokerTalkRender(poker_t *poker, input_t *input);
/**
* Requests the talk manager to begin speaking some text.
* @param poker Poker game context
* @param text Text to speak. Please ensure this is kept alive during talk.
*/
void pokerTalk(poker_t *poker, char *text);
/**
* Returns true if the poker text manager is still running the talk.
* @param poker Poker manager.
* @returns True while the game is still running active text.
*/
bool pokerTalkIsTalking(poker_t *poker);

View File

@ -32,8 +32,4 @@ void pokerMatchUpdate(poker_t *poker, engine_t *engine) {
pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_PLAYER0, (
t < 1 ? 1 - easeOutQuart(t) : 0
));
if(t > 0.75) {
pokerTalk(poker, "Hello World");
}
}

View File

@ -9,7 +9,6 @@
#include <dawn/dawn.h>
#include "start.h"
#include "../render/look.h"
#include "../render/talk.h"
/**
* Init the poker match round.