Refactoring some of the poker game logic again.
This commit is contained in:
45
temp/frame.c
Normal file
45
temp/frame.c
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "frame.h"
|
||||
|
||||
void pokerFrameInit(poker_t *poker, render_t *render) {
|
||||
frameBufferInit(&poker->frameWorld, render->width, render->height);
|
||||
frameBufferInit(&poker->frameGui, render->width, render->height);
|
||||
}
|
||||
|
||||
void pokerFrameWorld(poker_t *poker, render_t *render) {
|
||||
// Update the frame buffer
|
||||
frameBufferResize(&poker->frameWorld, render->width, render->height);
|
||||
|
||||
// Correct the aspect on the perspective camera for the world
|
||||
cameraPerspective(&poker->cameraWorld, 20,
|
||||
render->width / render->height,
|
||||
0.001, 1000
|
||||
);
|
||||
shaderUseCamera(&poker->shader, &poker->cameraWorld);
|
||||
}
|
||||
|
||||
void pokerFrameGui(poker_t *poker, render_t *render) {
|
||||
// Update FB
|
||||
frameBufferResize(&poker->frameGui, render->width, render->height);
|
||||
poker->guiWidth = ((float)POKER_GUI_HEIGHT/render->height) * render->width;
|
||||
// frameBufferUse(&poker->frameGui, true);
|
||||
|
||||
// Correct aspect on the ortho camera
|
||||
cameraOrtho(&poker->cameraGui,
|
||||
0, poker->guiWidth,
|
||||
POKER_GUI_HEIGHT, 0,
|
||||
0.01, 100
|
||||
);
|
||||
cameraLookAt(&poker->cameraGui, 0, 0, 5, 0, 0, 0);
|
||||
shaderUseCamera(&poker->shader, &poker->cameraGui);
|
||||
}
|
||||
|
||||
void pokerFrameRender(poker_t *poker, render_t *render) {
|
||||
|
||||
}
|
43
temp/frame.h
Normal file
43
temp/frame.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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/framebuffer.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../display/camera.h"
|
||||
#include "../../display/primitives/quad.h"
|
||||
|
||||
#include "../../display/gui/font.h"
|
||||
|
||||
/**
|
||||
* Initializes the various frame buffers for the poker game.
|
||||
*
|
||||
* @param poker Poker game to initialize for
|
||||
* @param render Rendering context.
|
||||
*/
|
||||
void pokerFrameInit(poker_t *poker, render_t *render);
|
||||
|
||||
/**
|
||||
* Bind the world frame, this will also correct the camera angles.
|
||||
*
|
||||
* @param poker Poker game context.
|
||||
* @param render Rendering engine context.
|
||||
*/
|
||||
void pokerFrameWorld(poker_t *poker, render_t *render);
|
||||
|
||||
/**
|
||||
* Bind the frame for GUI rendering.
|
||||
*
|
||||
* @param poker Poker game context.
|
||||
* @param render Rendering engine context.
|
||||
*/
|
||||
void pokerFrameGui(poker_t *poker, render_t *render);
|
||||
|
||||
void pokerFrameTest(poker_t *poker, render_t *render);
|
54
temp/render.h
Normal file
54
temp/render.h
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
|
||||
#include "../display/tileset.h"
|
||||
#include "../display/primitive.h"
|
||||
#include "../display/texture.h"
|
||||
#include "../display/shader.h"
|
||||
#include "../display/camera.h"
|
||||
#include "../display/spritebatch.h"
|
||||
|
||||
/** Size of the Render frames */
|
||||
#define POKER_FRAME_HEIGHT RENDER_STATE.height
|
||||
#define POKER_FRAME_LEFT_WIDTH RENDER_STATE.width*0.65
|
||||
#define POKER_FRAME_RIGHT_WIDTH (\
|
||||
RENDER_STATE.width - POKER_FRAME_LEFT_WIDTH - 1\
|
||||
)
|
||||
|
||||
/** Size of the rendered card */
|
||||
#define POKER_CARD_WIDTH 0.04
|
||||
#define POKER_CARD_HEIGHT POKER_CARD_WIDTH/2.5*3.5
|
||||
#define POKER_CARD_DEPTH 0.0005
|
||||
#define POKER_CARD_PADDING 0.0125
|
||||
|
||||
/** Macro for the angle (Yaw) that the seat has */
|
||||
#define POKER_SEAT_ANGLE(seat) mathDeg2Rad(-45 * seat)
|
||||
|
||||
/** Slots where cards can render */
|
||||
#define POKER_CARD_SLOT_HAND0 0x00
|
||||
#define POKER_CARD_SLOT_HAND1 0x01
|
||||
#define POKER_CARD_SLOT_FLOP0 0x02
|
||||
#define POKER_CARD_SLOT_FLOP1 0x03
|
||||
#define POKER_CARD_SLOT_FLOP2 0x04
|
||||
#define POKER_CARD_SLOT_FLOP3 0x05
|
||||
#define POKER_CARD_SLOT_FLOP4 0x06
|
||||
|
||||
/** Various seats at the table that people can sit */
|
||||
#define POKER_SEAT_DEALER 0x00
|
||||
#define POKER_SEAT_PLAYER0 0x04
|
||||
#define POKER_SEAT_PLAYER1 0x06
|
||||
#define POKER_SEAT_PLAYER2 0x05
|
||||
#define POKER_SEAT_PLAYER3 0x03
|
||||
#define POKER_SEAT_PLAYER4 0x02
|
||||
|
||||
typedef struct {
|
||||
float x, z;
|
||||
float yaw;
|
||||
} pokerposition_t;
|
99
temp/render/card.c
Normal file
99
temp/render/card.c
Normal file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "card.h"
|
||||
|
||||
void pokerCardInit(poker_t *poker) {
|
||||
tilesetdiv_t *cardBack;
|
||||
|
||||
// Load Cards Texture
|
||||
assetTextureLoad(&poker->cardTexture, "cards_normal.png");
|
||||
tilesetInit(&poker->cardTileset,
|
||||
CARD_COUNT_PER_SUIT, 6,
|
||||
poker->cardTexture.width, poker->cardTexture.height,
|
||||
0, 0,
|
||||
0, 0
|
||||
);
|
||||
|
||||
// Cards Primitive
|
||||
cardBack = poker->cardTileset.divisions+(poker->cardTileset.columns * 4);
|
||||
primitiveInit(&poker->cardPrimitive,
|
||||
QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2
|
||||
);
|
||||
quadBuffer(&poker->cardPrimitive, -POKER_CARD_DEPTH,
|
||||
-POKER_CARD_WIDTH, -POKER_CARD_HEIGHT,
|
||||
cardBack->x0, cardBack->y1,
|
||||
POKER_CARD_WIDTH, POKER_CARD_HEIGHT,
|
||||
cardBack->x1, cardBack->y0,
|
||||
QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT
|
||||
);
|
||||
}
|
||||
|
||||
pokerposition_t pokerCardGetPosition(uint8_t seat, uint8_t slot) {
|
||||
pokerposition_t position;
|
||||
float t, t2;
|
||||
|
||||
position.yaw = POKER_SEAT_ANGLE(seat);
|
||||
position.x = sin(position.yaw) * -0.75;
|
||||
position.z = cos(position.yaw) * -0.75;
|
||||
|
||||
t = position.yaw + mathDeg2Rad(90);
|
||||
|
||||
switch (slot) {
|
||||
case POKER_CARD_SLOT_HAND0:
|
||||
case POKER_CARD_SLOT_HAND1:
|
||||
t2 = POKER_CARD_WIDTH+POKER_CARD_PADDING;
|
||||
if(slot == POKER_CARD_SLOT_HAND0) t2 = -t2;
|
||||
t2 += 0.1;
|
||||
break;
|
||||
|
||||
case POKER_CARD_SLOT_FLOP0:
|
||||
case POKER_CARD_SLOT_FLOP1:
|
||||
case POKER_CARD_SLOT_FLOP2:
|
||||
case POKER_CARD_SLOT_FLOP3:
|
||||
case POKER_CARD_SLOT_FLOP4:
|
||||
t2 = POKER_CARD_WIDTH*2+POKER_CARD_PADDING;
|
||||
t2 = (
|
||||
-t2 * ( POKER_CARD_SLOT_FLOP4-POKER_CARD_SLOT_FLOP0)
|
||||
)/2 + t2*(slot-POKER_CARD_SLOT_FLOP0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
position.x += t2 * sin(t);
|
||||
position.z += t2 * cos(t);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void pokerCardRender(poker_t *poker, card_t card, float x, float y, float z,
|
||||
float pitch, float yaw, float roll
|
||||
) {
|
||||
tilesetdiv_t *cardFront = poker->cardTileset.divisions + card;
|
||||
quadBuffer(&poker->cardPrimitive, POKER_CARD_DEPTH,
|
||||
-POKER_CARD_WIDTH, -POKER_CARD_HEIGHT,
|
||||
cardFront->x0, cardFront->y1,
|
||||
POKER_CARD_WIDTH, POKER_CARD_HEIGHT,
|
||||
cardFront->x1, cardFront->y0,
|
||||
0, 0
|
||||
);
|
||||
|
||||
shaderUseTexture(&poker->shader, &poker->cardTexture);
|
||||
shaderUsePosition(&poker->shader, x,y,z, pitch,yaw,roll);
|
||||
primitiveDraw(&poker->cardPrimitive, 0, -1);
|
||||
}
|
||||
|
||||
void pokerCardRenderForSeat(poker_t *poker, uint8_t seat, card_t card, uint8_t slot) {
|
||||
pokerposition_t position = pokerCardGetPosition(seat, slot);
|
||||
pokerCardRender(poker, card,
|
||||
position.x, 0, position.z,
|
||||
mathDeg2Rad(-90), position.yaw, 0
|
||||
);
|
||||
}
|
55
temp/render/card.h
Normal file
55
temp/render/card.h
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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 "../../file/asset.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/primitives/quad.h"
|
||||
#include "../../display/tileset.h"
|
||||
|
||||
/**
|
||||
* Initializes the Card Renderer.
|
||||
* @param poker The poker game context.
|
||||
*/
|
||||
void pokerCardInit(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Returns the position a card "naturally" sits at for a given seat and slot.
|
||||
*
|
||||
* @param seat Seat that the card belongs to
|
||||
* @param slot Slot within the player/dealers' hand that the card belongs to.
|
||||
* @return A struct containing X, Z and YAW properties.
|
||||
*/
|
||||
pokerposition_t pokerCardGetPosition(uint8_t seat, uint8_t slot);
|
||||
|
||||
/**
|
||||
* Render's a given card at the specified coordinates. Card is a reused quad
|
||||
* and is re-buffered to for every draw call.
|
||||
*
|
||||
* @param poker The poker game context.
|
||||
* @param card Card to render.
|
||||
* @param x X Position (world space).
|
||||
* @param y Y Position (world space).
|
||||
* @param z Z Position (world space).
|
||||
* @param pitch Pitch angle.
|
||||
* @param yaw Yaw angle.
|
||||
* @param roll Roll angle.
|
||||
*/
|
||||
void pokerCardRender(poker_t *poker, card_t card, float x, float y, float z,
|
||||
float pitch, float yaw, float roll
|
||||
);
|
||||
|
||||
/**
|
||||
* Render's a card at a given seat and slot.
|
||||
* @param poker The poker game context.
|
||||
* @param seat Seat the card is for.
|
||||
* @param card Card to render.
|
||||
* @param slot Slot the card is for.
|
||||
*/
|
||||
void pokerCardRenderForSeat(poker_t *poker, uint8_t seat, card_t card, uint8_t slot);
|
30
temp/render/look.c
Normal file
30
temp/render/look.c
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "look.h"
|
||||
|
||||
void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance) {
|
||||
float x, z, angle;
|
||||
angle = POKER_SEAT_ANGLE(seat);
|
||||
x = sin(angle) * (0.8 + distance);
|
||||
z = cos(angle) * (0.8 + distance);
|
||||
cameraLookAt(camera,
|
||||
x, 0.3, z,
|
||||
-x, 0.3, -z
|
||||
);
|
||||
}
|
||||
|
||||
void pokerLookAtHand(camera_t *camera, uint8_t seat) {
|
||||
float x, z, angle;
|
||||
angle = POKER_SEAT_ANGLE(seat);
|
||||
x = sin(angle);
|
||||
z = cos(angle);
|
||||
cameraLookAt(camera,
|
||||
x*0.1, 0.8, z*0.1,
|
||||
-x*0.5, 0.2, -z*0.5
|
||||
);
|
||||
}
|
26
temp/render/look.h
Normal file
26
temp/render/look.h
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include <dawn/dawn.h>
|
||||
#include "../../display/camera.h"
|
||||
|
||||
/**
|
||||
* Look at a specific seats' player.
|
||||
*
|
||||
* @param camera Camera to adjust.
|
||||
* @param seat Seat to look at.
|
||||
* @param distance Distance from the seat to look from. 0 is default.
|
||||
*/
|
||||
void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance);
|
||||
|
||||
/**
|
||||
* Look at a specific seats' hand.
|
||||
*
|
||||
* @param camera Camera to adjust.
|
||||
* @param seat Seats hand to look at.
|
||||
*/
|
||||
void pokerLookAtHand(camera_t *camera, uint8_t seat);
|
68
temp/render/player.c
Normal file
68
temp/render/player.c
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "player.h"
|
||||
|
||||
void pokerPlayerInit(poker_t *poker) {
|
||||
uint8_t i;
|
||||
pokerplayer_t *player;
|
||||
float w, h;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
player = poker->players + i;
|
||||
assetTextureLoad(&player->bodyTexture, "characters/penny/textures/body.png");
|
||||
assetTextureLoad(&player->faceTexture, "characters/penny/textures/face.png");
|
||||
|
||||
w = 0.6;
|
||||
h=((float)player->faceTexture.width)/((float)player->faceTexture.height)*w;
|
||||
w = w / 2;
|
||||
h = h / 2;
|
||||
quadInit(&player->bodyPrimitive, 0,
|
||||
-w, -h, 0, 1,
|
||||
w, h, 1, 0
|
||||
);
|
||||
quadInit(&player->facePrimitive, 0,
|
||||
-w, -h, 0, 1,
|
||||
w, h, 1, 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t pokerPlayerGetSeatForPlayer(uint8_t player) {
|
||||
switch(player) {
|
||||
case 0x01:
|
||||
return POKER_SEAT_PLAYER1;
|
||||
case 0x02:
|
||||
return POKER_SEAT_PLAYER2;
|
||||
case 0x03:
|
||||
return POKER_SEAT_PLAYER3;
|
||||
case 0x04:
|
||||
return POKER_SEAT_PLAYER4;
|
||||
default:
|
||||
return POKER_SEAT_PLAYER0;
|
||||
}
|
||||
}
|
||||
|
||||
void pokerPlayerRender(poker_t* poker, pokerplayer_t *player, uint8_t seat) {
|
||||
float x, z, angle;
|
||||
float w, h;
|
||||
|
||||
// Determine position
|
||||
angle = POKER_SEAT_ANGLE(seat);
|
||||
x = sin(angle) * -1;
|
||||
z = cos(angle) * -1;
|
||||
|
||||
shaderUsePosition(&poker->shader, x,0.34,z, 0,angle,0);
|
||||
|
||||
// Render Body
|
||||
shaderUseTexture(&poker->shader, &player->bodyTexture);
|
||||
primitiveDraw(&player->bodyPrimitive, 0, -1);
|
||||
|
||||
// Render Face
|
||||
shaderUseTexture(&poker->shader, &player->faceTexture);
|
||||
primitiveDraw(&player->facePrimitive, 0, -1);
|
||||
}
|
34
temp/render/player.h
Normal file
34
temp/render/player.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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 "../../file/asset.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/tileset.h"
|
||||
#include "../../display/primitives/quad.h"
|
||||
|
||||
/**
|
||||
* Initializes the player renderer.
|
||||
* @param poker Poker game context.
|
||||
*/
|
||||
void pokerPlayerInit(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Returns the seat index for a given player.
|
||||
* @param player Player to get the seat for.
|
||||
* @return Seat ID for the given player.
|
||||
*/
|
||||
uint8_t pokerPlayerGetSeatForPlayer(uint8_t player);
|
||||
|
||||
/**
|
||||
* Render's a player at a seat.
|
||||
* @param poker Poker game context.
|
||||
* @param seat Seat to render the player at.
|
||||
*/
|
||||
void pokerPlayerRender(poker_t *poker, pokerplayer_t *player, uint8_t seat);
|
30
temp/render/world.c
Normal file
30
temp/render/world.c
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "world.h"
|
||||
|
||||
void pokerWorldInit(poker_t *poker) {
|
||||
// Poker Table
|
||||
pokerTableInit(&poker->tablePrimitive);
|
||||
assetTextureLoad(&poker->tableTexture, "pokertable.png");
|
||||
}
|
||||
|
||||
void pokerWorldRender(poker_t *poker) {
|
||||
// Poker Table
|
||||
shaderUsePositionAndScale(&poker->shader,
|
||||
0, -0.01, 0,
|
||||
0, 0, 0,
|
||||
3.4, 3.4, 3.4
|
||||
);
|
||||
shaderUseTexture(&poker->shader, &poker->tableTexture);
|
||||
primitiveDraw(&poker->tablePrimitive, 0, -1);
|
||||
}
|
||||
|
||||
void pokerWorldDispose(poker_t *poker) {
|
||||
textureDispose(&poker->tableTexture);
|
||||
primitiveDispose(&poker->tablePrimitive);
|
||||
}
|
32
temp/render/world.h
Normal file
32
temp/render/world.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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 "../../assets/models/pokertable.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../file/asset.h"
|
||||
|
||||
/**
|
||||
* Initializes the world renderer.
|
||||
* @param poker Poker scene to initialize.
|
||||
*/
|
||||
void pokerWorldInit(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Renders the world.
|
||||
* @param poker Poker scene to render.
|
||||
*/
|
||||
void pokerWorldRender(poker_t *poker);
|
||||
|
||||
/**
|
||||
* Disposes a poker world.
|
||||
* @param poker Poker game to cleanup the world for.
|
||||
*/
|
||||
void pokerWorldDispose(poker_t *poker);
|
63
temp/talk.c
63
temp/talk.c
@ -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;
|
||||
}
|
53
temp/talk.h
53
temp/talk.h
@ -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);
|
Reference in New Issue
Block a user