Refactor almost finished.
This commit is contained in:
		| @@ -9,6 +9,7 @@ | ||||
| #include "../libs.h" | ||||
| #include "spritebatch.h" | ||||
| #include "tileset.h" | ||||
| #include "../util/math.h" | ||||
|  | ||||
| /** Which is the first character within the font tilemap */ | ||||
| #define BITMAP_FONT_CHAR_START 33 | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "primitive.h" | ||||
| #include "primitives/quad.h" | ||||
| #include "../util/mem.h" | ||||
| #include "../util/math.h" | ||||
|  | ||||
| /** Which character (ASCII) to start the font from */ | ||||
| #define FONT_FIRST_CHAR 32 | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "../util/math.h" | ||||
| #include "primitive.h" | ||||
| #include "primitives/quad.h" | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "../util/math.h" | ||||
|  | ||||
| #define EPOCH_FIXED_STEP 0.016f | ||||
| #define EPOCH_SMALLEST_STEP 0.001f | ||||
|   | ||||
| @@ -109,7 +109,7 @@ void _pokerGameActionBetOnEnd( | ||||
|     pokerDiscussionQueue(&discussion); | ||||
|  | ||||
|     pokerBetResetBetter( | ||||
|       &game->poker, &game->poker.players, game->poker.roundSmallBlind | ||||
|       &game->poker.bet, game->poker.players, game->poker.roundSmallBlind | ||||
|     ); | ||||
|     pokerGameActionRestackAdd(game); | ||||
|     pokerGameActionLookAdd(game, game->poker.bet.better); | ||||
|   | ||||
| @@ -7,9 +7,10 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../../../libs.h" | ||||
| #include "../../../util/math.h" | ||||
| #include "action.h" | ||||
| #include "../../../display/animation/queue.h" | ||||
| #include "../pokergame.h" | ||||
| #include "../../../display/animation/queue.h" | ||||
| #include "../../../poker/turn.h" | ||||
| #include "../../../poker/bet.h" | ||||
| #include "../../../poker/actions/flop.h" | ||||
|   | ||||
| @@ -42,7 +42,7 @@ void _pokerGameActionRoundOnEnd(queue_t *queue,queueaction_t *action,uint8_t i){ | ||||
|   // Begin Betting Round. This will queue for one player only and then the round | ||||
|   // will take over. | ||||
|   pokerBetResetBetter( | ||||
|     &game->poker, game->poker.players, game->poker.roundSmallBlind | ||||
|     &game->poker.bet, game->poker.players, game->poker.roundSmallBlind | ||||
|   ); | ||||
|   pokerGameActionBetAdd(game); | ||||
| } | ||||
|   | ||||
| @@ -71,14 +71,3 @@ void gameInstanceDispose(pokergame_t *game) { | ||||
|   // Unload all assets | ||||
|   pokerGameAssetsDispose(&game->assets); | ||||
| } | ||||
|  | ||||
| void pokerGameQueueRestack(pokergame_t *pokerGame) { | ||||
|   arrayRewind( | ||||
|     sizeof(pokergameactiondata_t), | ||||
|     pokerGame->actionData, | ||||
|     ANIMATION_QUEUE_ITEM_MAX, | ||||
|     pokerGame->scene.conversation.actionQueue.current, | ||||
|     pokerGame->scene.conversation.actionQueue.count | ||||
|   ); | ||||
|   queueRestack(&pokerGame->scene.conversation.actionQueue); | ||||
| } | ||||
| @@ -37,10 +37,3 @@ void gameInstanceUpdate(pokergame_t *game); | ||||
|  * @param game Game to dispose. | ||||
|  */ | ||||
| void gameInstanceDispose(pokergame_t *game); | ||||
|  | ||||
| /** | ||||
|  * Restacks the poker game's stack. | ||||
|  *  | ||||
|  * @param game Poker game to restack | ||||
|  */ | ||||
| void pokerGameQueueRestack(pokergame_t *game); | ||||
							
								
								
									
										19
									
								
								src/game/poker/pokergame.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/game/poker/pokergame.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| /** | ||||
|  * Copyright (c) 2021 Dominic Masters | ||||
|  *  | ||||
|  * This software is released under the MIT License. | ||||
|  * https://opensource.org/licenses/MIT | ||||
|  */ | ||||
|  | ||||
| #include "pokergame.h" | ||||
|  | ||||
| void pokerGameQueueRestack(pokergame_t *pokerGame) { | ||||
|   arrayRewind( | ||||
|     sizeof(pokergameactiondata_t), | ||||
|     pokerGame->actionData, | ||||
|     ANIMATION_QUEUE_ITEM_MAX, | ||||
|     pokerGame->scene.conversation.actionQueue.current, | ||||
|     pokerGame->scene.conversation.actionQueue.count | ||||
|   ); | ||||
|   queueRestack(&pokerGame->scene.conversation.actionQueue); | ||||
| } | ||||
| @@ -38,3 +38,10 @@ typedef struct { | ||||
|   /** Data for the actions */ | ||||
|   pokergameactiondata_t actionData[ANIMATION_QUEUE_ITEM_MAX]; | ||||
| } pokergame_t; | ||||
|  | ||||
| /** | ||||
|  * Restacks the poker game's stack. | ||||
|  *  | ||||
|  * @param game Poker game to restack | ||||
|  */ | ||||
| void pokerGameQueueRestack(pokergame_t *game); | ||||
| @@ -77,7 +77,7 @@ void pokerUiUpdate( | ||||
|     ); | ||||
|      | ||||
|     // Bind the frame buffer | ||||
|     frameBufferUse(&ui->frames + j, true); | ||||
|     frameBufferUse(ui->frames+j, true); | ||||
|  | ||||
|     // Render the VN character | ||||
|     shaderUse(shader); | ||||
| @@ -110,7 +110,7 @@ void pokerUiRender( | ||||
|     for(j = 0; j < POKER_PLAYER_COUNT; j++) { | ||||
|       player = poker->players + j; | ||||
|       for(i = 0; i < player->cardCount; i++) { | ||||
|         pokerCardSetImage(&ui->card, &assets->cardTexture, player->cards[i]); | ||||
|         pokerUiSetImageToCard(&ui->card,&assets->cardTexture,player->cards[i]); | ||||
|         imageRender(&ui->card, &assets->shader, i * 64.0f, j * 100.0f); | ||||
|       } | ||||
|     } | ||||
| @@ -132,11 +132,11 @@ void pokerUiRender( | ||||
|  | ||||
|     // Position the grid itself. | ||||
|     x = 0; | ||||
|     y = POKER_UI_PLAYER_HEIGHT * j; | ||||
|     y = (float)(POKER_UI_PLAYER_HEIGHT * j); | ||||
|  | ||||
|     // Render face | ||||
|     gridGetChild(&ui->grid, 1, 0, 1, 2, &gx, &gy, &gw, &gh); | ||||
|     shaderUseTexture(&assets->shader, &ui->frames + j); | ||||
|     shaderUseTexture(&assets->shader, &(ui->frames + j)->texture); | ||||
|     shaderUsePosition(&assets->shader, x + gx, y + gy, 0, 0,0,0); | ||||
|     primitiveDraw(&ui->quad, 0, -1); | ||||
|  | ||||
| @@ -194,8 +194,8 @@ void pokerUiSetImageToCard(image_t *image, texture_t *texture, card_t card) { | ||||
|  | ||||
|   imageSetTextureAndCrop( | ||||
|     image, texture, | ||||
|     cardGetNumber(cardImageIndex) * 71, | ||||
|     cardGetSuit(card) * 96, | ||||
|     cardGetNumber(cardImageIndex) * 71.0f, | ||||
|     cardGetSuit(card) * 96.0f, | ||||
|     71, 96 | ||||
|   ); | ||||
| } | ||||
| @@ -91,4 +91,4 @@ void pokerUiDispose(pokerui_t *ui); | ||||
|  * @param texture Texture to use. | ||||
|  * @param card Card to set to. | ||||
|  */ | ||||
| void pokerCardSetImage(image_t *image, texture_t *texture, card_t card); | ||||
| void pokerUiSetImageToCard(image_t *image, texture_t *texture, card_t card); | ||||
| @@ -9,6 +9,7 @@ | ||||
| #include "../libs.h" | ||||
| #include "sphere.h" | ||||
| #include "../input/input.h" | ||||
| #include "../util/math.h" | ||||
|  | ||||
| typedef struct { | ||||
|   float hitX; | ||||
|   | ||||
| @@ -15,6 +15,7 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){ | ||||
|  | ||||
|   poker = (poker_t *)action->data; | ||||
|  | ||||
|   // Update game state. | ||||
|   poker->state = POKER_STATE_STARTING_ROUND; | ||||
|  | ||||
|   // Prepare the initial game state | ||||
|   | ||||
| @@ -11,6 +11,7 @@ | ||||
| #include "../dealer.h" | ||||
| #include "../bet.h" | ||||
| #include "../player.h" | ||||
| #include "../poker.h" | ||||
|  | ||||
| /** Callback for when the poker round start aciton begins. */ | ||||
| void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action, uint8_t i); | ||||
|   | ||||
| @@ -29,7 +29,7 @@ void pokerBetPlayer(pokerbet_t *bet, pokerplayer_t *player, int32_t chips) { | ||||
| } | ||||
|  | ||||
| void pokerBetResetBetter( | ||||
|   pokerbet_t *poker, pokerplayer_t *players, uint8_t roundSmallBlind | ||||
|   pokerbet_t *bet, pokerplayer_t *players, uint8_t roundSmallBlind | ||||
| ) { | ||||
|   uint8_t i; | ||||
|   pokerplayer_t *player; | ||||
| @@ -37,6 +37,7 @@ void pokerBetResetBetter( | ||||
|     player = players + i; | ||||
|     player->state = flagOff(player->state, POKER_PLAYER_STATE_ROUND_MOVE); | ||||
|   } | ||||
|    | ||||
|   bet->better = pokerBetGetRoundPlayerDefault(roundSmallBlind); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "player.h" | ||||
| #include "../util/math.h" | ||||
|  | ||||
| /** How many chips each player has by defautl */ | ||||
| #define POKER_BET_PLAYER_CHIPS_DEFAULT 10000 | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "../util/flags.h" | ||||
|  | ||||
| #define ALIGN_POS_CENTER flagDefine(0) | ||||
| #define ALIGN_POS_START flagDefine(1) | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "../util/math.h" | ||||
| #include "align.h" | ||||
|  | ||||
| /** Maximum number of columns a grid can have */ | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
|  | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "rand.h" | ||||
|  | ||||
| /** | ||||
|  * Definition of a callback that is used to sort an array. | ||||
|   | ||||
| @@ -8,6 +8,7 @@ | ||||
| #pragma once | ||||
| #include "../libs.h" | ||||
| #include "array.h" | ||||
| #include "math.h" | ||||
|  | ||||
| /** Custom Array Definition */ | ||||
| typedef struct { | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
| #include "vnconversation.h" | ||||
| #include "../../display/animation/queue.h" | ||||
| #include "../vncharacter.h" | ||||
| #include "../../util/flags.h" | ||||
|  | ||||
| /** Event Callback for when the talk action starts */ | ||||
| void _vnConversationTalkStart(queue_t *q, queueaction_t *a, uint8_t i); | ||||
|   | ||||
| @@ -15,6 +15,7 @@ | ||||
| #include "../../input/input.h" | ||||
| #include "../../ui/frame.h" | ||||
| #include "../../engine/engine.h" | ||||
| #include "../../util/flags.h" | ||||
|  | ||||
| /** Amount of characters scrolled, per second */ | ||||
| #define VN_TEXTBOX_SCROLL_SPEED 60 | ||||
|   | ||||
| @@ -14,6 +14,7 @@ | ||||
| #include "../display/primitives/quad.h" | ||||
| #include "../display/animation/animation.h" | ||||
| #include "../engine/engine.h" | ||||
| #include "../display/animation/easing.h" | ||||
|  | ||||
| #define VN_CHARACTER_BLINK_TIME_RANGE_MAX 6 | ||||
| #define VN_CHARACTER_SIZE 0.5 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user