Working on the Player UI
This commit is contained in:
@ -31,10 +31,13 @@ bool pokerGameInit(pokergame_t *game) {
|
||||
}
|
||||
|
||||
void pokerGameUpdate(pokergame_t *game, engine_t *engine) {
|
||||
|
||||
// Update the VN Engine.
|
||||
vnSceneUpdate(&game->scene, engine);
|
||||
|
||||
// Update the UI
|
||||
pokerUiUpdate(game, engine);
|
||||
|
||||
|
||||
// Bind the shader.
|
||||
shaderUse(&game->assets.shader);
|
||||
|
||||
|
@ -32,12 +32,7 @@ void pokerWorldInit(pokergame_t *game) {
|
||||
|
||||
void pokerWorldLookAtPlayer(vnscene_t *scene, uint8_t playerIndex) {
|
||||
uint8_t seat;
|
||||
seat = (
|
||||
playerIndex == POKER_DEALER_INDEX ?
|
||||
POKER_GAME_SEAT_DEALER :
|
||||
POKER_GAME_SEAT_FOR_PLAYER(playerIndex)
|
||||
);
|
||||
|
||||
seat = pokerGameSeatFromIndex(playerIndex);
|
||||
scene->cameraLookX = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||
scene->cameraLookZ = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||
}
|
||||
|
@ -9,6 +9,55 @@
|
||||
|
||||
void pokerPlayerUiInit(pokerplayerui_t *ui) {
|
||||
labelInit(&ui->label);
|
||||
|
||||
frameBufferInit(&ui->frame,
|
||||
POKER_PLAYER_UI_IMAGE_RESOLUTION, POKER_PLAYER_UI_IMAGE_RESOLUTION
|
||||
);
|
||||
|
||||
quadInit(&ui->quad, 0,
|
||||
0, 0, 0, 1,
|
||||
POKER_PLAYER_UI_IMAGE_SIZE, POKER_PLAYER_UI_IMAGE_SIZE, 1, 0
|
||||
);
|
||||
}
|
||||
|
||||
void pokerPlayerUiUpdate(
|
||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex,
|
||||
engine_t *engine
|
||||
) {
|
||||
|
||||
camera_t camera;
|
||||
uint8_t seat;
|
||||
float x, y, z;
|
||||
|
||||
// Bind the frame buffer
|
||||
frameBufferUse(&ui->frame, true);
|
||||
|
||||
// Set up the camera perspective
|
||||
cameraPerspective(&camera, 45,
|
||||
(float)POKER_PLAYER_UI_IMAGE_SIZE / (float)POKER_PLAYER_UI_IMAGE_SIZE,
|
||||
0.03f, 10.0f
|
||||
);
|
||||
|
||||
// Locate the XYZ position of the camera to look at the player
|
||||
seat = pokerGameSeatFromIndex(playerIndex);
|
||||
x = POKER_WORLD_SEAT_POSITION_X(seat);
|
||||
y = POKER_PLAYER_UI_IMAGE_Y;
|
||||
z = POKER_WORLD_SEAT_POSITION_Z(seat);
|
||||
|
||||
// Actually look at the player, we need to get close.
|
||||
cameraLookAt(&camera,
|
||||
x * POKER_PLAYER_UI_IMAGE_DIST, y, z * POKER_PLAYER_UI_IMAGE_DIST,
|
||||
x, y, z
|
||||
);
|
||||
|
||||
// Render the VN character
|
||||
shaderUse(shader);
|
||||
shaderUseCamera(shader, &camera);
|
||||
shaderUsePosition(shader, 0,0,0, 0,0,0);
|
||||
vnCharacterRender(game->scene.characters + playerIndex, shader);
|
||||
|
||||
// Unbind the frame buffer.
|
||||
frameBufferUnbind(&engine->render, false);
|
||||
}
|
||||
|
||||
void pokerPlayerUiRender(
|
||||
@ -22,13 +71,20 @@ void pokerPlayerUiRender(
|
||||
scale = fontGetScale(FONT_SIZE_DEFAULT);
|
||||
player = game->poker.players + playerIndex;
|
||||
|
||||
// Render Face
|
||||
shaderUseTexture(shader, &ui->frame.texture);
|
||||
shaderUsePosition(shader, x - POKER_PLAYER_UI_IMAGE_SIZE,y,0, 0,0,0);
|
||||
primitiveDraw(&ui->quad, 0, -1);
|
||||
|
||||
// Move everything left a bit.
|
||||
x -= POKER_PLAYER_UI_IMAGE_SIZE + POKER_PLAYER_UI_PADDING;
|
||||
y += (POKER_PLAYER_UI_IMAGE_SIZE - (FONT_LINE_HEIGHT * scale * 2)) / 2.0f;
|
||||
|
||||
// Render chips
|
||||
sprintf(buffer, "$%i", player->chips);
|
||||
labelSetText(&ui->label, font, buffer);
|
||||
labelRender(&ui->label, shader, x - ui->label.info.width, y);
|
||||
|
||||
// Render Face
|
||||
|
||||
// Render state
|
||||
if(player->state & POKER_PLAYER_STATE_OUT) {
|
||||
sprintf(buffer, "Out");
|
||||
@ -48,5 +104,7 @@ void pokerPlayerUiRender(
|
||||
}
|
||||
|
||||
void pokerPlayerUiDispose(pokerplayerui_t *ui) {
|
||||
primitiveDispose(&ui->quad);
|
||||
frameBufferDispose(&ui->frame);
|
||||
labelDispose(&ui->label);
|
||||
}
|
@ -10,11 +10,19 @@
|
||||
#include "../../../ui/label.h"
|
||||
#include "../../../ui/image.h"
|
||||
#include "../../../display/framebuffer.h"
|
||||
#include "../../../display/primitive.h"
|
||||
#include "../../../display/primitives/quad.h"
|
||||
#include "../../../display/primitives/cube.h"
|
||||
#include "../../../display/camera.h"
|
||||
|
||||
#include "../../../vn/vncharacter.h"
|
||||
|
||||
void pokerPlayerUiInit(pokerplayerui_t *ui);
|
||||
|
||||
void pokerPlayerUiUpdate(
|
||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, int32_t playerIndex,
|
||||
engine_t *engine
|
||||
);
|
||||
|
||||
void pokerPlayerUiRender(
|
||||
pokerplayerui_t *ui, pokergame_t *game, shader_t *shader, font_t *font,
|
||||
int32_t playerIndex, float x, float y
|
||||
|
@ -15,6 +15,17 @@ void pokerUiInit(pokergame_t *pokerGame) {
|
||||
}
|
||||
}
|
||||
|
||||
void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine) {
|
||||
uint8_t i;
|
||||
pokerplayerui_t *ui;
|
||||
|
||||
for(i = 0; i < POKER_PLAYER_COUNT; i++) {
|
||||
ui = pokerGame->ui.player + i;
|
||||
|
||||
pokerPlayerUiUpdate(ui, pokerGame, &pokerGame->assets.shader, i, engine);
|
||||
}
|
||||
}
|
||||
|
||||
void pokerUiRender(pokergame_t *pokerGame, engine_t *engine) {
|
||||
uint8_t i;
|
||||
pokerplayerui_t *ui;
|
||||
|
@ -17,6 +17,14 @@
|
||||
*/
|
||||
void pokerUiInit(pokergame_t *pokerGame);
|
||||
|
||||
/**
|
||||
* Update the Poker Game UI.
|
||||
*
|
||||
* @param pokerGame Game to update.
|
||||
* @param engine Engine to use for updating.
|
||||
*/
|
||||
void pokerUiUpdate(pokergame_t *pokerGame, engine_t *engine);
|
||||
|
||||
/**
|
||||
* Render the Poker Game UI.
|
||||
*
|
||||
|
Reference in New Issue
Block a user