Roughing talk logic
This commit is contained in:
7
IDEA.md
7
IDEA.md
@ -1,7 +1,2 @@
|
|||||||
- Make font measure take in a pointer to a primitive to offer auto buffering of verts
|
- Make font measure take in a pointer to a primitive to offer auto buffering of verts
|
||||||
- Make a clone of the string into font measure pointing only to real chars?
|
- Make a clone of the string into font measure pointing only to real chars?
|
||||||
|
|
||||||
- How to do text wrapping efficiently?
|
|
||||||
- Two pointers, one for current char and one for the last known text position.
|
|
||||||
- Start by measuring whole string, this will give me n chars and let me know straight away if text fits
|
|
||||||
- Half divide the pointer to try and find the mid point and figure out if I should go up or down, keep halfing until finding the below then iterate up
|
|
@ -42,6 +42,7 @@
|
|||||||
#include "poker/player.h"
|
#include "poker/player.h"
|
||||||
#include "poker/poker.h"
|
#include "poker/poker.h"
|
||||||
#include "poker/render.h"
|
#include "poker/render.h"
|
||||||
|
#include "poker/strings.h"
|
||||||
|
|
||||||
// Utility Objects
|
// Utility Objects
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
|
@ -80,11 +80,18 @@ typedef struct {
|
|||||||
/** Rendering Assets */
|
/** Rendering Assets */
|
||||||
framebuffer_t frameWorld;
|
framebuffer_t frameWorld;
|
||||||
framebuffer_t frameGui;
|
framebuffer_t frameGui;
|
||||||
|
|
||||||
font_t font;
|
font_t font;
|
||||||
shader_t shader;
|
shader_t shader;
|
||||||
camera_t cameraWorld;
|
camera_t cameraWorld;
|
||||||
camera_t cameraGui;
|
camera_t cameraGui;
|
||||||
|
|
||||||
|
/** Talk related */
|
||||||
|
float lastWidth, lastHeight;
|
||||||
|
primitive_t talkPrimitive;
|
||||||
|
char *talkText;
|
||||||
|
fonttextinfo_t *talkTextInfo;
|
||||||
|
|
||||||
texture_t dealerTexture;
|
texture_t dealerTexture;
|
||||||
tileset_t dealerTileset;
|
tileset_t dealerTileset;
|
||||||
primitive_t dealerPrimitive;
|
primitive_t dealerPrimitive;
|
||||||
|
11
include/dawn/poker/strings.h
Normal file
11
include/dawn/poker/strings.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2021 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "../libs.h"
|
||||||
|
|
||||||
|
#define POKER_TALK_MATCH_START "The game is no-limits Texas Hold'em."
|
@ -21,6 +21,7 @@ void pokerInit(poker_t *poker, render_t *render) {
|
|||||||
pokerWorldInit(poker);
|
pokerWorldInit(poker);
|
||||||
pokerCardInit(poker);
|
pokerCardInit(poker);
|
||||||
pokerPlayerInit(poker);
|
pokerPlayerInit(poker);
|
||||||
|
pokerTalkInit(poker);
|
||||||
|
|
||||||
// Hand over to the deal for the first time.
|
// Hand over to the deal for the first time.
|
||||||
pokerMatchInit(poker);
|
pokerMatchInit(poker);
|
||||||
@ -46,9 +47,11 @@ void pokerUpdate(poker_t *poker, render_t *render) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pokerFrameGui(poker, render);
|
pokerFrameGui(poker, render);
|
||||||
|
pokerTalkRender(poker, render);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerDispose(poker_t * poker) {
|
void pokerDispose(poker_t * poker) {
|
||||||
|
pokerTalkDispose(poker);
|
||||||
pokerWorldDispose(poker);
|
pokerWorldDispose(poker);
|
||||||
shaderDispose(&poker->shader);
|
shaderDispose(&poker->shader);
|
||||||
}
|
}
|
@ -14,6 +14,7 @@
|
|||||||
#include "render/card.h"
|
#include "render/card.h"
|
||||||
#include "render/player.h"
|
#include "render/player.h"
|
||||||
#include "render/look.h"
|
#include "render/look.h"
|
||||||
|
#include "render/talk.h"
|
||||||
|
|
||||||
#include "../file/asset.h"
|
#include "../file/asset.h"
|
||||||
#include "../display/shader.h"
|
#include "../display/shader.h"
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
primitive_t bruh;
|
|
||||||
|
|
||||||
void pokerFrameInit(poker_t *poker, render_t *render) {
|
void pokerFrameInit(poker_t *poker, render_t *render) {
|
||||||
frameBufferInit(&poker->frameWorld, render->width, render->height);
|
frameBufferInit(&poker->frameWorld, render->width, render->height);
|
||||||
frameBufferInit(&poker->frameGui, render->width, render->height);
|
frameBufferInit(&poker->frameGui, render->width, render->height);
|
||||||
|
|
||||||
fonttextinfo_t *info;
|
// fonttextinfo_t *info;
|
||||||
char *text = "Hello world how are you today? I'm doing fine myself.";
|
// char *text = "Hello world how are you today? I'm doing fine myself.";
|
||||||
info = fontTextClamp(&poker->font, text, 16, 500);
|
// info = fontTextClamp(&poker->font, text, 16, 500);
|
||||||
fontTextInit(&poker->font, &bruh, info);
|
// fontTextInit(&poker->font, &bruh, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerFrameWorld(poker_t *poker, render_t *render) {
|
void pokerFrameWorld(poker_t *poker, render_t *render) {
|
||||||
@ -44,8 +42,4 @@ void pokerFrameGui(poker_t *poker, render_t *render) {
|
|||||||
);
|
);
|
||||||
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
|
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
|
||||||
shaderUseCamera(&poker->shader, &poker->cameraGui);
|
shaderUseCamera(&poker->shader, &poker->cameraGui);
|
||||||
|
|
||||||
shaderUsePosition(&poker->shader, 0,0,0, 0,0,0);
|
|
||||||
shaderUseTexture(&poker->shader, &poker->font.texture);
|
|
||||||
primitiveDraw(&bruh, 0, -1);
|
|
||||||
}
|
}
|
@ -5,4 +5,47 @@
|
|||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "talk.h"
|
#include "talk.h"
|
||||||
|
#define SCALE 16
|
||||||
|
|
||||||
|
void pokerTalkInit(poker_t *poker) {
|
||||||
|
poker->talkText = NULL;
|
||||||
|
poker->talkTextInfo = NULL;
|
||||||
|
poker->lastWidth = 0, poker->lastHeight = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerTalkDispose(poker_t *poker) {
|
||||||
|
if(poker->talkTextInfo == NULL) return;
|
||||||
|
fontTextInfoDispose(poker->talkTextInfo);
|
||||||
|
primitiveDispose(&poker->talkPrimitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerTalkTextRebuffer(poker_t *poker, render_t *render) {
|
||||||
|
// Check if we need to force a redraw or not.
|
||||||
|
if(poker->talkText == NULL || poker->lastWidth != render->width) {
|
||||||
|
if(poker->talkTextInfo != NULL) {
|
||||||
|
fontTextInfoDispose(poker->talkTextInfo);
|
||||||
|
primitiveDispose(&poker->talkPrimitive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(poker->talkText == NULL) return;
|
||||||
|
|
||||||
|
// Rebuffer
|
||||||
|
poker->talkTextInfo = fontTextClamp(&poker->font, poker->talkText, SCALE,
|
||||||
|
render->width
|
||||||
|
);
|
||||||
|
fontTextInit(&poker->font, &poker->talkPrimitive, poker->talkTextInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerTalkRender(poker_t *poker, render_t *render) {
|
||||||
|
pokerTalkTextRebuffer(poker, render);
|
||||||
|
|
||||||
|
if(poker->talkTextInfo == NULL) return;
|
||||||
|
shaderUsePosition(&poker->shader, 0,0,0, 0,0,0);
|
||||||
|
shaderUseTexture(&poker->shader, &poker->font.texture);
|
||||||
|
primitiveDraw(&poker->talkPrimitive, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokerTalk(poker_t *poker, char *text) {
|
||||||
|
poker->talkText = text;
|
||||||
|
}
|
@ -8,4 +8,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "../../display/gui/font.h"
|
#include "../../display/gui/font.h"
|
||||||
#include "../../display/primitive.h"
|
#include "../../display/primitive.h"
|
||||||
|
#include "../../display/shader.h"
|
||||||
|
|
||||||
|
void pokerTalkInit(poker_t *poker);
|
||||||
|
|
||||||
|
void pokerTalkDispose(poker_t *poker);
|
||||||
|
|
||||||
|
void pokerTalkTextRebuffer(poker_t *poker, render_t *render);
|
||||||
|
|
||||||
|
void pokerTalkRender(poker_t *poker, render_t *render);
|
||||||
|
|
||||||
|
void pokerTalk(poker_t *poker, char *text);
|
@ -22,7 +22,7 @@ void pokerMatchInit(poker_t *poker) {
|
|||||||
poker->players[x].chips = POKER_PLAYER_CHIPS_DEFAULT;
|
poker->players[x].chips = POKER_PLAYER_CHIPS_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Match start\n");
|
pokerTalk(poker, POKER_TALK_MATCH_START);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pokerMatchUpdate(poker_t *poker) {
|
void pokerMatchUpdate(poker_t *poker) {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
#include "deal.h"
|
#include "deal.h"
|
||||||
#include "../render/look.h"
|
#include "../render/look.h"
|
||||||
|
#include "../render/talk.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init the poker match round.
|
* Init the poker match round.
|
||||||
|
Reference in New Issue
Block a user