Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added cpsc585/DirectX/X3DAudio.lib
Binary file not shown.
Binary file added cpsc585/DirectX/X3DAudio1_7.dll
Binary file not shown.
Binary file added cpsc585/DirectX/XAudio2_7.dll
Binary file not shown.
1,350 changes: 1,251 additions & 99 deletions cpsc585/cpsc585/AI.cpp

Large diffs are not rendered by default.

104 changes: 90 additions & 14 deletions cpsc585/cpsc585/AI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <stdlib.h>
#include <math.h>
#include <process.h>

#include "Renderer.h"
#include "Input.h"
Expand All @@ -13,57 +14,132 @@
#include "Waypoint.h"
#include "AIMind.h"
#include "HUD.h"
#include "WaypointEditor.h"
#include "Ability.h"
#include "CheckpointTimer.h"
#include "DynamicObjManager.h"
#include "MenuHandler.h"
#include "Server.h"
#include "Client.h"

#define NUMRACERS 8
#define NUMWAYPOINTS 83
#define NUMCHECKPOINTS 4
#define NETWORKTIME 0.00

class AI
{
public:
AI(void);
~AI(void);
AI();
~AI();
void shutdown();
void initialize(Renderer* renderer, Input* input);
void initialize(Input* input);
void simulate(float milliseconds);
void displayDebugInfo(Intention intention, float milliseconds);
void updateRacerPlacement(int left, int right);
void initializeGame();

private:
std::string getFPSString(float milliseconds);
void initializeWaypoints();
void initializeAIRacers();
void initializeCheckpoints();
void displayPostGameStatistics();
std::string boolToString(bool boolean);
std::string getSpaces(std::string input, int numSpaces);

//Networking functions
static unsigned __stdcall staticSetupServer(void * pThis);
void setupServer();
static unsigned __stdcall staticConnectToServer(void *pThis);
void connectToServer();
void runNetworking(float milliseconds);
void switchToServer();

std::string postGameStatistics[9];
bool generatePostGameStatistics;

Renderer* renderer;
Input* input;
Physics* physics;
HUD* hud;
MenuHandler* menuHandler;
CheckpointTimer* checkPointTimer;
WaypointEditor* wpEditor;

DynamicObjManager* dynManager;

int count;
int fps;
int currentWaypoint;

// Player
Racer* player;
// Race start/end stuff
float raceStartTimer;
bool raceStarted;
bool raceEnded;
bool playedOne, playedTwo, playedThree;

bool paused;
bool startReleased;

int numberOfWaypoints;

int racerIndex;

// Abilities
Ability* speedBoost;

// Racers
Racer* enemies[4];
Racer* racers[NUMRACERS];
Racer* player;
Racer* ai1;
Racer* ai2;
Racer* ai3;
Racer* ai4;
Racer* ai5;
Racer* ai6;
Racer* ai7;

// Racer Minds
AIMind* racerMinds[4];
AIMind* racerMinds[NUMRACERS];
AIMind* playerMind;
AIMind* aiMind1;
AIMind* aiMind2;
AIMind* aiMind3;
AIMind* aiMind4;
AIMind* aiMind5;
AIMind* aiMind6;
AIMind* aiMind7;

AIMind* racerPlacement[NUMRACERS];

// World
World* world;

// Waypoints
Waypoint* waypoints[4];
Waypoint* wp1;
Waypoint* wp2;
Waypoint* wp3;
Waypoint* wp4;
Waypoint* waypoints[NUMWAYPOINTS];

Waypoint* buildingWaypoint;

//Networking
std::string hostName;
HANDLE hth1;
HANDLE hth2;
Server server;
Client client;
ConfigReader config;
bool clientConnected;
bool serverStarted;
bool tryToConnectToServer;
bool readyPressed;
Intention racerIntents[NUMRACERS];
bool readyStatus[NUMRACERS];
Intention prevIntent;
bool isClient;
bool isServer;
float networkTime;

// Checkpoints
Waypoint* checkpoints[NUMCHECKPOINTS];
Waypoint* prevCheckpoints[NUMCHECKPOINTS];

Intention intention;
};
Loading