More code cleaning.
This commit is contained in:
		@@ -20,7 +20,7 @@ set(SETTING_GAME_POKER 1)
 | 
			
		||||
set(SETTING_GAME_DAWN 2)
 | 
			
		||||
set(SETTING_GAME_SANDBOX 3)
 | 
			
		||||
 | 
			
		||||
set(SETTING_GAME SETTING_GAME_DAWN)
 | 
			
		||||
set(SETTING_GAME SETTING_GAME_POKER)
 | 
			
		||||
set(SETTING_GAME_NAME "DawnGame")
 | 
			
		||||
 | 
			
		||||
################################## Targets #####################################
 | 
			
		||||
@@ -71,16 +71,6 @@ if(${SETTING_PLATFORM} EQUAL ${SETTING_PLATFORM_SDL})
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
#################################### ASSETS ####################################
 | 
			
		||||
if(${SETTING_GAME} EQUAL ${SETTING_GAME_SANDBOX})
 | 
			
		||||
  set(SCRIPT_FILES scripts.js)
 | 
			
		||||
  add_custom_command(
 | 
			
		||||
    OUTPUT ${SCRIPT_FILES}
 | 
			
		||||
    COMMAND npm run build
 | 
			
		||||
    DEPENDS ${SOURCE_FILES}
 | 
			
		||||
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 | 
			
		||||
  )
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 | 
			
		||||
 | 
			
		||||
