diff --git a/.gitignore b/.gitignore index b11fa2a2..fcc31a31 100644 --- a/.gitignore +++ b/.gitignore @@ -70,4 +70,7 @@ build lib assets/testworld/tileset.png -oldsrc \ No newline at end of file +oldsrc + +node_modules +yarn.lock \ No newline at end of file diff --git a/include/dawn/poker/card.h b/include/dawn/poker/card.h index 515f3953..db8e125d 100644 --- a/include/dawn/poker/card.h +++ b/include/dawn/poker/card.h @@ -80,10 +80,27 @@ //////////////////////////////////////////////////////////////////////////////// // Suits //////////////////////////////////////////////////////////////////////////////// -#define CARD_SUIT_CLUBS 0x01 -#define CARD_SUIT_DIAMONDS 0x02 -#define CARD_SUIT_HEARTS 0x03 -#define CARD_SUIT_SPADES 0x04 +#define CARD_SUIT_CLUBS 0x0D +#define CARD_SUIT_DIAMONDS 0x1A +#define CARD_SUIT_HEARTS 0x27 +#define CARD_SUIT_SPADES 0x34 + +//////////////////////////////////////////////////////////////////////////////// +// Card numbers +//////////////////////////////////////////////////////////////////////////////// +#define CARD_ACE 0x00 +#define CARD_TWO 0x01 +#define CARD_THREE 0x02 +#define CARD_FOUR 0x03 +#define CARD_FIVE 0x04 +#define CARD_SIX 0x05 +#define CARD_SEVEN 0x06 +#define CARD_EIGHT 0x07 +#define CARD_NINE 0x08 +#define CARD_TEN 0x09 +#define CARD_JACK 0x0A +#define CARD_QUEEN 0x0B +#define CARD_KING 0x0C /** Count of cards in each suit */ #define CARD_COUNT_PER_SUIT 13 diff --git a/include/dawn/poker/poker.h b/include/dawn/poker/poker.h index 330a0186..604dc1aa 100644 --- a/include/dawn/poker/poker.h +++ b/include/dawn/poker/poker.h @@ -110,7 +110,7 @@ typedef struct { /** Game's Shader */ shader_t shader; /** Camera for the world and the GUI */ - camera_t cameraWorld, cameraGui; + camera_t cameraWorld, cameraGui, cameraTest; /** Refer to POKER_GUI_HEIGHT */ float guiWidth; diff --git a/package.json b/package.json new file mode 100644 index 00000000..82a82a87 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "dawn", + "version": "1.0.0", + "repository": "https://YourWishes@github.com/YourWishes/Dawn.git", + "author": "Dominic Masters ", + "license": "MIT", + "private": true, + "dependencies": { + "pngjs": "^6.0.0" + }, + "scripts": { + "stitch": "node --max-heap-size=3840 ./tools/stitcher/index.js" + } +} diff --git a/src/poker/poker.c b/src/poker/poker.c index 96cced8e..10418b68 100644 --- a/src/poker/poker.c +++ b/src/poker/poker.c @@ -44,7 +44,8 @@ void pokerUpdate(poker_t *poker, engine_t *engine) { } shaderUse(&poker->shader); - pokerFrameWorld(poker, &engine->render); + // pokerFrameWorld(poker, &engine->render); + pokerFrameTest(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 95304e9b..ffc25f24 100644 --- a/src/poker/render/frame.c +++ b/src/poker/render/frame.c @@ -42,4 +42,19 @@ 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/frame.h b/src/poker/render/frame.h index a5b5baed..df192230 100644 --- a/src/poker/render/frame.h +++ b/src/poker/render/frame.h @@ -38,4 +38,6 @@ void pokerFrameWorld(poker_t *poker, render_t *render); * @param poker Poker game context. * @param render Rendering engine context. */ -void pokerFrameGui(poker_t *poker, render_t *render); \ No newline at end of file +void pokerFrameGui(poker_t *poker, render_t *render); + +void pokerFrameTest(poker_t *poker, render_t *render); \ No newline at end of file diff --git a/src/poker/round/winner.c b/src/poker/round/winner.c index 6aeaff78..c2c19cf1 100644 --- a/src/poker/round/winner.c +++ b/src/poker/round/winner.c @@ -8,14 +8,44 @@ #pragma once #include "winner.h" -void pokerWinnerInit(poker_t *poker) { +void pokerWinnerGetFullHand(poker_t *poker,pokerplayer_t *player,card_t *cards){ uint8_t i; + for(i = 0; i < poker->cardsFacing; i++) { + cards[i] = poker->cards[i]; + } + + for(i = 0; i < player->cardCount; i++) { + cards[i+poker->cardsFacing] = player->cards[i]; + } +} + +void pokerWinnerInit(poker_t *poker) { + uint8_t winners[POKER_PLAYER_COUNT]; + uint8_t winnerCount = 0; + poker->round = POKER_ROUND_WINNER; printf("Winner Winner Chicken Dinner\n"); - // Bruh Moment - for(i = 0; i < POKER_PLAYER_COUNT; i++) { - + // Find the player(s) who have a royal flush? + for(uint8_t i = 0; i < POKER_PLAYER_COUNT; i++) { + pokerplayer_t *player = poker->players + i; + if(!pokerPlayerIsAlive(player)) continue; + + card_t fullHand[POKER_DEALER_HAND+POKER_PLAYER_HAND]; + pokerWinnerGetFullHand(poker, player, fullHand); + uint8_t cardCount = poker->cardsFacing + player->cardCount; + + uint8_t suit; + + // Find the ace and get it's suit + for(uint8_t j = 0; j < cardCount; j++) { + card_t card = fullHand[j]; + if((card % CARD_COUNT_PER_SUIT) != CARD_ACE) continue; + suit = card / CARD_COUNT_PER_SUIT; + break; + } + + // Now we have a suit, check we have each of that } } \ No newline at end of file diff --git a/src/poker/round/winner.h b/src/poker/round/winner.h index 6bdf8a84..6cc5be83 100644 --- a/src/poker/round/winner.h +++ b/src/poker/round/winner.h @@ -7,5 +7,7 @@ #pragma once #include +#include "../player.h" +void pokerWinnerGetFullHand(poker_t *poker,pokerplayer_t *player,card_t *cards); void pokerWinnerInit(poker_t *poker); \ No newline at end of file diff --git a/tools/stitcher/index.js b/tools/stitcher/index.js index 5b99ff75..d26fd132 100644 --- a/tools/stitcher/index.js +++ b/tools/stitcher/index.js @@ -9,10 +9,17 @@ const IMAGES_ROOT = path.join(...[ 'characters', 'penny', 'Sample sets', - 'Eyes' + 'Mouth' ]); -const FILE_OUT = +const FILE_OUT = path.join(...[ + '.', + 'assets', + 'characters', + 'penny', + 'textures', + 'mouth.png' +]) // Code @@ -84,5 +91,6 @@ const imageWrite = (image, file) => new Promise(resolve => { } }; + console.log('Writing'); await imageWrite(stitched, FILE_OUT); })().catch(console.error); \ No newline at end of file