Skip to content

Commit

Permalink
Fleshed out Biped, Team, and World classes
Browse files Browse the repository at this point in the history
  • Loading branch information
JLmike7 committed Oct 10, 2014
1 parent 4981511 commit 7eb7b10
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 90 deletions.
49 changes: 24 additions & 25 deletions SeniorDesignProject/SeniorDesignProject/Biped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@

Biped::Biped()
{
//stance = Stance->STANDBY;
//weapons[0];
teamNumber = 1;
cameraHeight = 5.0f;
crawlCameraHeight = 5.0f;
teamColor = 1;
fire = false;
death = false;
Init();
}


Expand All @@ -20,43 +13,49 @@ Biped::~Biped()

void Biped::Init()
{
//stance = Stance->STANDBY;
weapons[0];
stance = walk;
teamNumber = 1;
biped = new Biped;
cameraHeight = 5.0f;
crawlCameraHeight = 5.0f;
teamColor = 1;
}


/*Stance Biped::getStance()
Biped::Stance Biped::getStance()
{
return stance;
}

void Biped::setStance(Stance stance)
{
Biped::stance = stance;
}*/

/*Weapon Biped::getWeapon(){
return weapons[10];
}
void Biped::setWeapon(Weapon gunType){

}*/
Weapon Biped::getWeapon(){
return weapons.front();
}
void Biped::pushWeapon(Weapon newWeapon){
weapons.push_front(newWeapon);
}
int Biped::getTeam(){
return teamNumber;
}
void Biped::setTeam(int team){

void Biped::nextWeapon(){
weapons.push_back(weapons.front());
weapons.pop_front();
}
void Biped::prevWeapon(){
weapons.push_front(weapons.back());
weapons.pop_back();
}
void Biped::setTeam(int _team){
teamNumber = _team;
}
int Biped::takeHit(int damage){

stats.setHealth(stats.getHealth()-damage);
}
bool Biped::fire(){
return fire;
void Biped::fire(){
//TODO: implement
}


Expand Down Expand Up @@ -89,8 +88,8 @@ void Biped::setTeamColor(int newColor){
teamColor = newColor;
}
bool Biped::getDeath(){
return death;
return dead;
}
void Biped::setDeath(bool isDead){
death = isDead;
dead = isDead;
}
33 changes: 19 additions & 14 deletions SeniorDesignProject/SeniorDesignProject/Biped.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#pragma once
#include "Object.h"
#include "Stance.h"
#include "Weapon.h"
#include <deque>
class Biped :
public Object
{
public Object{

enum Stance { sprint, walk, crouch };

public:
void Init();
Stance getStance();
void setStance(Stance iCanMove);
//Weapon getWeapon();
//void setWeapon(Weapon gunType);
void setStance(Stance stance);
Weapon getWeapon();
void pushWeapon(Weapon gunType);
void nextWeapon();
void prevWeapon();
int getTeam();
void setTeam(int team);
int takeHit(int damage);
Expand All @@ -23,19 +27,20 @@ class Biped :
void setTeamColor(int newColor);
bool getDeath();
void setDeath(bool isDead);

void fire();
Biped();
~Biped();

private:


protected:

Stance stance;
Weapon weapons[10];
int teamNumber;
float cameraHeight;
float crawlCameraHeight;
int teamColor;
Stance stance;
std::deque<Weapon> weapons;
int teamNumber;
float cameraHeight;
float crawlCameraHeight;
int teamColor;
bool dead;
Stats stats;
};
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,11 @@
<ClInclude Include="Direction.h" />
<ClInclude Include="Menu.h" />
<ClInclude Include="Object.h" />
<ClInclude Include="Person.h" />
<ClInclude Include="Physics.h" />
<ClInclude Include="Point.h" />
<ClInclude Include="Position.h" />
<ClInclude Include="Quad.h" />
<ClInclude Include="Settings.h" />
<ClInclude Include="Stance.h" />
<ClInclude Include="Stats.h" />
<ClInclude Include="Team.h" />
<ClInclude Include="Triangle.h" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,9 @@
<ClInclude Include="World.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Person.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Settings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Stance.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Weapon.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
36 changes: 26 additions & 10 deletions SeniorDesignProject/SeniorDesignProject/Team.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
#pragma once
#include "Team.h"

Team::Team()
Team::Team(int teamNumber)
{

Init({}, 0, teamNumber);
}

Team::Team(Biped* _members[], int size, int teamNumber)
{
Init(_members, size, teamNumber);
}

Team::~Team()
{

}

void Team::Init(Biped* _members[],int size){
if (memberCount <= MAX_MEMBERS){
for (int i = 0; i < size; i++){
addMember(_members[i]);
}
void Team::Init(Biped* _members[],int size,int teamNumber){
teamNum = teamNumber;
for (int i = 0; i < size; i++){
addMember(_members[i],false);
}
}

void Team::addMember(Biped* member){
members[memberCount] = member;
memberCount++;
void Team::addMember(Biped* member,bool forceIntoTeam){
if (memberCount <= MAX_MEMBERS){
if (forceIntoTeam){
member->setTeam(teamNum);
}
if (member->getTeam() == teamNum){
members[memberCount] = member;
memberCount++;
}
else{
//TODO: throw an error, player doesn't belong in this team!
}
}
else{
//TODO: Make error for "not enough room"!
}
}

Biped* Team::getMember(int index){
Expand Down
8 changes: 5 additions & 3 deletions SeniorDesignProject/SeniorDesignProject/Team.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
class Team
{
public:
void Init(Biped* members[MAX_MEMBERS],int memberCount);
void addMember(Biped* member);
void Init(Biped* members[MAX_MEMBERS],int memberCount,int teamNumber);
void addMember(Biped* member,bool forceIntoTeam);
Biped* getMember(int index);
Biped** getMembers();

Team();
Team(int teamNumber);
Team::Team(Biped* _members[], int size, int teamNumber);
~Team();

private:

protected:
int teamNum;
int memberCount;
Biped* members[MAX_MEMBERS];
};
53 changes: 27 additions & 26 deletions SeniorDesignProject/SeniorDesignProject/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ World::~World()
void World::Init(){
playerIndex = -1;
for (int team = 0; team < NUMBER_TEAMS; team++){
for (int Biped = 0; Biped < TEAM_SIZE; Biped++){
int i = team*TEAM_SIZE + Biped;
for (int teamBipedIndex = 0; teamBipedIndex < TEAM_SIZE; teamBipedIndex++){
int i = (team*TEAM_SIZE) + teamBipedIndex;
if (playerIndex == -1 && team == FRIENDLY_TEAM){
playerIndex = i;
setPlayer(i);
}
people[i].setTeam(team);
bipeds[i]->setTeam(team);
}
}
}
Expand All @@ -32,49 +32,50 @@ void World::setPlayer(int index)

Biped* World::getPlayer()
{
return &people[playerIndex];
return bipeds[playerIndex];
}
Biped* World::getBiped(int index)
{
return &people[index];
return bipeds[index];
}

//This method is inneficient. Use sparingly.
/*Biped** World::getTeam(int teamNum, bool aliveOnly){
//Create a new array of Biped pointers.
//Copy from people[] to team[] if teamIndex matches.
}*/
Team* World::getTeam(int teamNum, bool aliveOnly){
Team* team = new Team(teamNum);
//for each player, put them in the team object
for (int i = 0; i < TEAM_SIZE*NUMBER_TEAMS; i++){
if (!aliveOnly || !bipeds[i]->getDeath()){
team->addMember(bipeds[i], false);
}
}
}
//This method is inneficient. Use sparingly.
int World::getTeamSize(int teamNum, bool aliveOnly){
int peopleInTeam = 0;
for (int i = 0; i < TEAM_SIZE*NUMBER_TEAMS; i++){
if (people[i].getTeam() == teamNum && (!aliveOnly || people[i].getDeath())){
if (bipeds[i]->getTeam() == teamNum && (!aliveOnly || bipeds[i]->getDeath())){
peopleInTeam++;
}
}
return peopleInTeam;
}

//Divides the players by team
/*Biped** World::getTeams(bool aliveOnly){
//Team size must be able to include all players, in the case that a player converted everyone to their team.
Biped* teams[NUMBER_TEAMS][TEAM_SIZE*NUMBER_TEAMS];
int teamCounts[NUMBER_TEAMS];
//set all teamCounts to zero
for (int i = 0; i < NUMBER_TEAMS; i++)
teamCounts[i] = 0;
//for each player, put them in an array in teams.
Team** World::getTeams(bool aliveOnly){
//Initialize teams
Team* teams[NUMBER_TEAMS];
for (int i = 0; i < NUMBER_TEAMS; i++){
teams[i] = new Team(i);
}
//for each player, put them in their team object
for (int i = 0; i < TEAM_SIZE*NUMBER_TEAMS; i++){
if (!aliveOnly || people[i].getDeath()){
int teamNum = people[i].getTeam();
teams[teamNum][teamCounts[teamNum]] = &people[i];
teamCounts[teamNum]++;
if (!aliveOnly || !bipeds[i]->getDeath()){
teams[bipeds[i]->getTeam()]->addMember(bipeds[i],false);
}
}
return teams;
}*/
}
void World::convert(int BipedIndex)
{
people[BipedIndex].setTeam(FRIENDLY_TEAM);
bipeds[BipedIndex]->setTeam(FRIENDLY_TEAM);
}
9 changes: 5 additions & 4 deletions SeniorDesignProject/SeniorDesignProject/World.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "Person.h"
#include "Biped.h"
#include "Team.h"

#define TEAM_SIZE 5
#define NUMBER_TEAMS 2
Expand All @@ -13,9 +14,9 @@ class World
void convert(int BipedIndex);
Biped* getPlayer();
Biped* getBiped(int index);
//Biped** getTeam(int teamIndex, bool aliveOnly);
Team* getTeam(int teamIndex, bool aliveOnly);
int getTeamSize(int teamIndex, bool aliveOnly);
//Biped** getTeams(bool aliveOnly);
Team** getTeams(bool aliveOnly);


World();
Expand All @@ -25,5 +26,5 @@ class World

protected:
int playerIndex;
Person* people[TEAM_SIZE*NUMBER_TEAMS];
Biped* bipeds[TEAM_SIZE*NUMBER_TEAMS];
};

0 comments on commit 7eb7b10

Please sign in to comment.