##################################### LIBS #####################################
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										18
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								package.json
									
									
									
									
									
								
							@@ -1,18 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "Dawn",
 | 
			
		||||
  "version": "1.0.0",
 | 
			
		||||
  "main": "index.js",
 | 
			
		||||
  "repository": "https://YourWishes@github.com/YourWishes/Dawn.git",
 | 
			
		||||
  "author": "Dominic Masters <dominic@domsplace.com>",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build:typescript:production": "tsc -p .",
 | 
			
		||||
    "build:production": "npm run build:typescript:production",
 | 
			
		||||
    "bundle:production": "node ./scripts/bundle.js",
 | 
			
		||||
    "build": "npm run build:production && npm run bundle:production"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "tsc": "^2.0.3",
 | 
			
		||||
    "typescript": "^4.4.3"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -49,32 +49,7 @@ void _pokerGameActionBetOnUpdate(
 | 
			
		||||
  pokerTurnAction(&game->poker, player, &turn);
 | 
			
		||||
 | 
			
		||||
  // Speak
 | 
			
		||||
  switch(turn.type) {
 | 
			
		||||
    case POKER_TURN_TYPE_BET:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_PLAYER_RAISING;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_CALL:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_PLAYER_CALLING;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_ALL_IN:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_PLAYER_ALL_IN;
 | 
			
		||||
      break;
 | 
			
		||||
    
 | 
			
		||||
    case POKER_TURN_TYPE_FOLD:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_PLAYER_FOLDING;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_CHECK:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_PLAYER_CHECKING;
 | 
			
		||||
      break;
 | 
			
		||||
    
 | 
			
		||||
    default:
 | 
			
		||||
      discussion.reason = POKER_DISCUSSION_REASON_TEST;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  discussion.reason = pokerDiscussionGetTypeFromTurnType(turn.type);
 | 
			
		||||
  discussion.poker = game;
 | 
			
		||||
  discussion.playerCause = game->poker.bet.better;
 | 
			
		||||
  pokerDiscussionQueue(&discussion);
 | 
			
		||||
@@ -104,7 +79,6 @@ void _pokerGameActionBetOnEnd(
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Not waiting, do next action.
 | 
			
		||||
  printf("Not waiting on anything!\n");
 | 
			
		||||
  pokerGameActionFlopAdd(game);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,6 @@ void _pokerGameActionFlopOnStart(
 | 
			
		||||
      if(pokerBetGetRemainingPlayerCount(
 | 
			
		||||
        &game->poker.bet, game->poker.players
 | 
			
		||||
      ) > 1) {
 | 
			
		||||
 | 
			
		||||
        // Begin betting.
 | 
			
		||||
        pokerGameActionLookAdd(game, game->poker.bet.better);
 | 
			
		||||
        pokerGameActionBetAdd(game);
 | 
			
		||||
@@ -56,7 +55,6 @@ void _pokerGameActionFlopOnStart(
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Done betting
 | 
			
		||||
  printf("All betting is done, reveal\n");
 | 
			
		||||
  pokerGameActionRestackAdd(game);
 | 
			
		||||
  pokerGameActionWinnerAdd(game);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,11 @@
 | 
			
		||||
#include "winner.h"
 | 
			
		||||
#include "bet.h"
 | 
			
		||||
 | 
			
		||||
/** Callback that is fired when the flop action starts */
 | 
			
		||||
void _pokerGameActionFlopOnStart(
 | 
			
		||||
  queue_t *queue, queueaction_t *action, uint8_t i
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Queues a flop action on to the queue.
 | 
			
		||||
 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,6 @@ void _pokerGameActionRestackOnStart(
 | 
			
		||||
  queue_t *queue, queueaction_t *action, uint8_t i
 | 
			
		||||
) {
 | 
			
		||||
  pokergame_t *game = (pokergame_t *)action->data;
 | 
			
		||||
  printf("Restacking\n");
 | 
			
		||||
  pokerGameQueueRestack(game);
 | 
			
		||||
  queueNext(queue);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,6 @@ void _pokerGameActionWinnerOnStart(
 | 
			
		||||
  pokergame_t *game = (pokergame_t *)action->data;
 | 
			
		||||
 | 
			
		||||
  // Calculate the winners
 | 
			
		||||
  printf("Winner start action");
 | 
			
		||||
  pokerWinnerCalculate(
 | 
			
		||||
    &game->poker.winner,
 | 
			
		||||
    &game->poker.dealer,
 | 
			
		||||
@@ -24,13 +23,6 @@ void _pokerGameActionWinnerOnStart(
 | 
			
		||||
  // Action
 | 
			
		||||
  pokerGameWin(&game->poker);
 | 
			
		||||
 | 
			
		||||
  // Debug printing.
 | 
			
		||||
  printf("Winner Count %u\n", game->poker.winner.winnerCount);
 | 
			
		||||
  for(uint8_t i = 0; i < game->poker.winner.winnerCount; i++) {
 | 
			
		||||
    uint8_t winner = game->poker.winner.winners[i];
 | 
			
		||||
    printf("Winner %u\n", winner);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Say stuff
 | 
			
		||||
  discussion.reason = POKER_DISCUSSION_REASON_BETTING_DONE;
 | 
			
		||||
  discussion.poker = game;
 | 
			
		||||
 
 | 
			
		||||
@@ -109,6 +109,29 @@ void pokerDiscussionGet(
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType) {
 | 
			
		||||
  switch(winningType) {
 | 
			
		||||
    case POKER_TURN_TYPE_BET:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_PLAYER_RAISING;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_CALL:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_PLAYER_CALLING;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_ALL_IN:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_PLAYER_ALL_IN;
 | 
			
		||||
    
 | 
			
		||||
    case POKER_TURN_TYPE_FOLD:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_PLAYER_FOLDING;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case POKER_TURN_TYPE_CHECK:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_PLAYER_CHECKING;
 | 
			
		||||
    
 | 
			
		||||
    default:
 | 
			
		||||
      return POKER_DISCUSSION_REASON_TEST;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pokerDiscussionQueue(pokerdiscussiondata_t *data) {
 | 
			
		||||
  pokerdiscussion_t discussion;
 | 
			
		||||
  uint8_t i, player;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
#include "../../vn/conversation/vnconversation.h"
 | 
			
		||||
#include "../../vn/conversation/talk.h"
 | 
			
		||||
#include "actions/look.h"
 | 
			
		||||
#include "../../poker/turn.h"
 | 
			
		||||
 | 
			
		||||
/** Maximum number of messages that the discussion buffer can hold */
 | 
			
		||||
#define POKER_DISCUSSION_MESSAGE_COUNT_MAX 32
 | 
			
		||||
@@ -49,6 +50,14 @@ typedef struct {
 | 
			
		||||
 */
 | 
			
		||||
void pokerDiscussionGet(pokerdiscussion_t *disc, pokerdiscussiondata_t *data);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Fetch the discussion type from a turn type.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param winningType Winning type 
 | 
			
		||||
 * @return Relevant discussion type.
 | 
			
		||||
 */
 | 
			
		||||
uint8_t pokerDiscussionGetTypeFromTurnType(uint8_t winningType);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Queue a discussion data result onto the conversation stack.
 | 
			
		||||
 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -69,7 +69,7 @@ void pokerUiUpdate(
 | 
			
		||||
    player = players + j;
 | 
			
		||||
 | 
			
		||||
    // Locate the XYZ position of the camera to look at the player
 | 
			
		||||
    seat = pokerGameSeatFromIndex(i);
 | 
			
		||||
    seat = pokerWorldSeatFromIndex(i);
 | 
			
		||||
    x = POKER_WORLD_SEAT_POSITION_X(seat);
 | 
			
		||||
    y = POKER_UI_PLAYER_IMAGE_Y;
 | 
			
		||||
    z = POKER_WORLD_SEAT_POSITION_Z(seat);
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ void pokerWorldInit(
 | 
			
		||||
  vncharacter_t *character;
 | 
			
		||||
  uint8_t i;
 | 
			
		||||
  
 | 
			
		||||
  world->seat = POKER_GAME_SEAT_DEALER;
 | 
			
		||||
  world->seat = POKER_WORLD_SEAT_DEALER;
 | 
			
		||||
  world->seatTime = 0;
 | 
			
		||||
 | 
			
		||||
  // Initialize the skywal
 | 
			
		||||
@@ -25,14 +25,14 @@ void pokerWorldInit(
 | 
			
		||||
  for(i = 0x00; i < POKER_PLAYER_COUNT; i++) {
 | 
			
		||||
    character = scene->characters + scene->characterCount;
 | 
			
		||||
    vnCharacterInit(character, &assets->pennyTexture, 
 | 
			
		||||
      POKER_GAME_PENNY_BASE_WIDTH, POKER_GAME_PENNY_BASE_HEIGHT,
 | 
			
		||||
      POKER_GAME_PENNY_FACE_X, POKER_GAME_PENNY_FACE_Y,
 | 
			
		||||
      POKER_GAME_PENNY_FACE_WIDTH, POKER_GAME_PENNY_FACE_HEIGHT
 | 
			
		||||
      POKER_WORLD_PENNY_BASE_WIDTH, POKER_WORLD_PENNY_BASE_HEIGHT,
 | 
			
		||||
      POKER_WORLD_PENNY_FACE_X, POKER_WORLD_PENNY_FACE_Y,
 | 
			
		||||
      POKER_WORLD_PENNY_FACE_WIDTH, POKER_WORLD_PENNY_FACE_HEIGHT
 | 
			
		||||
    );
 | 
			
		||||
    character->x = POKER_WORLD_SEAT_POSITION_X(POKER_GAME_SEAT_FOR_PLAYER(i));
 | 
			
		||||
    character->x = POKER_WORLD_SEAT_POSITION_X(POKER_WORLD_SEAT_FOR_PLAYER(i));
 | 
			
		||||
    character->y = POKER_WORLD_SEAT_POSITION_Y;
 | 
			
		||||
    character->z = POKER_WORLD_SEAT_POSITION_Z(POKER_GAME_SEAT_FOR_PLAYER(i)); 
 | 
			
		||||
    character->yaw = POKER_WORLD_SEAT_ROTATION(POKER_GAME_SEAT_FOR_PLAYER(i));
 | 
			
		||||
    character->z = POKER_WORLD_SEAT_POSITION_Z(POKER_WORLD_SEAT_FOR_PLAYER(i)); 
 | 
			
		||||
    character->yaw = POKER_WORLD_SEAT_ROTATION(POKER_WORLD_SEAT_FOR_PLAYER(i));
 | 
			
		||||
    scene->characterCount++;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,35 +18,46 @@
 | 
			
		||||
#include "../../engine/engine.h"
 | 
			
		||||
#include "pokergameassets.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** How far away from the camera are the characters distanced */
 | 
			
		||||
#define POKER_WORLD_SEAT_DISTANCE -0.75f
 | 
			
		||||
 | 
			
		||||
/** How rotated is the player at a given seat */
 | 
			
		||||
#define POKER_WORLD_SEAT_ROTATION(n) (n * mathDeg2Rad(45.0f))
 | 
			
		||||
 | 
			
		||||
/** World X position of a given seat */
 | 
			
		||||
#define POKER_WORLD_SEAT_POSITION_X(n) ( \
 | 
			
		||||
  POKER_WORLD_SEAT_DISTANCE * (float)sin(POKER_WORLD_SEAT_ROTATION(n)) \
 | 
			
		||||
)
 | 
			
		||||
/** Y Position of seats */
 | 
			
		||||
#define POKER_WORLD_SEAT_POSITION_Y -0.2f
 | 
			
		||||
/** World Z position of a given seat */
 | 
			
		||||
#define POKER_WORLD_SEAT_POSITION_Z(n) ( \
 | 
			
		||||
  POKER_WORLD_SEAT_DISTANCE * (float)cos(POKER_WORLD_SEAT_ROTATION(n)) \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
#define POKER_GAME_SEAT_COUNT 8
 | 
			
		||||
#define POKER_GAME_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
 | 
			
		||||
#define POKER_GAME_SEAT_DEALER POKER_GAME_SEAT_FOR_PLAYER(POKER_DEALER_INDEX)
 | 
			
		||||
/** Count of seats in the world */
 | 
			
		||||
#define POKER_WORLD_SEAT_COUNT 8
 | 
			
		||||
 | 
			
		||||
#define pokerGameSeatFromIndex(i) (\
 | 
			
		||||
/** The seat index for a given player index */
 | 
			
		||||
#define POKER_WORLD_SEAT_FOR_PLAYER(p) (p - (POKER_PLAYER_COUNT/2))
 | 
			
		||||
 | 
			
		||||
/** The seat that the dealer occupies */
 | 
			
		||||
#define POKER_WORLD_SEAT_DEALER POKER_WORLD_SEAT_FOR_PLAYER(POKER_DEALER_INDEX)
 | 
			
		||||
 | 
			
		||||
/** The seat index for a given character index */
 | 
			
		||||
#define pokerWorldSeatFromIndex(i) (\
 | 
			
		||||
  i == POKER_DEALER_INDEX ? \
 | 
			
		||||
  POKER_GAME_SEAT_DEALER : \
 | 
			
		||||
  POKER_GAME_SEAT_FOR_PLAYER(i) \
 | 
			
		||||
  POKER_WORLD_SEAT_DEALER : \
 | 
			
		||||
  POKER_WORLD_SEAT_FOR_PLAYER(i) \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
#define POKER_GAME_PENNY_BASE_WIDTH 1000
 | 
			
		||||
#define POKER_GAME_PENNY_BASE_HEIGHT 1920
 | 
			
		||||
#define POKER_GAME_PENNY_FACE_X 367
 | 
			
		||||
#define POKER_GAME_PENNY_FACE_Y 256
 | 
			
		||||
#define POKER_GAME_PENNY_FACE_WIDTH 280
 | 
			
		||||
#define POKER_GAME_PENNY_FACE_HEIGHT 280
 | 
			
		||||
 | 
			
		||||
// Penny Defs.
 | 
			
		||||
#define POKER_WORLD_PENNY_BASE_WIDTH 1000
 | 
			
		||||
#define POKER_WORLD_PENNY_BASE_HEIGHT 1920
 | 
			
		||||
#define POKER_WORLD_PENNY_FACE_X 367
 | 
			
		||||
#define POKER_WORLD_PENNY_FACE_Y 256
 | 
			
		||||
#define POKER_WORLD_PENNY_FACE_WIDTH 280
 | 
			
		||||
#define POKER_WORLD_PENNY_FACE_HEIGHT 280
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
  primitive_t skywall;
 | 
			
		||||
@@ -56,7 +67,6 @@ typedef struct {
 | 
			
		||||
  float seatTime;
 | 
			
		||||
} pokerworld_t;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the poker renderer.
 | 
			
		||||
 * 
 | 
			
		||||
 
 | 
			
		||||
@@ -18,8 +18,6 @@ void _pokerActionDealOnStart(queue_t *queue, queueaction_t *action, uint8_t i) {
 | 
			
		||||
 | 
			
		||||
  // Deal 2 card to each player
 | 
			
		||||
  pokerDealerDealAll(&poker->dealer, poker->players, POKER_DEAL_CARD_EACH);
 | 
			
		||||
  
 | 
			
		||||
  printf("Cards Dealt\n");
 | 
			
		||||
  queueNext(queue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ void _pokerActionFlopDo(queue_t *queue, queueaction_t *action, uint8_t count) {
 | 
			
		||||
 | 
			
		||||
  poker->state = POKER_STATE_CARDS_FLOPPING;
 | 
			
		||||
 | 
			
		||||
  pokerDealerBurn(&poker->dealer, 1);
 | 
			
		||||
  pokerDealerBurn(&poker->dealer, POKER_FLOP_BURN_COUNT);
 | 
			
		||||
  pokerDealerTurn(&poker->dealer, count);
 | 
			
		||||
 | 
			
		||||
  printf("Turned %u cards\n", count);
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,9 @@
 | 
			
		||||
#include "../poker.h"
 | 
			
		||||
#include "../turn.h"
 | 
			
		||||
 | 
			
		||||
/** How many cards the dealer should burn before dealing the flop */
 | 
			
		||||
#define POKER_FLOP_BURN_COUNT 1
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Shorthand action callback parser. Takes the queue, action and the intended
 | 
			
		||||
 * turn count to complete the action.
 | 
			
		||||
 
 | 
			
		||||
@@ -19,11 +19,11 @@ void _pokerActionMatchOnStart(queue_t *queue, queueaction_t *action, uint8_t i){
 | 
			
		||||
  pokerBetInit(&poker->bet);
 | 
			
		||||
  poker->roundDealer = POKER_PLAYER_COUNT-2;
 | 
			
		||||
  
 | 
			
		||||
  // Reset the players
 | 
			
		||||
  for(x = 0; x < POKER_PLAYER_COUNT; x++) {
 | 
			
		||||
    poker->players[x].state = 0x00;
 | 
			
		||||
    poker->players[x].chips = POKER_BET_PLAYER_CHIPS_DEFAULT;
 | 
			
		||||
  }
 | 
			
		||||
  printf("Match Start\n");
 | 
			
		||||
  queueNext(queue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
 | 
			
		||||
  pokerDealerInit(&poker->dealer);
 | 
			
		||||
 | 
			
		||||
  // Reset the players
 | 
			
		||||
  printf("Resetting the players\n");
 | 
			
		||||
  for(i = 0; i < POKER_PLAYER_COUNT; i++) {
 | 
			
		||||
    pokerPlayerReset(poker->players + i);
 | 
			
		||||
  }
 | 
			
		||||
@@ -57,7 +56,6 @@ void _pokerActionRoundOnStart(queue_t *queue, queueaction_t *action ,uint8_t i){
 | 
			
		||||
  poker->roundBigBlind = indexBigBlind;
 | 
			
		||||
  poker->roundSmallBlind = indexSmallBlind;
 | 
			
		||||
  
 | 
			
		||||
  printf("Round Start\n");
 | 
			
		||||
  queueNext(queue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,7 +10,7 @@
 | 
			
		||||
#include "../util/array.h"
 | 
			
		||||
 | 
			
		||||
/** How many chips each player has by defautl */
 | 
			
		||||
#define POKER_BET_PLAYER_CHIPS_DEFAULT 10000
 | 
			
		||||
#define POKER_BET_PLAYER_CHIPS_DEFAULT 1200
 | 
			
		||||
 | 
			
		||||
/** The default blind cost for the big blind. */
 | 
			
		||||
#define POKER_BET_BLIND_BIG_DEFAULT 600
 | 
			
		||||
 
 | 
			
		||||
@@ -52,4 +52,9 @@ typedef struct {
 | 
			
		||||
  uint8_t state;
 | 
			
		||||
} poker_t;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Action the poker game winning state after it has been calculated previously.
 | 
			
		||||
 * 
 | 
			
		||||
 * @param poker Poker game to action the winning state of.
 | 
			
		||||
 */
 | 
			
		||||
void pokerGameWin(poker_t *poker);
 | 
			
		||||
@@ -1,41 +0,0 @@
 | 
			
		||||
import { Shader } from "../display/Shader";
 | 
			
		||||
 | 
			
		||||
export interface IAssetOwner {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class AssetManager {
 | 
			
		||||
  private owners:{ [key:string]:IAssetOwner[] };
 | 
			
		||||
  private textures:{ [key:string]:CTexture };
 | 
			
		||||
  private shaders:{ [key:string]:Shader };
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.owners = {};
 | 
			
		||||
    this.textures = {};
 | 
			
		||||
    this.shaders = {};
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private addOwner(name:string, owner:IAssetOwner) {
 | 
			
		||||
    this.owners[name] = this.owners[name] || [];
 | 
			
		||||
    this.owners[name].push(owner);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public textureLoad(name:string, owner:IAssetOwner):CTexture {
 | 
			
		||||
    this.addOwner(name, owner);
 | 
			
		||||
    if(this.textures[name]) return this.textures[name];
 | 
			
		||||
    this.textures[name] = textureCreate();
 | 
			
		||||
    assetTextureLoad(this.textures[name], name);
 | 
			
		||||
    return this.textures[name];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public shaderLoad(vert:string, frag:string, owner:IAssetOwner):Shader {
 | 
			
		||||
    this.addOwner(vert, owner);
 | 
			
		||||
    if(this.shaders[vert]) return this.shaders[vert];
 | 
			
		||||
    this.shaders[vert] = new Shader();
 | 
			
		||||
    assetShaderLoad(this.shaders[vert]._shader, vert, frag);
 | 
			
		||||
    return this.shaders[vert];
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public releaseOwner(owner:IAssetOwner) {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,32 +0,0 @@
 | 
			
		||||
export class Camera {
 | 
			
		||||
  public _camera:CCamera;
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this._camera = cameraCreate();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public lookAt(x:number, y:number, z:number, lx:number, ly:number, lz:number) {
 | 
			
		||||
    cameraLookAt(this._camera, x, y, z, lx, ly, lz);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public look(
 | 
			
		||||
    x:number, y:number, z:number, pitch:number, yaw:number, roll:number
 | 
			
		||||
  ) {
 | 
			
		||||
    cameraLook(this._camera, x, y, z, pitch, yaw, roll);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public perspective(fov:number, aspect:number, near:number, far:number) {
 | 
			
		||||
    cameraPerspective(this._camera, fov, aspect, near, far);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public ortho(
 | 
			
		||||
    left:number, right:number, bottom:number, top:number,
 | 
			
		||||
    near:number, far:number
 | 
			
		||||
  ) {
 | 
			
		||||
    cameraOrtho(this._camera, left, right, bottom, top, near, far);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public dispose() {
 | 
			
		||||
    cameraDispose(this._camera);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,15 +0,0 @@
 | 
			
		||||
export class Primitive {
 | 
			
		||||
  public _primitive:CPrimitive;
 | 
			
		||||
 | 
			
		||||
  public constructor() {
 | 
			
		||||
    this._primitive = primitiveCreate();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  draw(start:number=0, count:number=-1) {
 | 
			
		||||
    primitiveDraw(this._primitive, start, count);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public dispose() {
 | 
			
		||||
    primitiveDispose(this._primitive);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +0,0 @@
 | 
			
		||||
import { Primitive } from "./Primitive";
 | 
			
		||||
 | 
			
		||||
export class Quad extends Primitive {
 | 
			
		||||
  constructor(z:number = 0,
 | 
			
		||||
    x0:number = -1, y0:number = -1, u0:number = 0, v0:number = 0,
 | 
			
		||||
    x1:number =  1, y1:number =  1, u1:number = 1, v1:number = 1
 | 
			
		||||
  ) {
 | 
			
		||||
    super();
 | 
			
		||||
    quadInit(this._primitive, z, x0, y0, u0, v0, x1, y1, u1, v1);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
import { Camera } from "./Camera";
 | 
			
		||||
 | 
			
		||||
export class Shader {
 | 
			
		||||
  public _shader:CShader;
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this._shader = shaderCreate();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public use() {
 | 
			
		||||
    shaderUse(this._shader);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public setCamera(camera:Camera) {
 | 
			
		||||
    shaderUseCamera(this._shader, camera._camera);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public setPosition(
 | 
			
		||||
    x:number, y:number, z:number, pitch:number, yaw:number, roll:number
 | 
			
		||||
  ) {
 | 
			
		||||
    shaderUsePosition(this._shader, x,y,z, pitch,yaw,roll);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public setPositionAndScale(
 | 
			
		||||
    x:number, y:number, z:number,
 | 
			
		||||
    pitch:number, yaw:number, roll:number,
 | 
			
		||||
    sx:number, sy:number, sz:number
 | 
			
		||||
  ) {
 | 
			
		||||
    shaderUsePositionAndScale(this._shader, x,y,z, pitch,yaw,roll, sx,sy,sz);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public setTexture(texture:CTexture) {
 | 
			
		||||
    shaderUseTexture(this._shader, texture);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public dispose() {
 | 
			
		||||
    shaderDispose(this._shader);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,77 +0,0 @@
 | 
			
		||||
import { AssetManager } from "../asset/AssetManager";
 | 
			
		||||
import { Scene } from "../scene/Scene";
 | 
			
		||||
 | 
			
		||||
type Time = {
 | 
			
		||||
  delta:number;
 | 
			
		||||
  current:number;
 | 
			
		||||
  last:number;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export class Game {
 | 
			
		||||
  public time:Time;
 | 
			
		||||
  public scene:Scene|null;
 | 
			
		||||
  public assets:AssetManager;
 | 
			
		||||
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.time = { delta: 0, current: 0, last: 0 };
 | 
			
		||||
    this.assets = new AssetManager();
 | 
			
		||||
    this.scene = null;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public setScene(scene:Scene) { this.scene = scene; }
 | 
			
		||||
 | 
			
		||||
  private timeUpdate() {
 | 
			
		||||
    this.time.delta = epochGetDelta();
 | 
			
		||||
    this.time.current = epochGetCurrent();
 | 
			
		||||
    this.time.last = epochGetLast();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  init() {
 | 
			
		||||
    this.timeUpdate();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  update() {
 | 
			
		||||
    this.timeUpdate();
 | 
			
		||||
 | 
			
		||||
    if(this.scene) this.scene.update();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  dispose() {
 | 
			
		||||
    if(this.scene) this.scene.dispose();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Main Game Instance
 | 
			
		||||
let GAME_MAIN:Game|null = null;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Set the main game instance.
 | 
			
		||||
 * @param game Game to become the main game instance.
 | 
			
		||||
 */
 | 
			
		||||
export const gameSetMain = (game:Game) => {
 | 
			
		||||
  GAME_MAIN = game;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Method that is invoked by C when the game needs to intialize.
 | 
			
		||||
 */
 | 
			
		||||
const init = () => {
 | 
			
		||||
  if(!GAME_MAIN) return;
 | 
			
		||||
  GAME_MAIN.init();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Method that is invoked by C every single frame.
 | 
			
		||||
 */
 | 
			
		||||
const update = () => {
 | 
			
		||||
  if(!GAME_MAIN) return;
 | 
			
		||||
  GAME_MAIN.update();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Method that is invoked by C when the game needs to stop and clean up.
 | 
			
		||||
 */
 | 
			
		||||
const dispose = () => {
 | 
			
		||||
  if(!GAME_MAIN) return;
 | 
			
		||||
  GAME_MAIN.dispose();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								ts/main.ts
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								ts/main.ts
									
									
									
									
									
								
							@@ -1,49 +0,0 @@
 | 
			
		||||
import { Camera } from "./display/Camera";
 | 
			
		||||
import { Quad } from "./display/Quad";
 | 
			
		||||
import { Shader } from "./display/Shader";
 | 
			
		||||
import { Game, gameSetMain } from "./game/Game";
 | 
			
		||||
import { Scene } from "./scene/Scene";
 | 
			
		||||
 | 
			
		||||
class TestScene extends Scene {
 | 
			
		||||
  private quad:Quad;
 | 
			
		||||
  private camera:Camera;
 | 
			
		||||
  private shader:Shader;
 | 
			
		||||
  private texture:CTexture;
 | 
			
		||||
 | 
			
		||||
  init() {
 | 
			
		||||
    this.quad = new Quad();
 | 
			
		||||
 | 
			
		||||
    this.shader = this.game.assets.shaderLoad(
 | 
			
		||||
      "shaders/textured.vert", "shaders/textured.frag", this
 | 
			
		||||
    );
 | 
			
		||||
    this.texture = this.game.assets.textureLoad("test_texture.png", this);
 | 
			
		||||
 | 
			
		||||
    this.camera = new Camera();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  update() {
 | 
			
		||||
    this.camera.perspective(45, 16/9, 0.01, 100);
 | 
			
		||||
    this.camera.lookAt(3,3,3, 0,0,0);
 | 
			
		||||
 | 
			
		||||
    this.shader.use();
 | 
			
		||||
    this.shader.setCamera(this.camera);
 | 
			
		||||
    this.shader.setTexture(this.texture);
 | 
			
		||||
    for(let i = 0; i < 3000; i++) {
 | 
			
		||||
      this.shader.setPosition(0,0,0, 0,this.game.time.current + (i*0.0001),0);
 | 
			
		||||
      this.quad.draw();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  dispose() {
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class MainGame extends Game {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    super();
 | 
			
		||||
    this.setScene(new TestScene(this));
 | 
			
		||||
    this.scene.init();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
gameSetMain(new MainGame());
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
import { IAssetOwner } from "../asset/AssetManager";
 | 
			
		||||
import { Game } from "../game/Game";
 | 
			
		||||
 | 
			
		||||
export abstract class Scene implements IAssetOwner {
 | 
			
		||||
  public readonly game:Game;
 | 
			
		||||
 | 
			
		||||
  constructor(game:Game) {
 | 
			
		||||
    this.game = game;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  abstract init():void;
 | 
			
		||||
  abstract update():void;
 | 
			
		||||
  abstract dispose():void;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "compilerOptions": {
 | 
			
		||||
    "target": "ES5",
 | 
			
		||||
    "noImplicitAny": true,
 | 
			
		||||
    "removeComments": true,
 | 
			
		||||
    "preserveConstEnums": true,
 | 
			
		||||
    "outDir": "build/scripts",
 | 
			
		||||
    "noImplicitUseStrict": true,
 | 
			
		||||
    "moduleResolution": "Node"
 | 
			
		||||
  },
 | 
			
		||||
  "include": [ "ts/**/*", "src/**/*.d.ts" ],
 | 
			
		||||
  "exclude": [ "platform/node_modules" ]
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user