From a97933d366921475d5f9234fe773a93d0baf7da4 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 17 May 2021 06:43:48 -0700 Subject: [PATCH] Nuked Poker State --- include/dawn/game/game.h | 70 +++++++++++++++++++++++++++++++++++-- include/dawn/poker/player.h | 4 +-- include/dawn/poker/poker.h | 56 +---------------------------- src/game/game.c | 11 +++--- src/poker/action/action.c | 32 ++++++++--------- src/poker/action/ai.c | 2 +- src/poker/action/deal.c | 8 ++--- src/poker/action/flop.c | 12 +++---- src/poker/action/round.c | 18 +++++----- src/poker/action/shuffle.c | 2 +- src/poker/action/start.c | 8 ++--- src/poker/render/card.c | 22 ++++++------ src/poker/render/frame.c | 62 ++++++++++++++++---------------- src/poker/render/look.c | 4 +-- src/poker/render/player.c | 30 ++++++++-------- src/poker/render/world.c | 16 ++++----- temp/src/world/world.c | 2 +- 17 files changed, 185 insertions(+), 174 deletions(-) diff --git a/include/dawn/game/game.h b/include/dawn/game/game.h index 4402406b..244e4a8e 100644 --- a/include/dawn/game/game.h +++ b/include/dawn/game/game.h @@ -7,18 +7,84 @@ #include "../libs.h" #include "../display/shader.h" #include "../display/camera.h" +#include "../poker/poker.h" +#include "../poker/card.h" +#include "../poker/player.h" +#include "../poker/render.h" +#include "../poker/action.h" +#include "../display/render.h" +#include "../display/spritebatch.h" +#include "../display/texture.h" +#include "../display/tileset.h" +#include "../display/framebuffer.h" /** Name of the current game */ #define GAME_NAME "Dawn" /** Describes the current game */ typedef struct { - /** Describes the name of a specific game. */ + /** Describes the name of the specific game. */ char *name; /** World Rendering stuff. */ shader_t *shaderWorld; - camera_t cameraWorld; + camera_t cameraMain; + + + + + + + + /** Current Card Deck */ + card_t deck[CARD_DECK_SIZE]; + /** Count of cards in the deck */ + uint8_t deckSize; + + /** How big is the current small blind */ + uint32_t blindSmall; + /** How big is the current big blind */ + uint32_t blindBig; + /** Current round pot */ + uint32_t pot; + + /** Cards that have been dealt */ + card_t cards[HOLDEM_DEALER_HAND]; + /** How many dealt cards are face up */ + uint8_t cardsFacing; + + /** Player States */ + pokerplayer_t players[POKER_PLAYER_COUNT]; + + + texture_t *kagamiTexture; + tileset_t *kagamiTileset; + primitive_t *kagamiQuad; + + /** Action and Allocated Data Space */ + pokeraction_t actionQueue[POKER_ACTION_QUEUE_SIZE]; + void *actionData[POKER_ACTION_DATA_SIZE*POKER_ACTION_QUEUE_SIZE]; + bool actionInitState[POKER_ACTION_DATA_SIZE]; + + /** Poker Table */ + primitive_t *tablePrimitive; + texture_t *tableTexture; + + texture_t *cardTexture; + tileset_t *cardTileset; + primitive_t *cardPrimitive; + + texture_t *fontTexture; + tileset_t *fontTileset; + spritebatch_t *fontBatch; + + /** Game Render Frames */ + framebuffer_t *frameLeft; + framebuffer_t *frameRight; + primitive_t *quadLeft; + primitive_t *quadRight; + camera_t cameraLeft; + camera_t cameraRight; } game_t; /** The current running game state. */ diff --git a/include/dawn/poker/player.h b/include/dawn/poker/player.h index d60b61f8..c85b039f 100644 --- a/include/dawn/poker/player.h +++ b/include/dawn/poker/player.h @@ -15,10 +15,10 @@ #define POKER_PLAYER_COUNT 5 /** State for whether or not a player has folded */ -#define POKER_STATE_FOLDED 0x01 +#define GAME_STATE_FOLDED 0x01 /** State for whether or not a player is showing their hand */ -#define POKER_STATE_SHOWING 0x02 +#define GAME_STATE_SHOWING 0x02 /** Poker Player State */ typedef struct { diff --git a/include/dawn/poker/poker.h b/include/dawn/poker/poker.h index 595c9d48..2480fc96 100644 --- a/include/dawn/poker/poker.h +++ b/include/dawn/poker/poker.h @@ -36,58 +36,4 @@ #define HOLDEM_GAME_CARD_SLOT_FLOP1 0x03 #define HOLDEM_GAME_CARD_SLOT_FLOP2 0x04 #define HOLDEM_GAME_CARD_SLOT_FLOP3 0x05 -#define HOLDEM_GAME_CARD_SLOT_FLOP4 0x06 - -typedef struct { - /** Current Card Deck */ - card_t deck[CARD_DECK_SIZE]; - /** Count of cards in the deck */ - uint8_t deckSize; - - /** How big is the current small blind */ - uint32_t blindSmall; - /** How big is the current big blind */ - uint32_t blindBig; - /** Current round pot */ - uint32_t pot; - - /** Cards that have been dealt */ - card_t cards[HOLDEM_DEALER_HAND]; - /** How many dealt cards are face up */ - uint8_t cardsFacing; - - /** Player States */ - pokerplayer_t players[POKER_PLAYER_COUNT]; - - - texture_t *kagamiTexture; - tileset_t *kagamiTileset; - primitive_t *kagamiQuad; - - /** Action and Allocated Data Space */ - pokeraction_t actionQueue[POKER_ACTION_QUEUE_SIZE]; - void *actionData[POKER_ACTION_DATA_SIZE*POKER_ACTION_QUEUE_SIZE]; - bool actionInitState[POKER_ACTION_DATA_SIZE]; - - /** Poker Table */ - primitive_t *tablePrimitive; - texture_t *tableTexture; - - texture_t *cardTexture; - tileset_t *cardTileset; - primitive_t *cardPrimitive; - - texture_t *fontTexture; - tileset_t *fontTileset; - spritebatch_t *fontBatch; - - /** Game Render Frames */ - framebuffer_t *frameLeft; - framebuffer_t *frameRight; - primitive_t *quadLeft; - primitive_t *quadRight; - camera_t cameraLeft; - camera_t cameraRight; -} pokergame_t; - -extern pokergame_t POKER_STATE; \ No newline at end of file +#define HOLDEM_GAME_CARD_SLOT_FLOP4 0x06 \ No newline at end of file diff --git a/src/game/game.c b/src/game/game.c index bd6ba897..7eee4e1b 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -8,7 +8,6 @@ #include "game.h" game_t GAME_STATE; -pokergame_t POKER_STATE; bool gameInit() { // Init the game @@ -28,13 +27,13 @@ bool gameInit() { ); // Font - POKER_STATE.fontTexture = assetTextureLoad("font.png"); - POKER_STATE.fontTileset = tilesetCreate(20, 20, - POKER_STATE.fontTexture->width, - POKER_STATE.fontTexture->height, + GAME_STATE.fontTexture = assetTextureLoad("font.png"); + GAME_STATE.fontTileset = tilesetCreate(20, 20, + GAME_STATE.fontTexture->width, + GAME_STATE.fontTexture->height, 1, 1, 1, 1 ); - POKER_STATE.fontBatch = spriteBatchCreate(1024); + GAME_STATE.fontBatch = spriteBatchCreate(1024); // Prepare the renderer. holdemRenderFrameInit(); diff --git a/src/poker/action/action.c b/src/poker/action/action.c index bee8e2e6..b919ec6c 100644 --- a/src/poker/action/action.c +++ b/src/poker/action/action.c @@ -9,12 +9,12 @@ void pokerActionInit() { // Free up all actions - memset(POKER_STATE.actionQueue, (int32_t)NULL, + memset(GAME_STATE.actionQueue, (int32_t)NULL, sizeof(pokeraction_t) * POKER_ACTION_QUEUE_SIZE ); // Free up all data - memset(POKER_STATE.actionData, (int32_t)NULL, sizeof(void *) * + memset(GAME_STATE.actionData, (int32_t)NULL, sizeof(void *) * POKER_ACTION_DATA_SIZE * POKER_ACTION_QUEUE_SIZE ); } @@ -24,29 +24,29 @@ int32_t pokerActionAdd(pokeraction_t action) { int32_t j = -1; for(i = 0; i < POKER_ACTION_QUEUE_SIZE; i++) { - if(POKER_STATE.actionQueue[i].init != NULL) continue; + if(GAME_STATE.actionQueue[i].init != NULL) continue; j = i; break; } if(j == -1) return j; - POKER_STATE.actionQueue[j] = action; - POKER_STATE.actionInitState[j] = false; + GAME_STATE.actionQueue[j] = action; + GAME_STATE.actionInitState[j] = false; return j; } void pokerActionRemove(int32_t index) { - if(POKER_STATE.actionQueue[index].dispose != NULL) { - POKER_STATE.actionQueue[index].dispose( - index, POKER_STATE.actionData + index + if(GAME_STATE.actionQueue[index].dispose != NULL) { + GAME_STATE.actionQueue[index].dispose( + index, GAME_STATE.actionData + index ); } - memset(POKER_STATE.actionQueue+index, (int32_t)NULL, + memset(GAME_STATE.actionQueue+index, (int32_t)NULL, sizeof(pokeraction_t) ); - memset(POKER_STATE.actionData+index, (int32_t)NULL, + memset(GAME_STATE.actionData+index, (int32_t)NULL, sizeof(void *) * POKER_ACTION_DATA_SIZE ); } @@ -57,11 +57,11 @@ void pokerActionUpdate() { pokeraction_t *action; for(i = 0; i < POKER_ACTION_QUEUE_SIZE; i++) { - action = POKER_STATE.actionQueue + i; - data = POKER_STATE.actionData + i; + action = GAME_STATE.actionQueue + i; + data = GAME_STATE.actionData + i; - if(action->init != NULL && !POKER_STATE.actionInitState[i]) { - POKER_STATE.actionInitState[i] = true; + if(action->init != NULL && !GAME_STATE.actionInitState[i]) { + GAME_STATE.actionInitState[i] = true; action->init(i, data); } @@ -74,7 +74,7 @@ void pokerActionUpdate() { void pokerActionDispose() { int32_t i; for(i = 0; i < POKER_ACTION_QUEUE_SIZE; i++) { - if(POKER_STATE.actionQueue[i].dispose == NULL) continue; - POKER_STATE.actionQueue[i].dispose(i, POKER_STATE.actionData+i); + if(GAME_STATE.actionQueue[i].dispose == NULL) continue; + GAME_STATE.actionQueue[i].dispose(i, GAME_STATE.actionData+i); } } \ No newline at end of file diff --git a/src/poker/action/ai.c b/src/poker/action/ai.c index eefa0c47..97024511 100644 --- a/src/poker/action/ai.c +++ b/src/poker/action/ai.c @@ -33,7 +33,7 @@ void actionAiUpdate(int32_t index, void *data) { void actionAiDispose(int32_t index, void *data) { // Do we need to do a flop? - if(POKER_STATE.cardsFacing < HOLDEM_DEALER_HAND) { + if(GAME_STATE.cardsFacing < HOLDEM_DEALER_HAND) { pokerActionAdd(actionFlop()); } } \ No newline at end of file diff --git a/src/poker/action/deal.c b/src/poker/action/deal.c index e0667fff..d080e111 100644 --- a/src/poker/action/deal.c +++ b/src/poker/action/deal.c @@ -22,13 +22,13 @@ void actionDealInit(int32_t index, void *data) { for(i = 0; i < 2; i++) { for(j = 0; j < POKER_PLAYER_COUNT; j++) { - player = POKER_STATE.players + j; - cardDeal(POKER_STATE.deck, + player = GAME_STATE.players + j; + cardDeal(GAME_STATE.deck, player->cards, - POKER_STATE.deckSize, + GAME_STATE.deckSize, player->cardCount ); - POKER_STATE.deckSize--; + GAME_STATE.deckSize--; player->cardCount++; } } diff --git a/src/poker/action/flop.c b/src/poker/action/flop.c index e87eef80..f735ab7a 100644 --- a/src/poker/action/flop.c +++ b/src/poker/action/flop.c @@ -20,22 +20,22 @@ void actionFlopInit(int32_t index, void *data) { logText("Flop"); // Look at the dealer - holdemRenderLookHand(&POKER_STATE.cameraLeft, HOLDEM_GAME_SEAT_DEALER); + holdemRenderLookHand(&GAME_STATE.cameraLeft, HOLDEM_GAME_SEAT_DEALER); // Do the flop // if(match->cardsFacing >= HOLDEM_DEALER_HAND) return; // Burn the card off the top - POKER_STATE.deckSize -= 1; + GAME_STATE.deckSize -= 1; // Change count depending on facing - count = POKER_STATE.cardsFacing == 0 ? 0x03 : 0x01; + count = GAME_STATE.cardsFacing == 0 ? 0x03 : 0x01; // Deal for(i = 0; i < count; i++) { - cardDeal(POKER_STATE.deck, POKER_STATE.cards, POKER_STATE.deckSize, POKER_STATE.cardsFacing); - POKER_STATE.deckSize -= 1; - POKER_STATE.cardsFacing += 1; + cardDeal(GAME_STATE.deck, GAME_STATE.cards, GAME_STATE.deckSize, GAME_STATE.cardsFacing); + GAME_STATE.deckSize -= 1; + GAME_STATE.cardsFacing += 1; } // Next action diff --git a/src/poker/action/round.c b/src/poker/action/round.c index a693c672..e7fef9e0 100644 --- a/src/poker/action/round.c +++ b/src/poker/action/round.c @@ -22,22 +22,22 @@ void actionRoundInit(int32_t index, void *data) { logText("Round Start"); // Look at the dealer. - holdemRenderLookHand(&POKER_STATE.cameraLeft, HOLDEM_GAME_SEAT_DEALER); + holdemRenderLookHand(&GAME_STATE.cameraLeft, HOLDEM_GAME_SEAT_DEALER); // Init the round and shuffle the deck - cardDeckFill(POKER_STATE.deck); - POKER_STATE.deckSize = CARD_DECK_SIZE; - POKER_STATE.pot = 0; - POKER_STATE.cardsFacing = 0; + cardDeckFill(GAME_STATE.deck); + GAME_STATE.deckSize = CARD_DECK_SIZE; + GAME_STATE.pot = 0; + GAME_STATE.cardsFacing = 0; // Reset the players for(i = 0; i < POKER_PLAYER_COUNT; i++) { - player = POKER_STATE.players + i; + player = GAME_STATE.players + i; // Clear Round State(s) player->state &= ~( - POKER_STATE_FOLDED | - POKER_STATE_SHOWING + GAME_STATE_FOLDED | + GAME_STATE_SHOWING ); player->cardCount = 0; @@ -58,6 +58,6 @@ void actionRoundAfterShuffle() { void actionRoundDispose(int32_t index, void *data) { int32_t newI = pokerActionAdd(actionShuffle()); - shuffledata_t *newData=(shuffledata_t *)(POKER_STATE.actionData + newI); + shuffledata_t *newData=(shuffledata_t *)(GAME_STATE.actionData + newI); newData->done = &actionRoundAfterShuffle; } \ No newline at end of file diff --git a/src/poker/action/shuffle.c b/src/poker/action/shuffle.c index d79ac794..f63b42ab 100644 --- a/src/poker/action/shuffle.c +++ b/src/poker/action/shuffle.c @@ -17,7 +17,7 @@ pokeraction_t actionShuffle() { void actionShuffleInit(int32_t index, void *data) { logText("Shuffle Deck"); - cardShuffle(POKER_STATE.deck, POKER_STATE.deckSize); + cardShuffle(GAME_STATE.deck, GAME_STATE.deckSize); pokerActionRemove(index); } diff --git a/src/poker/action/start.c b/src/poker/action/start.c index 7c2f9986..0624fb1e 100644 --- a/src/poker/action/start.c +++ b/src/poker/action/start.c @@ -23,13 +23,13 @@ void actionStartInit(int32_t index, void *data) { logText("Holdem Starting"); // Prepare the match - POKER_STATE.blindBig = 0; - POKER_STATE.blindSmall = 0; - POKER_STATE.pot = 0; + GAME_STATE.blindBig = 0; + GAME_STATE.blindSmall = 0; + GAME_STATE.pot = 0; // Reset the players for(i = 0; i < POKER_PLAYER_COUNT; i++) { - player = POKER_STATE.players + i; + player = GAME_STATE.players + i; player->state = 0x00; player->chips = 0; } diff --git a/src/poker/render/card.c b/src/poker/render/card.c index cb214d6a..866a0181 100644 --- a/src/poker/render/card.c +++ b/src/poker/render/card.c @@ -11,20 +11,20 @@ void holdemRenderCardInit() { tilesetdiv_t *cardBack; // Load Cards Texture - POKER_STATE.cardTexture = assetTextureLoad("cards_normal.png"); - POKER_STATE.cardTileset = tilesetCreate(CARD_COUNT_PER_SUIT, 6, - POKER_STATE.cardTexture->width, POKER_STATE.cardTexture->height, + 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 = POKER_STATE.cardTileset->divisions+( - POKER_STATE.cardTileset->columns * 4 + cardBack = GAME_STATE.cardTileset->divisions+( + GAME_STATE.cardTileset->columns * 4 ); - POKER_STATE.cardPrimitive = primitiveCreate( + GAME_STATE.cardPrimitive = primitiveCreate( QUAD_VERTICE_COUNT * 2, QUAD_INDICE_COUNT * 2 ); - quadBuffer(POKER_STATE.cardPrimitive, -HOLDEM_GAME_CARD_DEPTH, + 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, @@ -74,8 +74,8 @@ pokerposition_t holdemRenderCardGetPosition(uint8_t seat, uint8_t slot) { void holdemRenderCard(card_t card, float x, float y, float z, float pitch, float yaw, float roll ) { - tilesetdiv_t *cardFront = POKER_STATE.cardTileset->divisions + card; - quadBuffer(POKER_STATE.cardPrimitive, HOLDEM_GAME_CARD_DEPTH, + 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, @@ -83,9 +83,9 @@ void holdemRenderCard(card_t card, float x, float y, float z, 0, 0 ); - shaderUseTexture(GAME_STATE.shaderWorld, POKER_STATE.cardTexture); + shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.cardTexture); shaderUsePosition(GAME_STATE.shaderWorld, x,y,z, pitch,yaw,roll); - primitiveDraw(POKER_STATE.cardPrimitive, 0, -1); + primitiveDraw(GAME_STATE.cardPrimitive, 0, -1); } void holdemRenderCardForSeat(uint8_t seat, card_t card, uint8_t slot) { diff --git a/src/poker/render/frame.c b/src/poker/render/frame.c index ba2b341a..72138cc6 100644 --- a/src/poker/render/frame.c +++ b/src/poker/render/frame.c @@ -13,10 +13,10 @@ void holdemRenderFrameInit() { // Prepare the two frame buffers. lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH; height = HOLDEM_GAME_FRAME_HEIGHT; - POKER_STATE.frameLeft = frameBufferCreate(lWidth, height); - POKER_STATE.frameRight = frameBufferCreate(rWidth, height); - POKER_STATE.quadLeft = quadCreate(0, 0, 0, 0, 0, lWidth, height, 1, 1); - POKER_STATE.quadRight = quadCreate(0, 0, 0, 0, 0, rWidth, height, 1, 1); + 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() { @@ -25,21 +25,21 @@ void holdemRenderFrameUpdate() { lWidth = HOLDEM_GAME_FRAME_LEFT_WIDTH, rWidth = HOLDEM_GAME_FRAME_RIGHT_WIDTH; height = HOLDEM_GAME_FRAME_HEIGHT; if(( - POKER_STATE.frameLeft->texture->width == lWidth && - POKER_STATE.frameLeft->texture->height == height + GAME_STATE.frameLeft->texture->width == lWidth && + GAME_STATE.frameLeft->texture->height == height )) return; // Recreate frame buffers. - frameBufferDispose(POKER_STATE.frameLeft); - frameBufferDispose(POKER_STATE.frameRight); - POKER_STATE.frameLeft = frameBufferCreate(lWidth, height); - POKER_STATE.frameRight = frameBufferCreate(rWidth, height); - quadBuffer(POKER_STATE.quadLeft, 0, + 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(POKER_STATE.quadRight, 0, + quadBuffer(GAME_STATE.quadRight, 0, 0, 0, 0, 1, rWidth, height, 1, 0, 0, 0 @@ -48,46 +48,46 @@ void holdemRenderFrameUpdate() { void holdemRenderFrameUseLeft() { glClearColor(0.3, 0, 0, 1); - frameBufferUse(POKER_STATE.frameLeft, true); - cameraPerspective(&POKER_STATE.cameraLeft, 35, + frameBufferUse(GAME_STATE.frameLeft, true); + cameraPerspective(&GAME_STATE.cameraLeft, 35, ( - (float)POKER_STATE.frameLeft->texture->width / - (float)POKER_STATE.frameLeft->texture->height + (float)GAME_STATE.frameLeft->texture->width / + (float)GAME_STATE.frameLeft->texture->height ), 0.2f, 1000.0f ); - shaderUseCamera(GAME_STATE.shaderWorld, &POKER_STATE.cameraLeft); + shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraLeft); } void holdemRenderFrameUseRight() { glClearColor(0.3, 0.3, 0, 1); - frameBufferUse(POKER_STATE.frameRight, true); - cameraPerspective(&POKER_STATE.cameraRight, 45, + frameBufferUse(GAME_STATE.frameRight, true); + cameraPerspective(&GAME_STATE.cameraRight, 45, ( - (float)POKER_STATE.frameRight->texture->width / - (float)POKER_STATE.frameRight->texture->height + (float)GAME_STATE.frameRight->texture->width / + (float)GAME_STATE.frameRight->texture->height ), 0.2f, 1000.0f ); - cameraLookAt(&POKER_STATE.cameraRight, 0, 3, 3, 0, 0, 0); - shaderUseCamera(GAME_STATE.shaderWorld, &POKER_STATE.cameraRight); + cameraLookAt(&GAME_STATE.cameraRight, 0, 3, 3, 0, 0, 0); + shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraRight); } void holdemRenderFrameBack() { glClearColor(0, 0, 0, 1); frameBufferUse(NULL, true); - cameraOrtho(&GAME_STATE.cameraWorld, 0, + cameraOrtho(&GAME_STATE.cameraMain, 0, RENDER_STATE.width, RENDER_STATE.height, 1, 0, 1 ); - cameraLookAt(&GAME_STATE.cameraWorld, 0, 0, 0.5f, 0, 0, 0); - shaderUseCamera(GAME_STATE.shaderWorld, &GAME_STATE.cameraWorld); + 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, POKER_STATE.frameLeft->texture); - primitiveDraw(POKER_STATE.quadLeft, 0, -1); + shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.frameLeft->texture); + primitiveDraw(GAME_STATE.quadLeft, 0, -1); shaderUsePosition(GAME_STATE.shaderWorld, - RENDER_STATE.width - POKER_STATE.frameRight->texture->width, + RENDER_STATE.width - GAME_STATE.frameRight->texture->width, 0, 0, 0, 0, 0 ); - shaderUseTexture(GAME_STATE.shaderWorld, POKER_STATE.frameRight->texture); - primitiveDraw(POKER_STATE.quadRight, 0, -1); + shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.frameRight->texture); + primitiveDraw(GAME_STATE.quadRight, 0, -1); } \ No newline at end of file diff --git a/src/poker/render/look.c b/src/poker/render/look.c index 7d66f048..ac261b8a 100644 --- a/src/poker/render/look.c +++ b/src/poker/render/look.c @@ -12,7 +12,7 @@ void holdemRenderLookSeat(camera_t *camera, uint8_t seat) { angle = HOLDEM_GAME_SEAT_ANGLE(seat); x = sin(angle); z = cos(angle); - cameraLookAt(&POKER_STATE.cameraLeft, + cameraLookAt(&GAME_STATE.cameraLeft, x, 0.2, z, -x, 0.2, -z ); @@ -23,7 +23,7 @@ void holdemRenderLookHand(camera_t *camera, uint8_t seat) { angle = HOLDEM_GAME_SEAT_ANGLE(seat); x = sin(angle); z = cos(angle); - cameraLookAt(&POKER_STATE.cameraLeft, + cameraLookAt(&GAME_STATE.cameraLeft, x*0.1, 0.8, z*0.1, -x*0.5, 0.2, -z*0.5 ); diff --git a/src/poker/render/player.c b/src/poker/render/player.c index 9bb38a58..4a108f42 100644 --- a/src/poker/render/player.c +++ b/src/poker/render/player.c @@ -8,13 +8,13 @@ #include "player.h" void holdemRenderPlayerInit() { - POKER_STATE.kagamiTexture = assetTextureLoad("kagami.png"); - POKER_STATE.kagamiTileset = tilesetCreate(3, 2, - POKER_STATE.kagamiTexture->width, - POKER_STATE.kagamiTexture->height, + GAME_STATE.kagamiTexture = assetTextureLoad("kagami.png"); + GAME_STATE.kagamiTileset = tilesetCreate(3, 2, + GAME_STATE.kagamiTexture->width, + GAME_STATE.kagamiTexture->height, 0, 0, 0, 0 ); - POKER_STATE.kagamiQuad = quadCreate(0, 0, 0, 0, 0, 1, 1, 1, 1); + GAME_STATE.kagamiQuad = quadCreate(0, 0, 0, 0, 0, 1, 1, 1, 1); } uint8_t holdemRenderPlayerGetSeatForPlayer(uint8_t player) { @@ -43,27 +43,27 @@ void holdemRenderPlayer(uint8_t seat) { // Determine size float w, h; w = 0.6, h = ( - (float)POKER_STATE.kagamiTileset->divY / - (float)POKER_STATE.kagamiTileset->divX + (float)GAME_STATE.kagamiTileset->divY / + (float)GAME_STATE.kagamiTileset->divX ) * w; // Animation - int i = (int32_t)(TIME_STATE.current*10)%POKER_STATE.kagamiTileset->count; - quadBuffer(POKER_STATE.kagamiQuad, 0, + int i = (int32_t)(TIME_STATE.current*10)%GAME_STATE.kagamiTileset->count; + quadBuffer(GAME_STATE.kagamiQuad, 0, -w/2, -h/2, - POKER_STATE.kagamiTileset->divisions[i].x0, - POKER_STATE.kagamiTileset->divisions[i].y1, + GAME_STATE.kagamiTileset->divisions[i].x0, + GAME_STATE.kagamiTileset->divisions[i].y1, w/2, h/2, - POKER_STATE.kagamiTileset->divisions[i].x1, - POKER_STATE.kagamiTileset->divisions[i].y0, + GAME_STATE.kagamiTileset->divisions[i].x1, + GAME_STATE.kagamiTileset->divisions[i].y0, 0, 0 ); // Render - shaderUseTexture(GAME_STATE.shaderWorld, POKER_STATE.kagamiTexture); + shaderUseTexture(GAME_STATE.shaderWorld, GAME_STATE.kagamiTexture); shaderUsePosition(GAME_STATE.shaderWorld, x, 0.34, z, 0, angle, 0 ); - primitiveDraw(POKER_STATE.kagamiQuad, 0, -1); + primitiveDraw(GAME_STATE.kagamiQuad, 0, -1); } \ No newline at end of file diff --git a/src/poker/render/world.c b/src/poker/render/world.c index fd284bfd..a461fbda 100644 --- a/src/poker/render/world.c +++ b/src/poker/render/world.c @@ -8,8 +8,8 @@ #include "world.h" void holdemRenderWorldInit() { - POKER_STATE.tablePrimitive = pokerTableCreate(); - POKER_STATE.tableTexture = assetTextureLoad("pokertable.png"); + GAME_STATE.tablePrimitive = pokerTableCreate(); + GAME_STATE.tableTexture = assetTextureLoad("pokertable.png"); } void holdemRenderWorld() { @@ -23,26 +23,26 @@ void holdemRenderWorld() { 0, 0, 0, 3.4, 3.4, 3.4 ); - shaderUseTexture(GAME_STATE.shaderWorld, POKER_STATE.tableTexture); - primitiveDraw(POKER_STATE.tablePrimitive, 0, -1); + 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 < POKER_STATE.cardsFacing; i++) { + for(i = 0x00; i < GAME_STATE.cardsFacing; i++) { holdemRenderCardForSeat( HOLDEM_GAME_SEAT_DEALER, - POKER_STATE.cards[i], + GAME_STATE.cards[i], HOLDEM_GAME_CARD_SLOT_FLOP0 + i ); } // Test for(i = 0x00; i < POKER_PLAYER_COUNT; i++) { - player = POKER_STATE.players + i; + player = GAME_STATE.players + i; seat = holdemRenderPlayerGetSeatForPlayer(i); holdemRenderPlayer(seat); - if(player->state & POKER_STATE_FOLDED) continue; + if(player->state & GAME_STATE_FOLDED) continue; for(j = 0x00; j < player->cardCount; j++) { holdemRenderCardForSeat(seat, player->cards[j], HOLDEM_GAME_CARD_SLOT_HAND0+j); diff --git a/temp/src/world/world.c b/temp/src/world/world.c index ff2c42c7..eca6f630 100644 --- a/temp/src/world/world.c +++ b/temp/src/world/world.c @@ -14,7 +14,7 @@ void worldInit() { void worldRender() { if(ENTITY_STATE.entities[0].type != ENTITY_TYPE_NULL) { - cameraLookAt(&GAME_STATE.cameraWorld, + cameraLookAt(&GAME_STATE.cameraMain, ENTITY_STATE.entities[0].positionX, ENTITY_STATE.entities[0].positionY - 0.5, ENTITY_STATE.entities[0].positionZ + 7,