From 6a1b3705503fad20d5272a5d1e2f32a46e75f783 Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 14 Jul 2021 21:24:04 -0700 Subject: [PATCH] Cleaned some stuff up --- include/dawn/dawn.h | 2 ++ include/dawn/poker/poker.h | 7 +++++-- include/dawn/poker/round/match.h | 14 ++++++++++++++ src/poker/poker.c | 3 +-- src/poker/render/frame.c | 15 --------------- src/poker/render/look.c | 2 +- src/poker/render/look.h | 1 + src/poker/round/deal.c | 5 ++++- src/poker/round/flop.h | 1 + src/poker/round/match.c | 5 +++-- 10 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 include/dawn/poker/round/match.h diff --git a/include/dawn/dawn.h b/include/dawn/dawn.h index aa128cbf..5625f904 100644 --- a/include/dawn/dawn.h +++ b/include/dawn/dawn.h @@ -38,6 +38,8 @@ #include "input/input.h" // Poker Game Logic +#include "poker/round/match.h" + #include "poker/bet.h" #include "poker/card.h" #include "poker/dealer.h" diff --git a/include/dawn/poker/poker.h b/include/dawn/poker/poker.h index fcf0975e..ae4fbc10 100644 --- a/include/dawn/poker/poker.h +++ b/include/dawn/poker/poker.h @@ -14,6 +14,8 @@ #include "render.h" #include "winner.h" +#include "round/match.h" + #include "../display/camera.h" #include "../display/shader.h" #include "../display/texture.h" @@ -71,9 +73,10 @@ typedef struct { /** For Betting round, which player is currently betting */ uint8_t roundBetCurrent; - uint32_t roundTextCounter; + pokerroundmatch_t roundMatch; + ////////////////////////////////////////////////////////////////////////////// // Rendering Variables ////////////////////////////////////////////////////////////////////////////// @@ -88,7 +91,7 @@ typedef struct { shader_t shader; /** Camera for the world and the GUI */ - camera_t cameraWorld, cameraGui, cameraTest; + camera_t cameraWorld, cameraGui; /** Refer to POKER_GUI_HEIGHT */ float guiWidth; diff --git a/include/dawn/poker/round/match.h b/include/dawn/poker/round/match.h new file mode 100644 index 00000000..2b210bff --- /dev/null +++ b/include/dawn/poker/round/match.h @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2021 Dominic Masters + * + * This software is released under the MIT License. + * https://opensource.org/licenses/MIT + */ + +#pragma once +#include "../../libs.h" + +typedef struct { + // Time when match started (for fade effect) + float time; +} pokerroundmatch_t; \ No newline at end of file diff --git a/src/poker/poker.c b/src/poker/poker.c index ba6ac403..0522db0c 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -44,8 +44,7 @@ void pokerUpdate(poker_t *poker, engine_t *engine) { } shaderUse(&poker->shader); - // pokerFrameWorld(poker, &engine->render); - pokerFrameTest(poker, &engine->render); + pokerFrameWorld(poker, &engine->render); pokerWorldRender(poker); for(uint8_t pi = 0; pi < POKER_PLAYER_COUNT; pi++) { diff --git a/src/poker/render/frame.c b/src/poker/render/frame.c index ffc25f24..95304e9b 100644 --- a/src/poker/render/frame.c +++ b/src/poker/render/frame.c @@ -42,19 +42,4 @@ void pokerFrameGui(poker_t *poker, render_t *render) { void pokerFrameRender(poker_t *poker, render_t *render) { -} - -void pokerFrameTest(poker_t *poker, render_t *render) { - // Correct the aspect on the perspective camera for the world - cameraPerspective(&poker->cameraTest, 20, - render->width / render->height, - 0.001, 1000 - ); - - cameraLookAt(&poker->cameraTest, - 0, 0.25, -1, - 0, 0.25, 0.5 - ); - - shaderUseCamera(&poker->shader, &poker->cameraTest); } \ No newline at end of file diff --git a/src/poker/render/look.c b/src/poker/render/look.c index 19e36fcf..73b09d4f 100644 --- a/src/poker/render/look.c +++ b/src/poker/render/look.c @@ -10,7 +10,7 @@ void pokerLookAtPlayer(camera_t *camera, uint8_t seat, float distance) { float x, z, angle; angle = POKER_SEAT_ANGLE(seat); - x = sin(angle) * (0.8); + x = sin(angle) * (0.8 + distance); z = cos(angle) * (0.8 + distance); cameraLookAt(camera, x, 0.3, z, diff --git a/src/poker/render/look.h b/src/poker/render/look.h index df268b80..ff3df6ee 100644 --- a/src/poker/render/look.h +++ b/src/poker/render/look.h @@ -13,6 +13,7 @@ * * @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); diff --git a/src/poker/round/deal.c b/src/poker/round/deal.c index a1aed39a..3c164c9d 100644 --- a/src/poker/round/deal.c +++ b/src/poker/round/deal.c @@ -18,6 +18,9 @@ void pokerDealInit(poker_t *poker) { // Deal 2 card to each player pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH); + // Deal 2 card to each player + pokerDealerDealAll(poker, POKER_DEAL_CARD_EACH); + printf("Cards Dealt\n"); - pokerBetInit(poker); + pokerRoundBetInit(poker); } \ No newline at end of file diff --git a/src/poker/round/flop.h b/src/poker/round/flop.h index 24a0cb66..c06d55bf 100644 --- a/src/poker/round/flop.h +++ b/src/poker/round/flop.h @@ -9,5 +9,6 @@ #include #include "../dealer.h" #include "../card.h" +#include "bet.h" void pokerFlopInit(poker_t *poker); \ No newline at end of file diff --git a/src/poker/round/match.c b/src/poker/round/match.c index b912b41a..d050c312 100644 --- a/src/poker/round/match.c +++ b/src/poker/round/match.c @@ -10,8 +10,7 @@ void pokerMatchInit(poker_t *poker, engine_t *engine) { uint8_t x; // Look at the dealer - // poker->matchStart = engine->time.current; - pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_DEALER, 100); + poker->roundMatch.time = engine->time.current; // Reset the main game state. This does not init the round. pokerBetInit(&poker->bet); @@ -29,4 +28,6 @@ void pokerMatchInit(poker_t *poker, engine_t *engine) { void pokerMatchUpdate(poker_t *poker, engine_t *engine) { // float matchDiff = poker->matchStart - engine->time.current; + float diff = engine->time.current - poker->roundMatch.time; + pokerLookAtPlayer(&poker->cameraWorld, POKER_SEAT_PLAYER0, 3 - (diff/2)); } \ No newline at end of file