Added some basic font rendering and texas holdem
This commit is contained in:
99
include/dawn/cards/card.h
Normal file
99
include/dawn/cards/card.h
Normal file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Cards
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Aces
|
||||
#define CARD_CLUBS_ACE 0x00
|
||||
#define CARD_CLUBS_TWO 0x01
|
||||
#define CARD_CLUBS_THREE 0x02
|
||||
#define CARD_CLUBS_FOUR 0x03
|
||||
#define CARD_CLUBS_FIVE 0x04
|
||||
#define CARD_CLUBS_SIX 0x05
|
||||
#define CARD_CLUBS_SEVEN 0x06
|
||||
#define CARD_CLUBS_EIGHT 0x07
|
||||
#define CARD_CLUBS_NINE 0x08
|
||||
#define CARD_CLUBS_TEN 0x09
|
||||
#define CARD_CLUBS_JACK 0x0A
|
||||
#define CARD_CLUBS_QUEEN 0x0B
|
||||
#define CARD_CLUBS_KING 0x0C
|
||||
|
||||
// Diamonds
|
||||
#define CARD_DIAMONDS_ACE 0x0D
|
||||
#define CARD_DIAMONDS_TWO 0x0E
|
||||
#define CARD_DIAMONDS_THREE 0x0F
|
||||
#define CARD_DIAMONDS_FOUR 0x10
|
||||
#define CARD_DIAMONDS_FIVE 0x11
|
||||
#define CARD_DIAMONDS_SIX 0x12
|
||||
#define CARD_DIAMONDS_SEVEN 0x13
|
||||
#define CARD_DIAMONDS_EIGHT 0x14
|
||||
#define CARD_DIAMONDS_NINE 0x15
|
||||
#define CARD_DIAMONDS_TEN 0x16
|
||||
#define CARD_DIAMONDS_JACK 0x17
|
||||
#define CARD_DIAMONDS_QUEEN 0x18
|
||||
#define CARD_DIAMONDS_KING 0x19
|
||||
|
||||
// Hearts
|
||||
#define CARD_HEARTS_ACE 0x1A
|
||||
#define CARD_HEARTS_TWO 0x1B
|
||||
#define CARD_HEARTS_THREE 0x1C
|
||||
#define CARD_HEARTS_FOUR 0x1D
|
||||
#define CARD_HEARTS_FIVE 0x1E
|
||||
#define CARD_HEARTS_SIX 0x1F
|
||||
#define CARD_HEARTS_SEVEN 0x20
|
||||
#define CARD_HEARTS_EIGHT 0x21
|
||||
#define CARD_HEARTS_NINE 0x22
|
||||
#define CARD_HEARTS_TEN 0x23
|
||||
#define CARD_HEARTS_JACK 0x24
|
||||
#define CARD_HEARTS_QUEEN 0x25
|
||||
#define CARD_HEARTS_KING 0x26
|
||||
|
||||
// Spades
|
||||
#define CARD_SPADES_ACE 0x27
|
||||
#define CARD_SPADES_TWO 0x28
|
||||
#define CARD_SPADES_THREE 0x29
|
||||
#define CARD_SPADES_FOUR 0x2A
|
||||
#define CARD_SPADES_FIVE 0x2B
|
||||
#define CARD_SPADES_SIX 0x2C
|
||||
#define CARD_SPADES_SEVEN 0x2D
|
||||
#define CARD_SPADES_EIGHT 0x2E
|
||||
#define CARD_SPADES_NINE 0x2F
|
||||
#define CARD_SPADES_TEN 0x30
|
||||
#define CARD_SPADES_JACK 0x31
|
||||
#define CARD_SPADES_QUEEN 0x32
|
||||
#define CARD_SPADES_KING 0x33
|
||||
|
||||
// Special Cards
|
||||
#define CARD_RED_JOKER 0x34
|
||||
#define CARD_BLACK_JOKER 0x35
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Suits
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#define CARD_SUIT_CLUBS 0x01
|
||||
#define CARD_SUIT_DIAMONDS 0x02
|
||||
#define CARD_SUIT_HEARTS 0x03
|
||||
#define CARD_SUIT_SPADES 0x04
|
||||
|
||||
|
||||
/** Count of cards in each suit */
|
||||
#define CARD_COUNT_PER_SUIT 13
|
||||
|
||||
/** Standard Card Deck Size */
|
||||
#define CARD_DECK_SIZE 52
|
||||
|
||||
/** Full Card Deck Size */
|
||||
#define CARD_DECK_SIZE_FULL 54
|
||||
|
||||
/** Type Representing a card's id */
|
||||
typedef uint8_t card_t;
|
69
include/dawn/cards/poker/holdem.h
Normal file
69
include/dawn/cards/poker/holdem.h
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../card.h"
|
||||
#include "../../display/spritebatch.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../display/tileset.h"
|
||||
|
||||
/** How many cards a player can hold in their hand */
|
||||
#define HOLDEM_PLAYER_HAND 2
|
||||
/** How many cards the dealer can hold in their hand */
|
||||
#define HOLDEM_DEALER_HAND 5
|
||||
/** How many players in a holdem game (excludes dealer) */
|
||||
#define HOLDEM_PLAYER_COUNT 5
|
||||
|
||||
/** State for whether or not a player has folded */
|
||||
#define HOLDEM_STATE_FOLDED 0x01
|
||||
/** State for whether or not a player is showing their hand */
|
||||
#define HOLDEM_STATE_SHOWING 0x02
|
||||
|
||||
/** Texas Hold'em Player State */
|
||||
typedef struct {
|
||||
/** Cards in the players' hand */
|
||||
card_t cards[HOLDEM_PLAYER_HAND];
|
||||
uint8_t cardCount;
|
||||
|
||||
/** Current State of player */
|
||||
uint8_t state;
|
||||
|
||||
/** Chips in players' posession */
|
||||
uint32_t chips;
|
||||
|
||||
/** Current bet in current round player has placed */
|
||||
uint32_t currentBet;
|
||||
} holdemplayer_t;
|
||||
|
||||
/** Representation of a Texas Hold'em Game State */
|
||||
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 */
|
||||
holdemplayer_t players[HOLDEM_PLAYER_COUNT];
|
||||
} holdemgame_t;
|
||||
|
||||
typedef struct {
|
||||
spritebatch_t *batch;
|
||||
texture_t *texture;
|
||||
tileset_t *tileset;
|
||||
} holdemrender_t;
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
#include "libs.h"
|
||||
|
||||
// Display / Rendering
|
||||
#include "display/camera.h"
|
||||
#include "display/primitive.h"
|
||||
#include "display/render.h"
|
||||
@ -14,15 +15,24 @@
|
||||
#include "display/texture.h"
|
||||
#include "display/tileset.h"
|
||||
|
||||
// File / Asset Management
|
||||
#include "file/asset.h"
|
||||
|
||||
// Game Logic / Game Time Management
|
||||
#include "game/game.h"
|
||||
#include "game/gametime.h"
|
||||
|
||||
// Player Input
|
||||
#include "input/input.h"
|
||||
|
||||
// Poker Game Logic
|
||||
#include "cards/card.h"
|
||||
#include "cards/poker/holdem.h"
|
||||
|
||||
// Utility Objects
|
||||
#include "util/list.h"
|
||||
|
||||
// 3D Tile Game World
|
||||
#include "world/entity/entity.h"
|
||||
#include "world/map/chunk.h"
|
||||
#include "world/map/map.h"
|
||||
|
@ -16,6 +16,9 @@ typedef struct {
|
||||
/** Count of X/Y divisions */
|
||||
int32_t columns, rows;
|
||||
|
||||
/** Size of each divison (in pixels) */
|
||||
float divX, divY;
|
||||
|
||||
/** Count of divisions (unused) */
|
||||
int32_t count;
|
||||
|
||||
|
@ -31,10 +31,14 @@ typedef struct {
|
||||
float last;
|
||||
|
||||
/**
|
||||
* Fixed timestep that occured since the last frame. Typically locked to 1/60
|
||||
* steps per second.
|
||||
* Varying timestep that occured since the last frame.
|
||||
*/
|
||||
float delta;
|
||||
|
||||
/**
|
||||
* Fixed timestep that is not affected by framerate but remains consistent.
|
||||
*/
|
||||
float fixedDelta;
|
||||
} gametime_t;
|
||||
|
||||
extern gametime_t TIME_STATE;
|
@ -8,6 +8,13 @@
|
||||
#pragma once
|
||||
#include "../../libs.h"
|
||||
#include "../../display/spritebatch.h"
|
||||
#include "../../display/texture.h"
|
||||
#include "../../display/tileset.h"
|
||||
|
||||
/** Entity Texture Information */
|
||||
#define ENTITY_ASSET_TEXTURE "world/entity.png"
|
||||
#define ENTITY_WIDTH 32
|
||||
#define ENTITY_HEIGHT ENTITY_WIDTH
|
||||
|
||||
/** Entity ID Definitions */
|
||||
#define ENTITY_TYPE_NULL 0x00
|
||||
@ -19,6 +26,13 @@
|
||||
/** Count of different types of entities */
|
||||
#define ENTITY_TYPE_COUNT ENTITY_TYPE_PLAYER + 1
|
||||
|
||||
#define ENTITY_DIRECTION_SOUTH 0x00
|
||||
#define ENTITY_DIRECTION_NORTH 0x01
|
||||
#define ENTITY_DIRECTION_WEST 0x02
|
||||
#define ENTITY_DIRECTION_EAST 0x03
|
||||
|
||||
#define ENTITY_STATE_WALKING 0x01
|
||||
|
||||
/** Unique Entity ID */
|
||||
typedef uint8_t entityid_t;
|
||||
|
||||
@ -31,12 +45,15 @@ typedef struct {
|
||||
int32_t gridX, gridY, gridZ;
|
||||
int32_t oldGridX, oldGridY, oldGridZ;
|
||||
float positionX, positionY, positionZ;
|
||||
uint8_t direction;
|
||||
uint32_t state;
|
||||
} entity_t;
|
||||
|
||||
/** Definition for an entity type */
|
||||
typedef struct {
|
||||
void (*entityInit)(entityid_t entityId, entity_t *entity);
|
||||
void (*entityUpdate)(entityid_t entityId, entity_t *entity);
|
||||
void (*entityRender)(entityid_t entityId, entity_t *entity);
|
||||
void (*entityDispose)(entityid_t entityId, entity_t *entity);
|
||||
} entitytype_t;
|
||||
|
||||
@ -47,6 +64,12 @@ typedef struct {
|
||||
|
||||
/** Sprite Batch in the state */
|
||||
spritebatch_t *spriteBatch;
|
||||
|
||||
/** Texture for entities */
|
||||
texture_t *texture;
|
||||
|
||||
/** Divided Tileset for entities */
|
||||
tileset_t *tileset;
|
||||
} entitystate_t;
|
||||
|
||||
/** Global Entity State */
|
||||
|
Reference in New Issue
Block a user