Playing around with talking and input
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#define INPUT_DOWN (inputbind_t)0x81
|
||||
#define INPUT_LEFT (inputbind_t)0x82
|
||||
#define INPUT_RIGHT (inputbind_t)0x83
|
||||
#define INPUT_ACCEPT (inputbind_t)0x84
|
||||
|
||||
|
||||
#define INPUT_BIND_COUNT 0xFF
|
||||
|
@ -15,13 +15,7 @@ bool gameInit(game_t *game) {
|
||||
engineInit(&game->engine, game);
|
||||
|
||||
// Hand off to the poker logic.
|
||||
pokerInit(&game->poker, &game->engine.render);
|
||||
|
||||
// char *text = "Ayy\nNice meme";
|
||||
// fonttextinfo_t info = fontGetTextInfo(&font, text);
|
||||
// fontmeasure_t *measure = fontTextMeasure(&font, text, &info);
|
||||
// fontTextInitFromMeasure(&font, &quad, text, &info, measure);
|
||||
// fontTextMeasureDispose(measure);
|
||||
pokerInit(&game->poker, &game->engine);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -31,7 +25,7 @@ bool gameUpdate(game_t *game, float platformDelta) {
|
||||
engineUpdateStart(&game->engine, game, platformDelta);
|
||||
|
||||
// Hand off to the poker logic
|
||||
pokerUpdate(&game->poker, &game->engine.render);
|
||||
pokerUpdate(&game->poker, &game->engine);
|
||||
|
||||
// Hand back to the engine.
|
||||
return engineUpdateEnd(&game->engine, game);
|
||||
|
@ -63,6 +63,9 @@ int32_t main() {
|
||||
inputBind(input, INPUT_DOWN, (inputsource_t)GLFW_KEY_S);
|
||||
inputBind(input, INPUT_LEFT, (inputsource_t)GLFW_KEY_A);
|
||||
inputBind(input, INPUT_RIGHT, (inputsource_t)GLFW_KEY_D);
|
||||
inputBind(input, INPUT_ACCEPT, (inputsource_t)GLFW_KEY_E);
|
||||
inputBind(input, INPUT_ACCEPT, (inputsource_t)GLFW_KEY_ENTER);
|
||||
inputBind(input, INPUT_ACCEPT, (inputsource_t)GLFW_KEY_SPACE);
|
||||
|
||||
// Init the render resolution
|
||||
renderSetResolution(&game->engine.render,
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "poker.h"
|
||||
|
||||
void pokerInit(poker_t *poker, render_t *render) {
|
||||
void pokerInit(poker_t *poker, engine_t *engine) {
|
||||
// Load the main shader
|
||||
assetShaderLoad(&poker->shader,
|
||||
"shaders/textured.vert", "shaders/textured.frag"
|
||||
@ -17,7 +17,7 @@ void pokerInit(poker_t *poker, render_t *render) {
|
||||
assetFontLoad(&poker->font, "fonts/opensans/OpenSans-Bold.ttf");
|
||||
|
||||
// Initialize the render stuffs.
|
||||
pokerFrameInit(poker, render);
|
||||
pokerFrameInit(poker, &engine->render);
|
||||
pokerWorldInit(poker);
|
||||
pokerCardInit(poker);
|
||||
pokerPlayerInit(poker);
|
||||
@ -27,7 +27,7 @@ void pokerInit(poker_t *poker, render_t *render) {
|
||||
pokerMatchInit(poker);
|
||||
}
|
||||
|
||||
void pokerUpdate(poker_t *poker, render_t *render) {
|
||||
void pokerUpdate(poker_t *poker, engine_t *engine) {
|
||||
// Game Logic
|
||||
switch(poker->round) {
|
||||
case POKER_ROUND_MATCH:
|
||||
@ -39,15 +39,15 @@ void pokerUpdate(poker_t *poker, render_t *render) {
|
||||
|
||||
// Rendering
|
||||
shaderUse(&poker->shader);
|
||||
pokerFrameWorld(poker, render);
|
||||
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, render);
|
||||
pokerTalkRender(poker);
|
||||
pokerFrameGui(poker, &engine->render);
|
||||
pokerTalkRender(poker, &engine->input);
|
||||
|
||||
poker->textLastWidth = poker->guiWidth;
|
||||
}
|
||||
|
@ -24,16 +24,16 @@
|
||||
/**
|
||||
* Initializes the poker context for the first time.
|
||||
* @param poker Poker context to initialize.
|
||||
* @param render Rendering context.
|
||||
* @param engine Rendering context.
|
||||
*/
|
||||
void pokerInit(poker_t *poker, render_t *render);
|
||||
void pokerInit(poker_t *poker, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Updates the poker context.
|
||||
* @param poker Poker game to update.
|
||||
* @param render Render manager to use.
|
||||
* @param poker Poker game context.
|
||||
* @param engine Engine that is running the game.
|
||||
*/
|
||||
void pokerUpdate(poker_t *poker, render_t *render);
|
||||
void pokerUpdate(poker_t *poker, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Cleans an existing poker game instance.
|
||||
|
@ -25,6 +25,7 @@ void pokerTalkTextRebuffer(poker_t *poker) {
|
||||
if(poker->talkTextInfo != NULL) {
|
||||
fontTextInfoDispose(poker->talkTextInfo);
|
||||
primitiveDispose(&poker->talkPrimitive);
|
||||
poker->talkTextInfo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,7 +36,7 @@ void pokerTalkTextRebuffer(poker_t *poker) {
|
||||
fontTextInit(&poker->font, &poker->talkPrimitive, poker->talkTextInfo);
|
||||
}
|
||||
|
||||
void pokerTalkRender(poker_t *poker) {
|
||||
void pokerTalkRender(poker_t *poker, input_t *input) {
|
||||
pokerTalkTextRebuffer(poker);
|
||||
if(poker->talkTextInfo == NULL) return;
|
||||
|
||||
@ -46,8 +47,14 @@ void pokerTalkRender(poker_t *poker) {
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
bool pokerTalkIsTalking(poker_t *poker) {
|
||||
return poker->talkTextInfo != NULL;
|
||||
}
|
@ -10,13 +10,44 @@
|
||||
#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);
|
||||
|
||||
void pokerTalkRender(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);
|
@ -42,4 +42,5 @@ void pokerDealInit(poker_t *poker) {
|
||||
poker->deck[y] = poker->deck[x];// Move my card there
|
||||
poker->deck[x] = temporary;// Put other card here.
|
||||
}
|
||||
printf("Deal\n");
|
||||
}
|
@ -26,5 +26,6 @@ void pokerMatchInit(poker_t *poker) {
|
||||
}
|
||||
|
||||
void pokerMatchUpdate(poker_t *poker) {
|
||||
|
||||
if(pokerTalkIsTalking(poker)) return;
|
||||
pokerDealInit(poker);
|
||||
}
|
Reference in New Issue
Block a user