Restored some of the rendering
This commit is contained in:
15
temp/poker/card.c
Normal file
15
temp/poker/card.c
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "card.h"
|
||||
|
||||
void cardDeal(card_t *deck, card_t *hand, uint8_t deckSize, uint8_t handSize) {
|
||||
card_t card;
|
||||
card = deck[deckSize-1];
|
||||
deck[deckSize-1] = 0x00;
|
||||
hand[handSize] = card;
|
||||
}
|
34
temp/poker/card.h
Normal file
34
temp/poker/card.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>
|
||||
|
||||
/**
|
||||
* Fills a deck with a standard set of cards (unshuffled)
|
||||
*
|
||||
* @param deck Deck to fill. Must be at least 52 elements.
|
||||
*/
|
||||
void cardDeckFill(card_t *deck);
|
||||
|
||||
/**
|
||||
* Shuffles the given hand or deck.
|
||||
*
|
||||
* @param hand The hand/deck to shuffle.
|
||||
* @param cardCount The amount of cards that are in that deck/hand.
|
||||
*/
|
||||
void cardShuffle(card_t *hand, uint8_t cardCount);
|
||||
|
||||
/**
|
||||
* Deals a card of the top of the deck into the given hand.
|
||||
*
|
||||
* @param deck Deck to take from.
|
||||
* @param hand Hand to put into.
|
||||
* @param deckSize Size of the current deck.
|
||||
* @param handSize Size of the current hand.
|
||||
*/
|
||||
void cardDeal(card_t *deck, card_t *hand, uint8_t deckSize, uint8_t handSize);
|
42
temp/poker/poker.c
Normal file
42
temp/poker/poker.c
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "poker.h"
|
||||
|
||||
void pokerInit(poker_t *poker) {
|
||||
uint8_t x;
|
||||
|
||||
// Prepare the initial game state
|
||||
poker->round = POKER_ROUND_DEAL;
|
||||
poker->roundPlayer = 0x00;
|
||||
poker->roundDealer = 0x00;
|
||||
poker->blindSmall = 0;
|
||||
poker->blindBig = 0;
|
||||
|
||||
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||
poker->players[x].state = 0x00;
|
||||
poker->players[x].chips = 0;
|
||||
poker->players[x].cardCount = 0;
|
||||
poker->players[x].currentBet = 0;
|
||||
}
|
||||
|
||||
pokerRoundInit(poker);
|
||||
}
|
||||
|
||||
void pokerRoundInit(poker_t *poker) {
|
||||
uint8_t x;
|
||||
|
||||
// Refill the deck
|
||||
cardDeckFill(poker->deck);
|
||||
poker->deckSize = CARD_DECK_SIZE;
|
||||
|
||||
// Reset the players
|
||||
for(x = 0; x < POKER_PLAYER_COUNT; x++) {
|
||||
poker->players[x].cardCount = 0;
|
||||
poker->players[x].currentBet = 0;
|
||||
}
|
||||
}
|
25
temp/poker/poker.h
Normal file
25
temp/poker/poker.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 "card.h"
|
||||
|
||||
/**
|
||||
* Initializes the poker match for the first time.
|
||||
*
|
||||
* @param poker Poker game to init.
|
||||
*/
|
||||
void pokerInit(poker_t *poker);
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the round for a poker game.
|
||||
*
|
||||
* @param poker Poker game to init a new round for.
|
||||
*/
|
||||
void pokerRoundInit(poker_t *poker);
|
95
temp/render/card.c
Normal file
95
temp/render/card.c
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "card.h"
|
||||
|
||||
void holdemRenderCardInit() {
|
||||
tilesetdiv_t *cardBack;
|
||||
|
||||
// Load Cards Texture
|
||||
GAME_STATE.cardTexture = assetTextureLoad("cards_normal.png");
|
||||
GAME_STATE.cardTileset = tilesetCreate(CARD_COUNT_PER_SUIT, 6,
|
||||
GAME_STATE.cardTexture->width, GAME_STATE.cardTexture->height,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
|
||||
// Cards Primitive
|
||||
cardBack = GAME_STATE.cardTileset->divisions+(
|
||||
GAME_STATE.cardTileset->columns * 4
|
||||
);
|
||||
GAME_STATE.cardPrimitive = primitiveCreate(
|
||||
QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2
|
||||
);
|
||||
quadBuffer(GAME_STATE.cardPrimitive, -HOLDEM_GAME_CARD_DEPTH,
|
||||
-HOLDEM_GAME_CARD_WIDTH, -HOLDEM_GAME_CARD_HEIGHT,
|
||||
cardBack->x0, cardBack->y1,
|
||||
HOLDEM_GAME_CARD_WIDTH, HOLDEM_GAME_CARD_HEIGHT,
|
||||
cardBack->x1, cardBack->y0,
|
||||
QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT
|
||||
);
|
||||
}
|
||||
|
||||
pokerposition_t holdemRenderCardGetPosition(uint8_t seat, uint8_t slot) {
|
||||
pokerposition_t position;
|
||||
float t, t2;
|
||||
|
||||
position.yaw = HOLDEM_GAME_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 HOLDEM_GAME_CARD_SLOT_HAND0:
|
||||
case HOLDEM_GAME_CARD_SLOT_HAND1:
|
||||
t2 = HOLDEM_GAME_CARD_WIDTH+HOLDEM_GAME_CARD_PADDING;
|
||||
if(slot == HOLDEM_GAME_CARD_SLOT_HAND0) t2 = -t2;
|
||||
t2 += 0.1;
|
||||
break;
|
||||
|
||||
case HOLDEM_GAME_CARD_SLOT_FLOP0:
|
||||
case HOLDEM_GAME_CARD_SLOT_FLOP1:
|
||||
case HOLDEM_GAME_CARD_SLOT_FLOP2:
|
||||
case HOLDEM_GAME_CARD_SLOT_FLOP3:
|
||||
case HOLDEM_GAME_CARD_SLOT_FLOP4:
|
||||
t2 = HOLDEM_GAME_CARD_WIDTH*2+HOLDEM_GAME_CARD_PADDING;
|
||||
t2 = (
|
||||
-t2 * ( HOLDEM_GAME_CARD_SLOT_FLOP4-HOLDEM_GAME_CARD_SLOT_FLOP0)
|
||||
)/2 + t2*(slot-HOLDEM_GAME_CARD_SLOT_FLOP0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
position.x += t2 * sin(t);
|
||||
position.z += t2 * cos(t);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void holdemRenderCard(card_t card, float x, float y, float z,
|
||||
float pitch, float yaw, float roll
|
||||
) {
|
||||
tilesetdiv_t *cardFront = GAME_STATE.cardTileset->divisions + card;
|
||||
quadBuffer(GAME_STATE.cardPrimitive, HOLDEM_GAME_CARD_DEPTH,
|
||||
-HOLDEM_GAME_CARD_WIDTH, -HOLDEM_GAME_CARD_HEIGHT,
|
||||
cardFront->x0, cardFront->y1,
|
||||
HOLDEM_GAME_CARD_WIDTH, HOLDEM_GAME_CARD_HEIGHT,
|
||||
cardFront->x1, cardFront->y0,
|
||||
0, 0
|
||||
);
|
||||
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.cardTexture);
|
||||
shaderUsePosition(GAME_STATE.shaderWorld, x,y,z, pitch,yaw,roll);
|
||||
primitiveDraw(GAME_STATE.cardPrimitive, 0, -1);
|
||||
}
|
||||
|
||||
void holdemRenderCardForSeat(uint8_t seat, card_t card, uint8_t slot) {
|
||||
pokerposition_t position = holdemRenderCardGetPosition(seat, slot);
|
||||
holdemRenderCard(card, position.x, 0, position.z, mathDeg2Rad(-90), position.yaw, 0);
|
||||
}
|
53
temp/render/card.h
Normal file
53
temp/render/card.h
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void holdemRenderCardInit();
|
||||
|
||||
/**
|
||||
* 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 holdemRenderCardGetPosition(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 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 holdemRenderCard(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 seat Seat the card is for.
|
||||
* @param card Card to render.
|
||||
* @param slot Slot the card is for.
|
||||
*/
|
||||
void holdemRenderCardForSeat(uint8_t seat, card_t card, uint8_t slot);
|
46
temp/render/chip.c
Normal file
46
temp/render/chip.c
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "chip.h"
|
||||
|
||||
void holdemRenderChipSet(int32_t count,float x,float y,float z,float yaw) {
|
||||
shaderUsePositionAndScale(GAME_STATE.shaderWorld,
|
||||
x, y, z,
|
||||
0, yaw, 0,
|
||||
0.2, 0.2, 0.2
|
||||
);
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.chipTexture);
|
||||
primitiveDraw(GAME_STATE.chipPrimitive, 0, -1);
|
||||
}
|
||||
|
||||
pokerposition_t holdemRenderChipGetPosition(uint8_t seat) {
|
||||
pokerposition_t position;
|
||||
float t, t2;
|
||||
|
||||
position.yaw = HOLDEM_GAME_SEAT_ANGLE(seat);
|
||||
position.x = sin(position.yaw) * -0.675;
|
||||
position.z = cos(position.yaw) * -0.675;
|
||||
|
||||
t = position.yaw + mathDeg2Rad(90);
|
||||
|
||||
t2 = -0.175;
|
||||
position.x += t2 * sin(t);
|
||||
position.z += t2 * cos(t);
|
||||
return position;
|
||||
}
|
||||
|
||||
void holdemRenderChipInit() {
|
||||
GAME_STATE.chipPrimitive = pokerChipCreate();
|
||||
GAME_STATE.chipTexture = assetTextureLoad("pokerchip.png");
|
||||
}
|
||||
|
||||
void holdemRenderChip() {
|
||||
for(uint8_t seat = 0; seat < 0x08; seat++) {
|
||||
pokerposition_t position = holdemRenderChipGetPosition(HOLDEM_GAME_SEAT_PLAYER0);
|
||||
holdemRenderChipSet(0, position.x, 0.05, position.z, position.yaw);
|
||||
}
|
||||
}
|
42
temp/render/chip.h
Normal file
42
temp/render/chip.h
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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/pokerchip.h"
|
||||
#include "../../file/asset.h"
|
||||
#include "../../display/shader.h"
|
||||
#include "../../display/texture.h"
|
||||
|
||||
/**
|
||||
* Renders a stack of chips at a position.
|
||||
*
|
||||
* @param count Count of chips to render (Determines the stack size).
|
||||
* @param x X position of the stack.
|
||||
* @param y Y position of the stack.
|
||||
* @param z Z position of the stack.
|
||||
* @param yaw Rotation (YAW) of the chips.
|
||||
*/
|
||||
void holdemRenderChipSet(int32_t count,float x,float y,float z,float yaw);
|
||||
|
||||
/**
|
||||
* Get the position for a stack of chips based on a seat.
|
||||
*
|
||||
* @param seat Seat to get the position for.
|
||||
* @return Position for the seat that the chips should render to.
|
||||
*/
|
||||
pokerposition_t holdemRenderChipGetPosition(uint8_t seat);
|
||||
|
||||
/**
|
||||
* Init the poker chips renderer for each player.
|
||||
*/
|
||||
void holdemRenderChipInit();
|
||||
|
||||
/**
|
||||
* Render the poker chips.
|
||||
*/
|
||||
void holdemRenderChip();
|
103
temp/render/frame.c
Normal file
103
temp/render/frame.c
Normal file
@ -0,0 +1,103 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "frame.h"
|
||||
|
||||
void holdemRenderFrameInit() {
|
||||
int32_t lWidth, rWidth, height;
|
||||
|
||||
// Prepare the two frame buffers.
|
||||
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
||||
height = HOLDEM_GAME_FRAME_HEIGHT;
|
||||
GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
||||
GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
||||
GAME_STATE.quadLeft = quadCreate(0, 0, 0, 0, 0, lWidth, height, 1, 1);
|
||||
GAME_STATE.quadRight = quadCreate(0, 0, 0, 0, 0, rWidth, height, 1, 1);
|
||||
}
|
||||
|
||||
void holdemRenderFrameUpdate() {
|
||||
int32_t lWidth, rWidth, height;
|
||||
|
||||
lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH;
|
||||
height = HOLDEM_GAME_FRAME_HEIGHT;
|
||||
if((
|
||||
GAME_STATE.frameLeft->texture->width == lWidth &&
|
||||
GAME_STATE.frameLeft->texture->height == height
|
||||
)) return;
|
||||
|
||||
// Recreate frame buffers.
|
||||
frameBufferDispose(GAME_STATE.frameLeft);
|
||||
frameBufferDispose(GAME_STATE.frameRight);
|
||||
GAME_STATE.frameLeft = frameBufferCreate(lWidth, height);
|
||||
GAME_STATE.frameRight = frameBufferCreate(rWidth, height);
|
||||
quadBuffer(GAME_STATE.quadLeft, 0,
|
||||
0, 0, 0, 1,
|
||||
lWidth, height, 1, 0,
|
||||
0, 0
|
||||
);
|
||||
quadBuffer(GAME_STATE.quadRight, 0,
|
||||
0, 0, 0, 1,
|
||||
rWidth, height, 1, 0,
|
||||
0, 0
|
||||
);
|
||||
}
|
||||
|
||||
void holdemRenderFrameUseLeft() {
|
||||
glClearColor(0.3, 0, 0, 1);
|
||||
frameBufferUse(GAME_STATE.frameLeft, true);
|
||||
cameraPerspective(&GAME_STATE.cameraLeft, 35,
|
||||
(
|
||||
(float)GAME_STATE.frameLeft->texture->width /
|
||||
(float)GAME_STATE.frameLeft->texture->height
|
||||
), 0.2f, 1000.0f
|
||||
);
|
||||
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraLeft);
|
||||
}
|
||||
|
||||
void holdemRenderFrameUseRight() {
|
||||
glClearColor(0.3, 0.3, 0, 1);
|
||||
frameBufferUse(GAME_STATE.frameRight, true);
|
||||
|
||||
cameraPerspective(&GAME_STATE.cameraRight, 45,
|
||||
(
|
||||
(float)GAME_STATE.frameRight->texture->width /
|
||||
(float)GAME_STATE.frameRight->texture->height
|
||||
), 0.2f, 1000.0f
|
||||
);
|
||||
cameraLookAt(&GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0);
|
||||
|
||||
// cameraPerspective(&GAME_STATE.cameraRight, 15,
|
||||
// (
|
||||
// (float)GAME_STATE.frameRight->texture->width /
|
||||
// (float)GAME_STATE.frameRight->texture->height
|
||||
// ), 0.2f, 1000.0f
|
||||
// );
|
||||
// cameraLookAt(&GAME_STATE.cameraRight, 0, 1, -8, 0, 0, 0);
|
||||
|
||||
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraRight);
|
||||
}
|
||||
|
||||
void holdemRenderFrameBack() {
|
||||
glClearColor(0, 0, 0, 1);
|
||||
frameBufferUse(NULL, true);
|
||||
cameraOrtho(&GAME_STATE.cameraMain, 0,
|
||||
RENDER_STATE.width, RENDER_STATE.height, 1, 0, 1
|
||||
);
|
||||
cameraLookAt(&GAME_STATE.cameraMain, 0, 0, 0.5f, 0, 0, 0);
|
||||
shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraMain);
|
||||
shaderUsePosition(GAME_STATE.shaderWorld,
|
||||
0, 0, 0, 0, 0, 0
|
||||
);
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.frameLeft->texture);
|
||||
primitiveDraw(GAME_STATE.quadLeft, 0, -1);
|
||||
shaderUsePosition(GAME_STATE.shaderWorld,
|
||||
RENDER_STATE.width - GAME_STATE.frameRight->texture->width,
|
||||
0, 0, 0, 0, 0
|
||||
);
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.frameRight->texture);
|
||||
primitiveDraw(GAME_STATE.quadRight, 0, -1);
|
||||
}
|
41
temp/render/frame.h
Normal file
41
temp/render/frame.h
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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/shader.h"
|
||||
#include "../../display/primitive.h"
|
||||
#include "../../display/primitives/quad.h"
|
||||
#include "../../display/framebuffer.h"
|
||||
#include "../../display/camera.h"
|
||||
|
||||
/**
|
||||
* Initializes the frame buffers to be rendered to later.
|
||||
*/
|
||||
void holdemRenderFrameInit();
|
||||
|
||||
/**
|
||||
* Update the frame buffers at the start of a rendering cycle.
|
||||
*/
|
||||
void holdemRenderFrameUpdate();
|
||||
|
||||
/**
|
||||
* Binds the left frame buffer, clears it, and corrects its camera's
|
||||
* perspective.
|
||||
*/
|
||||
void holdemRenderFrameUseLeft();
|
||||
|
||||
/**
|
||||
* Binds the right frame buffer, clears it, and corrects its camera's
|
||||
* perspective.
|
||||
*/
|
||||
void holdemRenderFrameUseRight();
|
||||
|
||||
/**
|
||||
* Renders both the left and right frames to the backbuffer.
|
||||
*/
|
||||
void holdemRenderFrameBack();
|
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 holdemRenderLookSeat(camera_t *camera, uint8_t seat) {
|
||||
float x, z, angle;
|
||||
angle = HOLDEM_GAME_SEAT_ANGLE(seat);
|
||||
x = sin(angle);
|
||||
z = cos(angle);
|
||||
cameraLookAt(&GAME_STATE.cameraLeft,
|
||||
x, 0.2, z,
|
||||
-x, 0.2, -z
|
||||
);
|
||||
}
|
||||
|
||||
void holdemRenderLookHand(camera_t *camera, uint8_t seat) {
|
||||
float x, z, angle;
|
||||
angle = HOLDEM_GAME_SEAT_ANGLE(seat);
|
||||
x = sin(angle);
|
||||
z = cos(angle);
|
||||
cameraLookAt(&GAME_STATE.cameraLeft,
|
||||
x*0.1, 0.8, z*0.1,
|
||||
-x*0.5, 0.2, -z*0.5
|
||||
);
|
||||
}
|
25
temp/render/look.h
Normal file
25
temp/render/look.h
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 seat
|
||||
*
|
||||
* @param camera Camera to adjust.
|
||||
* @param seat Seat to look at.
|
||||
*/
|
||||
void holdemRenderLookSeat(camera_t *camera, uint8_t seat);
|
||||
|
||||
/**
|
||||
* Look at a specific seats hand.
|
||||
*
|
||||
* @param camera Camera to adjust.
|
||||
* @param seat Seats hand to look at.
|
||||
*/
|
||||
void holdemRenderLookHand(camera_t *camera, uint8_t seat);
|
71
temp/render/player.c
Normal file
71
temp/render/player.c
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "player.h"
|
||||
|
||||
void holdemRenderPlayerInit(poker_t *poker) {
|
||||
|
||||
|
||||
GAME_STATE.kagamiTexture = assetTextureLoad("kagami.png");
|
||||
GAME_STATE.kagamiTileset = tilesetCreate(3, 2,
|
||||
GAME_STATE.kagamiTexture->width,
|
||||
GAME_STATE.kagamiTexture->height,
|
||||
0, 0, 0, 0
|
||||
);
|
||||
GAME_STATE.kagamiQuad = quadCreate(0, 0, 0, 0, 0, 1, 1, 1, 1);
|
||||
}
|
||||
|
||||
uint8_t holdemRenderPlayerGetSeatForPlayer(uint8_t player) {
|
||||
switch(player) {
|
||||
case 0x01:
|
||||
return HOLDEM_GAME_SEAT_PLAYER1;
|
||||
case 0x02:
|
||||
return HOLDEM_GAME_SEAT_PLAYER2;
|
||||
case 0x03:
|
||||
return HOLDEM_GAME_SEAT_PLAYER3;
|
||||
case 0x04:
|
||||
return HOLDEM_GAME_SEAT_PLAYER4;
|
||||
default:
|
||||
return HOLDEM_GAME_SEAT_PLAYER0;
|
||||
}
|
||||
}
|
||||
|
||||
void holdemRenderPlayer(uint8_t seat) {
|
||||
float x, z, angle;
|
||||
|
||||
// Determine position
|
||||
angle = HOLDEM_GAME_SEAT_ANGLE(seat);
|
||||
x = sin(angle) * -1;
|
||||
z = cos(angle) * -1;
|
||||
|
||||
// Determine size
|
||||
float w, h;
|
||||
w = 0.6, h = (
|
||||
(float)GAME_STATE.kagamiTileset->divY /
|
||||
(float)GAME_STATE.kagamiTileset->divX
|
||||
) * w;
|
||||
|
||||
// Animation
|
||||
int i = (int32_t)(TIME_STATE.current*10)%GAME_STATE.kagamiTileset->count;
|
||||
quadBuffer(GAME_STATE.kagamiQuad, 0,
|
||||
-w/2, -h/2,
|
||||
GAME_STATE.kagamiTileset->divisions[i].x0,
|
||||
GAME_STATE.kagamiTileset->divisions[i].y1,
|
||||
w/2, h/2,
|
||||
GAME_STATE.kagamiTileset->divisions[i].x1,
|
||||
GAME_STATE.kagamiTileset->divisions[i].y0,
|
||||
0, 0
|
||||
);
|
||||
|
||||
// Render
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.kagamiTexture);
|
||||
shaderUsePosition(GAME_STATE.shaderWorld,
|
||||
x, 0.34, z,
|
||||
0, angle, 0
|
||||
);
|
||||
primitiveDraw(GAME_STATE.kagamiQuad, 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.
|
||||
*/
|
||||
void holdemRenderPlayerInit();
|
||||
|
||||
/**
|
||||
* 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 holdemRenderPlayerGetSeatForPlayer(uint8_t player);
|
||||
|
||||
/**
|
||||
* Render's a player at a seat.
|
||||
*
|
||||
* @param seat Seat to render the player at.
|
||||
*/
|
||||
void holdemRenderPlayer(uint8_t seat);
|
53
temp/render/world.c
Normal file
53
temp/render/world.c
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "world.h"
|
||||
|
||||
void holdemRenderWorldInit() {
|
||||
GAME_STATE.tablePrimitive = pokerTableCreate();
|
||||
GAME_STATE.tableTexture = assetTextureLoad("pokertable.png");
|
||||
}
|
||||
|
||||
void holdemRenderWorld() {
|
||||
uint8_t i, j;
|
||||
pokerplayer_t *player;
|
||||
uint8_t seat;
|
||||
|
||||
// Poker Table
|
||||
shaderUsePositionAndScale(GAME_STATE.shaderWorld,
|
||||
0, -0.01, 0,
|
||||
0, 0, 0,
|
||||
3.4, 3.4, 3.4
|
||||
);
|
||||
shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.tableTexture);
|
||||
primitiveDraw(GAME_STATE.tablePrimitive, 0, -1);
|
||||
|
||||
// Render the dealer and her hand
|
||||
holdemRenderPlayer(HOLDEM_GAME_SEAT_DEALER);
|
||||
for(i = 0x00; i < GAME_STATE.cardsFacing; i++) {
|
||||
holdemRenderCardForSeat(
|
||||
HOLDEM_GAME_SEAT_DEALER,
|
||||
GAME_STATE.cards[i],
|
||||
HOLDEM_GAME_CARD_SLOT_FLOP0 + i
|
||||
);
|
||||
}
|
||||
|
||||
// Test
|
||||
for(i = 0x00; i < POKER_PLAYER_COUNT; i++) {
|
||||
player = GAME_STATE.players + i;
|
||||
seat = holdemRenderPlayerGetSeatForPlayer(i);
|
||||
holdemRenderPlayer(seat);
|
||||
|
||||
if(player->state & POKER_PLAYER_STATE_SHOWING) continue;
|
||||
|
||||
for(j = 0x00; j < player->cardCount; j++) {
|
||||
holdemRenderCardForSeat(seat, player->cards[j], HOLDEM_GAME_CARD_SLOT_HAND0+j);
|
||||
}
|
||||
}
|
||||
|
||||
holdemRenderChip();
|
||||
}
|
23
temp/render/world.h
Normal file
23
temp/render/world.h
Normal file
@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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 "player.h"
|
||||
#include "card.h"
|
||||
#include "chip.h"
|
||||
#include "../../assets/models/pokertable.h"
|
||||
|
||||
/**
|
||||
* Initializes the world renderer.
|
||||
*/
|
||||
void holdemRenderWorldInit();
|
||||
|
||||
/**
|
||||
* Renders the world.
|
||||
*/
|
||||
void holdemRenderWorld();
|
Reference in New Issue
Block a user