[Orxonox-commit 5552] r10215 - in code/branches/presentationFS14/src: modules/jump modules/objects/controllers orxonox/controllers
landauf at orxonox.net
landauf at orxonox.net
Sat Jan 31 17:31:23 CET 2015
Author: landauf
Date: 2015-01-31 17:31:23 +0100 (Sat, 31 Jan 2015)
New Revision: 10215
Modified:
code/branches/presentationFS14/src/modules/jump/Jump.cc
code/branches/presentationFS14/src/modules/jump/JumpBoots.cc
code/branches/presentationFS14/src/modules/jump/JumpEnemy.cc
code/branches/presentationFS14/src/modules/jump/JumpFigure.cc
code/branches/presentationFS14/src/modules/jump/JumpFigure.h
code/branches/presentationFS14/src/modules/jump/JumpItem.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatform.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.h
code/branches/presentationFS14/src/modules/jump/JumpPlatformFake.h
code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.h
code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.h
code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.h
code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.cc
code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.h
code/branches/presentationFS14/src/modules/jump/JumpProjectile.cc
code/branches/presentationFS14/src/modules/jump/JumpPropeller.cc
code/branches/presentationFS14/src/modules/jump/JumpRocket.cc
code/branches/presentationFS14/src/modules/jump/JumpScore.cc
code/branches/presentationFS14/src/modules/jump/JumpShield.cc
code/branches/presentationFS14/src/modules/jump/JumpSpring.cc
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc
code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc
code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h
code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.cc
code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.h
Log:
replaced tabs with spaces. no changes in code.
Modified: code/branches/presentationFS14/src/modules/jump/Jump.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/Jump.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/Jump.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -83,208 +83,208 @@
void Jump::tick(float dt)
{
- SUPER(Jump, tick, dt);
+ SUPER(Jump, tick, dt);
- if (figure_ != NULL)
- {
- Vector3 figurePosition = figure_->getPosition();
- Vector3 figureVelocity = figure_->getVelocity();
+ if (figure_ != NULL)
+ {
+ Vector3 figurePosition = figure_->getPosition();
+ Vector3 figureVelocity = figure_->getVelocity();
- float boundary = totalScreenShift_+center_->getCameraOffset();
+ float boundary = totalScreenShift_+center_->getCameraOffset();
- if (figurePosition.z > boundary)
- {
- screenShiftSinceLastUpdate_ += figurePosition.z - boundary;
- totalScreenShift_ = figurePosition.z - center_->getCameraOffset();
+ if (figurePosition.z > boundary)
+ {
+ screenShiftSinceLastUpdate_ += figurePosition.z - boundary;
+ totalScreenShift_ = figurePosition.z - center_->getCameraOffset();
// Create new platforms if needed
if (screenShiftSinceLastUpdate_ > center_->getSectionLength())
{
- if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true)
- {
- screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength();
- ++ adventureNumber_;
- }
- else
- {
- screenShiftSinceLastUpdate_ -= center_->getSectionLength();
- addSection();
- }
+ if (sectionNumber_ > 2 && sectionNumber_%4 == 0 && rand()%2 == 0 && figure_->propellerActive_ == false && figure_->rocketActive_ == false && addAdventure(adventureNumber_) == true)
+ {
+ screenShiftSinceLastUpdate_ -= 2*center_->getSectionLength();
+ ++ adventureNumber_;
+ }
+ else
+ {
+ screenShiftSinceLastUpdate_ -= center_->getSectionLength();
+ addSection();
+ }
}
- }
+ }
- if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
- {
- figure_->dead_ = true;
- }
+ if (figurePosition.z < totalScreenShift_ - center_->getFieldDimension().y + platformHeight_ && figureVelocity.z < 0)
+ {
+ figure_->dead_ = true;
+ }
- if (figure_->fireSignal_ == true)
- {
- if (figure_->dead_ == true)
- {
- end();
- }
- else
- {
- figure_->fireSignal_ = false;
- addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
- }
- }
+ if (figure_->fireSignal_ == true)
+ {
+ if (figure_->dead_ == true)
+ {
+ end();
+ }
+ else
+ {
+ figure_->fireSignal_ = false;
+ addProjectile(figurePosition.x, figurePosition.z + figure_->getPropellerPos());
+ }
+ }
- if (camera != NULL)
- {
- Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0);
- camera->setPosition(cameraPosition);
- }
- else
- {
- orxout() << "No camera found." << endl;
- }
- }
+ if (camera != NULL)
+ {
+ Vector3 cameraPosition = Vector3(0, totalScreenShift_, 0);
+ camera->setPosition(cameraPosition);
+ }
+ else
+ {
+ orxout() << "No camera found." << endl;
+ }
+ }
- ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
- ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
- ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
- Vector3 platformPosition;
+ ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin();
+ ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end();
+ ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform;
+ Vector3 platformPosition;
- while (itPlatform != endPlatform)
- {
- platformPosition = itPlatform->getPosition();
- if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y)
- {
- ObjectList<JumpPlatform>::iterator temp = itPlatform;
- ++ itPlatform;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itPlatform;
- }
- }
+ while (itPlatform != endPlatform)
+ {
+ platformPosition = itPlatform->getPosition();
+ if (platformPosition.z < totalScreenShift_ - center_->getFieldDimension().y)
+ {
+ ObjectList<JumpPlatform>::iterator temp = itPlatform;
+ ++ itPlatform;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itPlatform;
+ }
+ }
- // Deleted deactivated platforms
- ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
- ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
- ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
+ // Deleted deactivated platforms
+ ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin();
+ ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end();
+ ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear;
- while (itDisappear != endDisappear)
- {
- if (!itDisappear->isActive())
- {
- ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
- ++ itDisappear;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itDisappear;
- }
- }
+ while (itDisappear != endDisappear)
+ {
+ if (!itDisappear->isActive())
+ {
+ ObjectList<JumpPlatformDisappear>::iterator temp = itDisappear;
+ ++ itDisappear;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itDisappear;
+ }
+ }
- ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
- ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
- ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
+ ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin();
+ ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end();
+ ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer;
- while (itTimer != endTimer)
- {
- if (!itTimer->isActive())
- {
- ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
- ++ itTimer;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itTimer;
- }
- }
+ while (itTimer != endTimer)
+ {
+ if (!itTimer->isActive())
+ {
+ ObjectList<JumpPlatformTimer>::iterator temp = itTimer;
+ ++ itTimer;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itTimer;
+ }
+ }
- ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
- ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
- ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
- Vector3 projectilePosition;
+ ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin();
+ ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end();
+ ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile;
+ Vector3 projectilePosition;
- while (itProjectile != endProjectile)
- {
- projectilePosition = itProjectile->getPosition();
- if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y)
- {
- ObjectList<JumpProjectile>::iterator temp = itProjectile;
- ++ itProjectile;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itProjectile;
- }
- }
+ while (itProjectile != endProjectile)
+ {
+ projectilePosition = itProjectile->getPosition();
+ if (projectilePosition.z > totalScreenShift_ + 5*center_->getFieldDimension().y)
+ {
+ ObjectList<JumpProjectile>::iterator temp = itProjectile;
+ ++ itProjectile;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itProjectile;
+ }
+ }
- ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
- ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
- ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy;
- Vector3 enemyPosition;
+ ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin();
+ ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end();
+ ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy;
+ Vector3 enemyPosition;
- while (itEnemy != endEnemy)
- {
- enemyPosition = itEnemy->getPosition();
- if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true)
- {
- ObjectList<JumpEnemy>::iterator temp = itEnemy;
- ++ itEnemy;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itEnemy;
- }
- }
+ while (itEnemy != endEnemy)
+ {
+ enemyPosition = itEnemy->getPosition();
+ if (enemyPosition.z < totalScreenShift_ - center_->getFieldDimension().y || itEnemy->dead_ == true)
+ {
+ ObjectList<JumpEnemy>::iterator temp = itEnemy;
+ ++ itEnemy;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itEnemy;
+ }
+ }
- ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
- ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
- ObjectList<JumpItem>::iterator itItem = beginItem;
- Vector3 itemPosition;
+ ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin();
+ ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end();
+ ObjectList<JumpItem>::iterator itItem = beginItem;
+ Vector3 itemPosition;
- while (itItem != endItem)
- {
- itemPosition = itItem->getPosition();
+ while (itItem != endItem)
+ {
+ itemPosition = itItem->getPosition();
- WorldEntity* parent = itItem->getParent();
+ WorldEntity* parent = itItem->getParent();
- if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_)
- {
- ObjectList<JumpItem>::iterator temp = itItem;
- ++ itItem;
- center_->detach(*temp);
- temp->destroy();
- }
- else
- {
- ++ itItem;
- }
- }
+ if (itItem->attachedToFigure_ == false && itemPosition.z < totalScreenShift_ - center_->getFieldDimension().y && parent == center_)
+ {
+ ObjectList<JumpItem>::iterator temp = itItem;
+ ++ itItem;
+ center_->detach(*temp);
+ temp->destroy();
+ }
+ else
+ {
+ ++ itItem;
+ }
+ }
}
void Jump::cleanup()
{
- camera = 0;
+ camera = 0;
}
void Jump::start()
{
if (center_ != NULL) // There needs to be a JumpCenterpoint, i.e. the area the game takes place.
{
- if (figure_ == NULL)
- {
- figure_ = new JumpFigure(center_->getContext());
- figure_->addTemplate(center_->getFigureTemplate());
- figure_->InitializeAnimation(center_->getContext());
- }
+ if (figure_ == NULL)
+ {
+ figure_ = new JumpFigure(center_->getContext());
+ figure_->addTemplate(center_->getFigureTemplate());
+ figure_->InitializeAnimation(center_->getContext());
+ }
center_->attach(figure_);
figure_->setPosition(0, 0, 0);
@@ -302,7 +302,7 @@
if (figure_ != NULL)
{
- camera = figure_->getCamera();
+ camera = figure_->getCamera();
}
totalScreenShift_ = 0.0;
@@ -317,8 +317,8 @@
void Jump::end()
{
- cleanup();
- GSLevel::startMainMenu();
+ cleanup();
+ GSLevel::startMainMenu();
Deathmatch::end();
}
@@ -348,264 +348,264 @@
void Jump::addPlatform(JumpPlatform* newPlatform, std::string platformTemplate, float xPosition, float zPosition)
{
- if (newPlatform != NULL && center_ != NULL)
- {
- newPlatform->addTemplate(platformTemplate);
- newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
- newPlatform->setFigure(this->figure_);
- center_->attach(newPlatform);
- }
+ if (newPlatform != NULL && center_ != NULL)
+ {
+ newPlatform->addTemplate(platformTemplate);
+ newPlatform->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newPlatform->setFigure(this->figure_);
+ center_->attach(newPlatform);
+ }
}
JumpPlatformStatic* Jump::addPlatformStatic(float xPosition, float zPosition)
{
- JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
- addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
+ JumpPlatformStatic* newPlatform = new JumpPlatformStatic(center_->getContext());
+ addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, zPosition);
- return newPlatform;
+ return newPlatform;
}
JumpPlatformHMove* Jump::addPlatformHMove(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float speed)
{
- JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
- newPlatform->setProperties(leftBoundary, rightBoundary, speed);
- addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
+ JumpPlatformHMove* newPlatform = new JumpPlatformHMove(center_->getContext());
+ newPlatform->setProperties(leftBoundary, rightBoundary, speed);
+ addPlatform(newPlatform, center_->getPlatformHMoveTemplate(), xPosition, zPosition);
- return newPlatform;
+ return newPlatform;
}
JumpPlatformVMove* Jump::addPlatformVMove(float xPosition, float zPosition, float lowerBoundary, float upperBoundary, float speed)
{
- JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
- newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
- addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
+ JumpPlatformVMove* newPlatform = new JumpPlatformVMove(center_->getContext());
+ newPlatform->setProperties(lowerBoundary, upperBoundary, speed);
+ addPlatform(newPlatform, center_->getPlatformVMoveTemplate(), xPosition, zPosition);
- return newPlatform;
+ return newPlatform;
}
JumpPlatformDisappear* Jump::addPlatformDisappear(float xPosition, float zPosition)
{
- JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
- newPlatform->setProperties(true);
- addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
+ JumpPlatformDisappear* newPlatform = new JumpPlatformDisappear(center_->getContext());
+ newPlatform->setProperties(true);
+ addPlatform(newPlatform, center_->getPlatformDisappearTemplate(), xPosition, zPosition);
- return newPlatform;
+ return newPlatform;
}
JumpPlatformTimer* Jump::addPlatformTimer(float xPosition, float zPosition, float time, float variance)
{
- float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
+ float additionalTime = (float)(rand()%100)/(100*variance) - variance/2;
- JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
- newPlatform->setProperties(time + additionalTime);
- addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
+ JumpPlatformTimer* newPlatform = new JumpPlatformTimer(center_->getContext());
+ newPlatform->setProperties(time + additionalTime);
+ addPlatform(newPlatform, center_->getPlatformTimerTemplate(), xPosition, zPosition);
- return newPlatform;
+ return newPlatform;
}
JumpPlatformFake* Jump::addPlatformFake(float xPosition, float zPosition)
{
- JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
- addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
- newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
+ JumpPlatformFake* newPlatform = new JumpPlatformFake(center_->getContext());
+ addPlatform(newPlatform, center_->getPlatformFakeTemplate(), xPosition, zPosition);
+ newPlatform->setAngularVelocity(Vector3(0, 0, 2.0));
- return newPlatform;
+ return newPlatform;
}
void Jump::addProjectile(float xPosition, float zPosition)
{
- JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
- if (newProjectile != NULL && center_ != NULL)
- {
- newProjectile->addTemplate(center_->getProjectileTemplate());
- newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
- newProjectile->setFieldDimension(center_->getFieldDimension());
- newProjectile->setFigure(this->figure_);
- center_->attach(newProjectile);
- }
+ JumpProjectile* newProjectile = new JumpProjectile(center_->getContext());
+ if (newProjectile != NULL && center_ != NULL)
+ {
+ newProjectile->addTemplate(center_->getProjectileTemplate());
+ newProjectile->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newProjectile->setFieldDimension(center_->getFieldDimension());
+ newProjectile->setFigure(this->figure_);
+ center_->attach(newProjectile);
+ }
}
void Jump::addSpring(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpSpring* newSpring = new JumpSpring(center_->getContext());
- if (newSpring != NULL && center_ != NULL)
- {
- newSpring->addTemplate(center_->getSpringTemplate());
- newSpring->setPosition(Vector3(xPosition, 0.0, zPosition));
- newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newSpring->setFigure(figure_);
- center_->attach(newSpring);
- }
+ JumpSpring* newSpring = new JumpSpring(center_->getContext());
+ if (newSpring != NULL && center_ != NULL)
+ {
+ newSpring->addTemplate(center_->getSpringTemplate());
+ newSpring->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newSpring->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newSpring->setFigure(figure_);
+ center_->attach(newSpring);
+ }
}
void Jump::addSpring(JumpPlatform* platform)
{
- JumpSpring* newSpring = new JumpSpring(center_->getContext());
- if (newSpring != NULL && center_ != NULL)
- {
- newSpring->addTemplate(center_->getSpringTemplate());
- newSpring->setPosition(Vector3(0.0, 0.0, 0.0));
- newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0);
- newSpring->setFigure(figure_);
- platform->attach(newSpring);
- }
+ JumpSpring* newSpring = new JumpSpring(center_->getContext());
+ if (newSpring != NULL && center_ != NULL)
+ {
+ newSpring->addTemplate(center_->getSpringTemplate());
+ newSpring->setPosition(Vector3(0.0, 0.0, 0.0));
+ newSpring->setProperties(-10.0, 10.0, -10.0, 10.0, 0.0, 0.0);
+ newSpring->setFigure(figure_);
+ platform->attach(newSpring);
+ }
}
void Jump::addRocket(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpRocket* newRocket = new JumpRocket(center_->getContext());
- if (newRocket != NULL && center_ != NULL)
- {
- newRocket->addTemplate(center_->getRocketTemplate());
- newRocket->setPosition(Vector3(xPosition, 0.0, zPosition));
- newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newRocket->setFigure(figure_);
- center_->attach(newRocket);
- }
+ JumpRocket* newRocket = new JumpRocket(center_->getContext());
+ if (newRocket != NULL && center_ != NULL)
+ {
+ newRocket->addTemplate(center_->getRocketTemplate());
+ newRocket->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newRocket->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newRocket->setFigure(figure_);
+ center_->attach(newRocket);
+ }
}
void Jump::addRocket(JumpPlatform* platform)
{
- JumpRocket* newRocket = new JumpRocket(center_->getContext());
- if (newRocket != NULL && center_ != NULL)
- {
- newRocket->addTemplate(center_->getRocketTemplate());
- newRocket->setPosition(Vector3(0.0, 0.0, 0.0));
- newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- newRocket->setFigure(figure_);
- platform->attach(newRocket);
- }
+ JumpRocket* newRocket = new JumpRocket(center_->getContext());
+ if (newRocket != NULL && center_ != NULL)
+ {
+ newRocket->addTemplate(center_->getRocketTemplate());
+ newRocket->setPosition(Vector3(0.0, 0.0, 0.0));
+ newRocket->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ newRocket->setFigure(figure_);
+ platform->attach(newRocket);
+ }
}
void Jump::addPropeller(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
- if (newPropeller != NULL && center_ != NULL)
- {
- newPropeller->addTemplate(center_->getPropellerTemplate());
- newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition));
- newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newPropeller->setFigure(figure_);
- center_->attach(newPropeller);
- }
+ JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
+ if (newPropeller != NULL && center_ != NULL)
+ {
+ newPropeller->addTemplate(center_->getPropellerTemplate());
+ newPropeller->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newPropeller->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newPropeller->setFigure(figure_);
+ center_->attach(newPropeller);
+ }
}
void Jump::addPropeller(JumpPlatform* platform)
{
- JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
- if (newPropeller != NULL && center_ != NULL)
- {
- newPropeller->addTemplate(center_->getPropellerTemplate());
- newPropeller->setPosition(Vector3(0.0, 0.0, 0.0));
- newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- newPropeller->setFigure(figure_);
- platform->attach(newPropeller);
- }
+ JumpPropeller* newPropeller = new JumpPropeller(center_->getContext());
+ if (newPropeller != NULL && center_ != NULL)
+ {
+ newPropeller->addTemplate(center_->getPropellerTemplate());
+ newPropeller->setPosition(Vector3(0.0, 0.0, 0.0));
+ newPropeller->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ newPropeller->setFigure(figure_);
+ platform->attach(newPropeller);
+ }
}
void Jump::addBoots(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpBoots* newBoots = new JumpBoots(center_->getContext());
- if (newBoots != NULL && center_ != NULL)
- {
- newBoots->addTemplate(center_->getBootsTemplate());
- newBoots->setPosition(Vector3(xPosition, 0.0, zPosition));
- newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newBoots->setFigure(figure_);
- center_->attach(newBoots);
- }
+ JumpBoots* newBoots = new JumpBoots(center_->getContext());
+ if (newBoots != NULL && center_ != NULL)
+ {
+ newBoots->addTemplate(center_->getBootsTemplate());
+ newBoots->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newBoots->setFigure(figure_);
+ center_->attach(newBoots);
+ }
}
void Jump::addBoots(JumpPlatform* platform)
{
- JumpBoots* newBoots = new JumpBoots(center_->getContext());
- if (newBoots != NULL && center_ != NULL)
- {
- newBoots->addTemplate(center_->getBootsTemplate());
- newBoots->setPosition(Vector3(0.0, 0.0, 0.0));
- newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- newBoots->setFigure(figure_);
- platform->attach(newBoots);
- }
+ JumpBoots* newBoots = new JumpBoots(center_->getContext());
+ if (newBoots != NULL && center_ != NULL)
+ {
+ newBoots->addTemplate(center_->getBootsTemplate());
+ newBoots->setPosition(Vector3(0.0, 0.0, 0.0));
+ newBoots->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ newBoots->setFigure(figure_);
+ platform->attach(newBoots);
+ }
}
void Jump::addShield(float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpShield* newShield = new JumpShield(center_->getContext());
- if (newShield != NULL && center_ != NULL)
- {
- newShield->addTemplate(center_->getShieldTemplate());
- newShield->setPosition(Vector3(xPosition, 0.0, zPosition));
- newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newShield->setFigure(figure_);
- center_->attach(newShield);
- }
+ JumpShield* newShield = new JumpShield(center_->getContext());
+ if (newShield != NULL && center_ != NULL)
+ {
+ newShield->addTemplate(center_->getShieldTemplate());
+ newShield->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newShield->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newShield->setFigure(figure_);
+ center_->attach(newShield);
+ }
}
void Jump::addShield(JumpPlatform* platform)
{
- JumpShield* newShield = new JumpShield(center_->getContext());
- if (newShield != NULL && center_ != NULL)
- {
- newShield->addTemplate(center_->getShieldTemplate());
- newShield->setPosition(Vector3(0.0, 0.0, 0.0));
- newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- newShield->setFigure(figure_);
- platform->attach(newShield);
- }
+ JumpShield* newShield = new JumpShield(center_->getContext());
+ if (newShield != NULL && center_ != NULL)
+ {
+ newShield->addTemplate(center_->getShieldTemplate());
+ newShield->setPosition(Vector3(0.0, 0.0, 0.0));
+ newShield->setProperties(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ newShield->setFigure(figure_);
+ platform->attach(newShield);
+ }
}
void Jump::addEnemy(int type, float xPosition, float zPosition, float leftBoundary, float rightBoundary, float lowerBoundary, float upperBoundary, float xVelocity, float zVelocity)
{
- JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
- if (newEnemy != NULL && center_ != NULL)
- {
- switch (type)
- {
- case 1:
- newEnemy->addTemplate(center_->getEnemy1Template());
- break;
- case 2:
- newEnemy->addTemplate(center_->getEnemy2Template());
- break;
- case 3:
- newEnemy->addTemplate(center_->getEnemy3Template());
- break;
- case 4:
- newEnemy->addTemplate(center_->getEnemy4Template());
- break;
- default:
- return;
- }
+ JumpEnemy* newEnemy = new JumpEnemy(center_->getContext());
+ if (newEnemy != NULL && center_ != NULL)
+ {
+ switch (type)
+ {
+ case 1:
+ newEnemy->addTemplate(center_->getEnemy1Template());
+ break;
+ case 2:
+ newEnemy->addTemplate(center_->getEnemy2Template());
+ break;
+ case 3:
+ newEnemy->addTemplate(center_->getEnemy3Template());
+ break;
+ case 4:
+ newEnemy->addTemplate(center_->getEnemy4Template());
+ break;
+ default:
+ return;
+ }
- newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
- newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
- newEnemy->setFieldDimension(center_->getFieldDimension());
- newEnemy->setFigure(this->figure_);
- center_->attach(newEnemy);
- }
+ newEnemy->setPosition(Vector3(xPosition, 0.0, zPosition));
+ newEnemy->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity);
+ newEnemy->setFieldDimension(center_->getFieldDimension());
+ newEnemy->setFigure(this->figure_);
+ center_->attach(newEnemy);
+ }
}
void Jump::addStartSection()
{
- JumpPlatform* newPlatform;
+ JumpPlatform* newPlatform;
- float sectionLength = center_->getSectionLength();
+ float sectionLength = center_->getSectionLength();
- newPlatform = new JumpPlatformStatic(center_->getContext());
- addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05*sectionLength);
+ newPlatform = new JumpPlatformStatic(center_->getContext());
+ addPlatform(newPlatform, center_->getPlatformStaticTemplate(), 0.0, -0.05*sectionLength);
- platformWidth_ = newPlatform->getWidth();
- platformHeight_ = newPlatform->getHeight();
+ platformWidth_ = newPlatform->getWidth();
+ platformHeight_ = newPlatform->getHeight();
- for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_)
- {
- newPlatform = new JumpPlatformStatic(center_->getContext());
- addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
- newPlatform = new JumpPlatformStatic(center_->getContext());
- addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05*sectionLength);
- }
+ for (float xPosition = platformWidth_; xPosition <= center_->getFieldDimension().x; xPosition += platformWidth_)
+ {
+ newPlatform = new JumpPlatformStatic(center_->getContext());
+ addPlatform(newPlatform, center_->getPlatformStaticTemplate(), xPosition, -0.05*sectionLength);
+ newPlatform = new JumpPlatformStatic(center_->getContext());
+ addPlatform(newPlatform, center_->getPlatformStaticTemplate(), -xPosition, -0.05*sectionLength);
+ }
}
void Jump::addSection()
@@ -618,481 +618,481 @@
int numI = 6;
int numJ = 4;
- enum PlatformType
- {
- PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE
- };
+ enum PlatformType
+ {
+ PLATFORM_EMPTY, PLATFORM_STATIC, PLATFORM_HMOVE, PLATFORM_VMOVE, PLATFORM_DISAPPEAR, PLATFORM_TIMER, PLATFORM_FAKE
+ };
- enum ItemType
- {
- ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD
- };
+ enum ItemType
+ {
+ ITEM_NOTHING, ITEM_SPRING, ITEM_PROPELLER, ITEM_ROCKET, ITEM_BOOTS, ITEM_SHIELD
+ };
struct PlatformMatrix
{
- PlatformType type;
+ PlatformType type;
bool done;
} matrix[numI][numJ];
- for (int i = 0; i < numI; ++i)
- {
- for (int j = 0; j < numJ; ++j)
- {
- matrix[i][j].type = PLATFORM_EMPTY;
- matrix[i][j].done = false;
- }
- }
- PlatformType platformtype1;
- PlatformType platformtype2;
- ItemType itemType = ITEM_NOTHING;
+ for (int i = 0; i < numI; ++i)
+ {
+ for (int j = 0; j < numJ; ++j)
+ {
+ matrix[i][j].type = PLATFORM_EMPTY;
+ matrix[i][j].done = false;
+ }
+ }
+ PlatformType platformtype1;
+ PlatformType platformtype2;
+ ItemType itemType = ITEM_NOTHING;
- if (rand()%2 == 0)
- {
- itemType = ITEM_SPRING;
- }
- else if (rand()%2 == 0 && sectionNumber_ > 3)
- {
- switch(rand()%4)
- {
- case 0:
- itemType = ITEM_PROPELLER;
- break;
- case 1:
- itemType = ITEM_ROCKET;
- break;
- case 2:
- itemType = ITEM_BOOTS;
- break;
- case 3:
- itemType = ITEM_SHIELD;
- break;
- default:
- break;
- }
- }
+ if (rand()%2 == 0)
+ {
+ itemType = ITEM_SPRING;
+ }
+ else if (rand()%2 == 0 && sectionNumber_ > 3)
+ {
+ switch(rand()%4)
+ {
+ case 0:
+ itemType = ITEM_PROPELLER;
+ break;
+ case 1:
+ itemType = ITEM_ROCKET;
+ break;
+ case 2:
+ itemType = ITEM_BOOTS;
+ break;
+ case 3:
+ itemType = ITEM_SHIELD;
+ break;
+ default:
+ break;
+ }
+ }
- switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
- {
- case 0:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 1:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 2:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 3:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 4:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 5:
- platformtype1 = PLATFORM_STATIC;
- platformtype2 = PLATFORM_TIMER;
- break;
- case 6:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 7:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 8:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 9:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 10:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 11:
- platformtype1 = PLATFORM_HMOVE;
- platformtype2 = PLATFORM_TIMER;
- break;
- case 12:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 13:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 14:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 15:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 16:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 17:
- platformtype1 = PLATFORM_DISAPPEAR;
- platformtype2 = PLATFORM_TIMER;
- break;
- case 18:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 19:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 20:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 21:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 22:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 23:
- platformtype1 = PLATFORM_VMOVE;
- platformtype2 = PLATFORM_TIMER;
- break;
- case 24:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_STATIC;
- break;
- case 25:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_HMOVE;
- break;
- case 26:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_DISAPPEAR;
- break;
- case 27:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_VMOVE;
- break;
- case 28:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_TIMER;
- break;
- default:
- platformtype1 = PLATFORM_TIMER;
- platformtype2 = PLATFORM_TIMER;
- break;
- }
+ switch((sectionNumber_ > 28) ? rand()%29 : rand()%(sectionNumber_+1))
+ {
+ case 0:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 1:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 2:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 3:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 4:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 5:
+ platformtype1 = PLATFORM_STATIC;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ case 6:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 7:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 8:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 9:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 10:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 11:
+ platformtype1 = PLATFORM_HMOVE;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ case 12:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 13:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 14:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 15:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 16:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 17:
+ platformtype1 = PLATFORM_DISAPPEAR;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ case 18:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 19:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 20:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 21:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 22:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 23:
+ platformtype1 = PLATFORM_VMOVE;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ case 24:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_STATIC;
+ break;
+ case 25:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_HMOVE;
+ break;
+ case 26:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_DISAPPEAR;
+ break;
+ case 27:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_VMOVE;
+ break;
+ case 28:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ default:
+ platformtype1 = PLATFORM_TIMER;
+ platformtype2 = PLATFORM_TIMER;
+ break;
+ }
- // Fill matrix with selected platform types
- for (int i = 0; i < numI; ++ i)
- {
- for (int j = 0; j < numJ; ++ j)
- {
- if (rand()%3 == 0)
- {
- matrix[i][j].type = platformtype1;
- }
- else
- {
- matrix[i][j].type = platformtype2;
- }
- matrix[i][j].done = false;
- }
- }
+ // Fill matrix with selected platform types
+ for (int i = 0; i < numI; ++ i)
+ {
+ for (int j = 0; j < numJ; ++ j)
+ {
+ if (rand()%3 == 0)
+ {
+ matrix[i][j].type = platformtype1;
+ }
+ else
+ {
+ matrix[i][j].type = platformtype2;
+ }
+ matrix[i][j].done = false;
+ }
+ }
- if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
+ if (platformtype1 == platformtype2 && sectionNumber_ > 10 && rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
- // Delete some planned platforms or replace them with fake platforms
- if (sectionNumber_ > 5)
- {
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- }
- else if (sectionNumber_ > 10)
- {
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- }
- else if (sectionNumber_ > 15)
- {
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- if (rand()%2 == 0)
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
- }
- else
- {
- matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
- }
- }
+ // Delete some planned platforms or replace them with fake platforms
+ if (sectionNumber_ > 5)
+ {
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ }
+ else if (sectionNumber_ > 10)
+ {
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ }
+ else if (sectionNumber_ > 15)
+ {
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ if (rand()%2 == 0)
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_EMPTY;
+ }
+ else
+ {
+ matrix[rand()%numI][rand()%numJ].type = PLATFORM_FAKE;
+ }
+ }
- std::vector<JumpPlatform*> platformList;
+ std::vector<JumpPlatform*> platformList;
- for (int i = 0; i < numI; ++ i)
- {
- for (int j = 0; j < numJ; ++ j)
- {
- if (matrix[i][j].done == false)
- {
- float xPosition = 0.0;
- float zPosition = 0.0;
- float leftBoundary = 0.0;
- float rightBoundary = 0.0;
- float lowerBoundary = 0.0;
- float upperBoundary = 0.0;
- float xVelocity = 0.0;
- float zVelocity = 0.0;
+ for (int i = 0; i < numI; ++ i)
+ {
+ for (int j = 0; j < numJ; ++ j)
+ {
+ if (matrix[i][j].done == false)
+ {
+ float xPosition = 0.0;
+ float zPosition = 0.0;
+ float leftBoundary = 0.0;
+ float rightBoundary = 0.0;
+ float lowerBoundary = 0.0;
+ float upperBoundary = 0.0;
+ float xVelocity = 0.0;
+ float zVelocity = 0.0;
- switch(matrix[i][j].type)
- {
- case PLATFORM_EMPTY:
- matrix[i][j].done = true;
- break;
- case PLATFORM_STATIC:
- xPosition = randomXPosition(numJ, j);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformStatic(xPosition, zPosition));
- matrix[i][j].done = true;
- break;
- case PLATFORM_FAKE:
- xPosition = randomXPosition(numJ, j);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformFake(xPosition, zPosition));
- matrix[i][j].done = true;
- break;
- case PLATFORM_TIMER:
- xPosition = randomXPosition(numJ, j);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5));
- matrix[i][j].done = true;
- break;
- case PLATFORM_DISAPPEAR:
- xPosition = randomXPosition(numJ, j);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformDisappear(xPosition, zPosition));
- matrix[i][j].done = true;
- break;
- case PLATFORM_HMOVE:
- xVelocity = randomSpeed();
- if (j <= numJ-3 && matrix[i][j+1].type == PLATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)
- {
- leftBoundary = randomXPositionLeft(numJ, j);
- rightBoundary = randomXPositionRight(numJ, j+2);
- xPosition = randomPosition(leftBoundary, rightBoundary);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
- matrix[i][j].done = true;
- matrix[i][j+1].done = true;
- matrix[i][j+2].done = true;
- }
- else if (j <= numJ-2 && matrix[i][j+1].type == PLATFORM_HMOVE && rand()%2 == 0)
- {
- leftBoundary = randomXPositionLeft(numJ, j);
- rightBoundary = randomXPositionRight(numJ, j+1);
- xPosition = randomPosition(leftBoundary, rightBoundary);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
- matrix[i][j].done = true;
- matrix[i][j+1].done = true;
- }
- else
- {
- leftBoundary = randomXPositionLeft(numJ, j);
- rightBoundary = randomXPositionRight(numJ, j);
- xPosition = randomPosition(leftBoundary, rightBoundary);
- zPosition = sectionBegin + i*sectionLength/numI;
- platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
- matrix[i][j].done = true;
- }
- break;
- case PLATFORM_VMOVE:
- zVelocity = randomSpeed();
- if (i <= numI-3 && matrix[i+1][j].type == PLATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)
- {
- lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
- upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd);
- zPosition = randomPosition(lowerBoundary, upperBoundary);
- xPosition = randomXPosition(numJ, j);
- platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
- matrix[i][j].done = true;
- matrix[i+1][j].done = true;
- matrix[i+2][j].done = true;
- }
- else if (i <= numI-2 && matrix[i+1][j].type == PLATFORM_VMOVE && rand()%2 == 0)
- {
- lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
- upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd);
- zPosition = randomPosition(lowerBoundary, upperBoundary);
- xPosition = randomXPosition(numJ, j);
- platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
- matrix[i][j].done = true;
- matrix[i+1][j].done = true;
- }
- else
- {
- lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
- upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd);
- zPosition = randomPosition(lowerBoundary, upperBoundary);
- xPosition = randomXPosition(numJ, j);
- platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
- matrix[i][j].done = true;
- }
- break;
- default:
- //ERROR
- break;
+ switch(matrix[i][j].type)
+ {
+ case PLATFORM_EMPTY:
+ matrix[i][j].done = true;
+ break;
+ case PLATFORM_STATIC:
+ xPosition = randomXPosition(numJ, j);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformStatic(xPosition, zPosition));
+ matrix[i][j].done = true;
+ break;
+ case PLATFORM_FAKE:
+ xPosition = randomXPosition(numJ, j);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformFake(xPosition, zPosition));
+ matrix[i][j].done = true;
+ break;
+ case PLATFORM_TIMER:
+ xPosition = randomXPosition(numJ, j);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformTimer(xPosition, zPosition, 12.0, 1.5));
+ matrix[i][j].done = true;
+ break;
+ case PLATFORM_DISAPPEAR:
+ xPosition = randomXPosition(numJ, j);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformDisappear(xPosition, zPosition));
+ matrix[i][j].done = true;
+ break;
+ case PLATFORM_HMOVE:
+ xVelocity = randomSpeed();
+ if (j <= numJ-3 && matrix[i][j+1].type == PLATFORM_HMOVE && matrix[i][j+2].type == PLATFORM_HMOVE && rand()%2 == 0)
+ {
+ leftBoundary = randomXPositionLeft(numJ, j);
+ rightBoundary = randomXPositionRight(numJ, j+2);
+ xPosition = randomPosition(leftBoundary, rightBoundary);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
+ matrix[i][j].done = true;
+ matrix[i][j+1].done = true;
+ matrix[i][j+2].done = true;
+ }
+ else if (j <= numJ-2 && matrix[i][j+1].type == PLATFORM_HMOVE && rand()%2 == 0)
+ {
+ leftBoundary = randomXPositionLeft(numJ, j);
+ rightBoundary = randomXPositionRight(numJ, j+1);
+ xPosition = randomPosition(leftBoundary, rightBoundary);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
+ matrix[i][j].done = true;
+ matrix[i][j+1].done = true;
+ }
+ else
+ {
+ leftBoundary = randomXPositionLeft(numJ, j);
+ rightBoundary = randomXPositionRight(numJ, j);
+ xPosition = randomPosition(leftBoundary, rightBoundary);
+ zPosition = sectionBegin + i*sectionLength/numI;
+ platformList.push_back(addPlatformHMove(xPosition, zPosition, leftBoundary, rightBoundary, xVelocity));
+ matrix[i][j].done = true;
+ }
+ break;
+ case PLATFORM_VMOVE:
+ zVelocity = randomSpeed();
+ if (i <= numI-3 && matrix[i+1][j].type == PLATFORM_VMOVE && matrix[i+2][j].type == PLATFORM_VMOVE && rand()%2 == 0)
+ {
+ lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
+ upperBoundary = randomZPositionUpper(numI, i+2, sectionBegin, sectionEnd);
+ zPosition = randomPosition(lowerBoundary, upperBoundary);
+ xPosition = randomXPosition(numJ, j);
+ platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
+ matrix[i][j].done = true;
+ matrix[i+1][j].done = true;
+ matrix[i+2][j].done = true;
+ }
+ else if (i <= numI-2 && matrix[i+1][j].type == PLATFORM_VMOVE && rand()%2 == 0)
+ {
+ lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
+ upperBoundary = randomZPositionUpper(numI, i+1, sectionBegin, sectionEnd);
+ zPosition = randomPosition(lowerBoundary, upperBoundary);
+ xPosition = randomXPosition(numJ, j);
+ platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
+ matrix[i][j].done = true;
+ matrix[i+1][j].done = true;
+ }
+ else
+ {
+ lowerBoundary = randomZPositionLower(numI, i, sectionBegin, sectionEnd);
+ upperBoundary = randomZPositionUpper(numI, i, sectionBegin, sectionEnd);
+ zPosition = randomPosition(lowerBoundary, upperBoundary);
+ xPosition = randomXPosition(numJ, j);
+ platformList.push_back(addPlatformVMove(xPosition, zPosition, lowerBoundary, upperBoundary, zVelocity));
+ matrix[i][j].done = true;
+ }
+ break;
+ default:
+ //ERROR
+ break;
- }
- }
- }
- }
+ }
+ }
+ }
+ }
- //Add items
- int numNewPlatforms = platformList.size();
+ //Add items
+ int numNewPlatforms = platformList.size();
- if (rand()%4 == 0)
- {
- if (rand()%2 == 0)
- {
- switch (itemType)
- {
- case ITEM_ROCKET:
- addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
- break;
- case ITEM_PROPELLER:
- addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
- break;
- case ITEM_BOOTS:
- addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
- break;
- case ITEM_SHIELD:
- addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
- break;
- default:
- break;
- }
- }
- else
- {
- switch (itemType)
- {
- case ITEM_ROCKET:
- addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
- break;
- case ITEM_PROPELLER:
- addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
- break;
- case ITEM_BOOTS:
- addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
- break;
- case ITEM_SHIELD:
- addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
- break;
- default:
- break;
- }
- }
- }
- else
- {
- if (numNewPlatforms > 0)
- {
- JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms];
+ if (rand()%4 == 0)
+ {
+ if (rand()%2 == 0)
+ {
+ switch (itemType)
+ {
+ case ITEM_ROCKET:
+ addRocket(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
+ break;
+ case ITEM_PROPELLER:
+ addPropeller(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
+ break;
+ case ITEM_BOOTS:
+ addBoots(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
+ break;
+ case ITEM_SHIELD:
+ addShield(0.0, randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/2, fieldWidth/2, 0.0, 0.0, randomSpeed(), 0.0);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch (itemType)
+ {
+ case ITEM_ROCKET:
+ addRocket(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
+ break;
+ case ITEM_PROPELLER:
+ addPropeller(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
+ break;
+ case ITEM_BOOTS:
+ addBoots(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
+ break;
+ case ITEM_SHIELD:
+ addShield(randomPosition(-fieldWidth/2, fieldWidth/2), sectionBegin + sectionLength/2, 0.0, 0.0, sectionBegin, sectionEnd, 0.0, randomSpeed());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ if (numNewPlatforms > 0)
+ {
+ JumpPlatform* itemPlatform = platformList[rand()%numNewPlatforms];
- switch (itemType)
- {
- case ITEM_SPRING:
- addSpring(itemPlatform);
- break;
- case ITEM_ROCKET:
- addRocket(itemPlatform);
- break;
- case ITEM_PROPELLER:
- addPropeller(itemPlatform);
- break;
- case ITEM_BOOTS:
- addBoots(itemPlatform);
- break;
- case ITEM_SHIELD:
- addShield(itemPlatform);
- break;
- default:
- break;
- }
- }
- }
+ switch (itemType)
+ {
+ case ITEM_SPRING:
+ addSpring(itemPlatform);
+ break;
+ case ITEM_ROCKET:
+ addRocket(itemPlatform);
+ break;
+ case ITEM_PROPELLER:
+ addPropeller(itemPlatform);
+ break;
+ case ITEM_BOOTS:
+ addBoots(itemPlatform);
+ break;
+ case ITEM_SHIELD:
+ addShield(itemPlatform);
+ break;
+ default:
+ break;
+ }
+ }
+ }
if (sectionNumber_ >= 5 && rand()%3 == 0)
{
- switch(rand()%4)
- {
+ switch(rand()%4)
+ {
case 0:
- addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
- break;
+ addEnemy(1, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
+ break;
case 1:
- addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
- break;
+ addEnemy(2, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
+ break;
case 2:
- addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
- break;
+ addEnemy(3, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
+ break;
case 3:
- addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
- break;
- }
+ addEnemy(4, randomXPosition(), randomPosition(sectionBegin, sectionBegin + sectionLength), -fieldWidth/3*2, fieldWidth/3*2, sectionBegin, sectionBegin + sectionLength, randomSpeed(), 0.0);
+ break;
+ }
}
- ++ sectionNumber_;
+ ++ sectionNumber_;
}
bool Jump::addAdventure(int number)
@@ -1105,76 +1105,76 @@
switch(number)
{
case 0:
- {
- int numI = 10;
- if (rand()%2 == 0)
- {
- for (int i = 0; i < numI; ++ i)
- {
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
- }
- }
- else
- {
- for (int i = 0; i < numI; ++ i)
- {
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI);
- }
- }
- break;
- }
+ {
+ int numI = 10;
+ if (rand()%2 == 0)
+ {
+ for (int i = 0; i < numI; ++ i)
+ {
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+i*sectionLength/numI);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < numI; ++ i)
+ {
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+(numI-i)*sectionLength/numI);
+ }
+ }
+ break;
+ }
case 1:
- {
- int numI = 7;
+ {
+ int numI = 7;
- addPlatformStatic(0.0, sectionBegin);
- if (rand()%2 == 0)
- {
- for (int i = 1; i < numI; ++ i)
- {
- addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
- addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
- }
- }
- else
- {
- for (int i = 1; i < numI; ++ i)
- {
- addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
- addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
- }
- }
- break;
- }
+ addPlatformStatic(0.0, sectionBegin);
+ if (rand()%2 == 0)
+ {
+ for (int i = 1; i < numI; ++ i)
+ {
+ addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
+ addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+i*sectionLength/numI);
+ }
+ }
+ else
+ {
+ for (int i = 1; i < numI; ++ i)
+ {
+ addPlatformStatic((fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
+ addPlatformStatic(-(fieldWidth-platformWidth_/2)*i/numI, sectionBegin+(numI-i)*sectionLength/numI);
+ }
+ }
+ break;
+ }
case 2:
- {
- int numI = 5;
- for (int i = 0; i <= numI; ++ i)
- {
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin);
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5);
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5);
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5);
- addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5);
- addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
- }
- break;
- }
+ {
+ int numI = 5;
+ for (int i = 0; i <= numI; ++ i)
+ {
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin);
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength/5);
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*2/5);
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*3/5);
+ addPlatformStatic((2*fieldWidth-platformWidth_)*i/numI-fieldWidth, sectionBegin+sectionLength*4/5);
+ addEnemy(4, (2*fieldWidth-platformWidth_)*i/numI-fieldWidth+platformWidth_/2, sectionBegin+sectionLength/2, -fieldWidth, fieldWidth, sectionBegin, sectionBegin + sectionLength, 0.0, 0.0);
+ }
+ break;
+ }
case 3:
- {
- addRocket(addPlatformStatic(0.0, sectionBegin));
- addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0);
- break;
- }
+ {
+ addRocket(addPlatformStatic(0.0, sectionBegin));
+ addEnemy(2, 0.0, sectionBegin+sectionLength/5, 0.0,0.0, 0.0, 0.0, 0.0, 0.0);
+ break;
+ }
case 4:
- {
- addPropeller(addPlatformStatic(0.0, sectionBegin));
- addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin));
- addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin));
- break;
- }
+ {
+ addPropeller(addPlatformStatic(0.0, sectionBegin));
+ addPropeller(addPlatformStatic(-fieldWidth/2, sectionBegin));
+ addPropeller(addPlatformStatic(fieldWidth/2, sectionBegin));
+ break;
+ }
default:
- return false;
+ return false;
}
sectionNumber_ +=2;
return true;
@@ -1184,85 +1184,85 @@
{
float fieldWidth = center_->getFieldDimension().x;
- return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
+ return (float)(rand()%(2*(int)fieldWidth)) - fieldWidth;
}
float Jump::randomXPosition(int totalColumns, int culomn)
{
- float fieldWidth = center_->getFieldDimension().x;
+ float fieldWidth = center_->getFieldDimension().x;
- float halfWidth = fieldWidth/totalColumns;
- float leftBound = culomn*halfWidth*2-fieldWidth;
- float rightBound = leftBound + 2*halfWidth;
+ float halfWidth = fieldWidth/totalColumns;
+ float leftBound = culomn*halfWidth*2-fieldWidth;
+ float rightBound = leftBound + 2*halfWidth;
- return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
+ return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
}
float Jump::randomXPositionLeft(int totalColumns, int culomn)
{
- float fieldWidth = center_->getFieldDimension().x;
+ float fieldWidth = center_->getFieldDimension().x;
- float halfWidth = fieldWidth/totalColumns;
- float leftBound = culomn*halfWidth*2-fieldWidth;
- float rightBound = leftBound + 2*halfWidth/3;
+ float halfWidth = fieldWidth/totalColumns;
+ float leftBound = culomn*halfWidth*2-fieldWidth;
+ float rightBound = leftBound + 2*halfWidth/3;
- return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
+ return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
}
float Jump::randomXPositionRight(int totalColumns, int culomn)
{
- float fieldWidth = center_->getFieldDimension().x;
+ float fieldWidth = center_->getFieldDimension().x;
- float halfWidth = fieldWidth/totalColumns;
- float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
- float leftBound = rightBound - 2*halfWidth/3;
- return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
+ float halfWidth = fieldWidth/totalColumns;
+ float rightBound = (culomn+1)*halfWidth*2-fieldWidth;
+ float leftBound = rightBound - 2*halfWidth/3;
+ return randomPosition(leftBound+platformWidth_/2, rightBound-platformWidth_/2);
}
float Jump::randomZPosition(int totalRows, int row, float sectionBegin, float SectionEnd)
{
- float fieldHeight = SectionEnd - sectionBegin;
- float halfHeight = fieldHeight/totalRows;
- float lowerBound = row*halfHeight*2+sectionBegin;
- float upperBound = lowerBound + 2*halfHeight;
+ float fieldHeight = SectionEnd - sectionBegin;
+ float halfHeight = fieldHeight/totalRows;
+ float lowerBound = row*halfHeight*2+sectionBegin;
+ float upperBound = lowerBound + 2*halfHeight;
- return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
+ return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
}
float Jump::randomZPositionLower(int totalRows, int row, float sectionBegin, float SectionEnd)
{
- float fieldHeight = SectionEnd - sectionBegin;
- float rowHeight = fieldHeight/totalRows;
- float lowerBound = row*rowHeight+sectionBegin;
- float upperBound = lowerBound + rowHeight/3;
+ float fieldHeight = SectionEnd - sectionBegin;
+ float rowHeight = fieldHeight/totalRows;
+ float lowerBound = row*rowHeight+sectionBegin;
+ float upperBound = lowerBound + rowHeight/3;
- return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
+ return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
}
float Jump::randomZPositionUpper(int totalRows, int row, float sectionBegin, float SectionEnd)
{
- float fieldHeight = SectionEnd - sectionBegin;
- float rowHeight = fieldHeight/totalRows;
- float lowerBound = (row+1)*rowHeight+sectionBegin;
- float upperBound = lowerBound - rowHeight/3;
+ float fieldHeight = SectionEnd - sectionBegin;
+ float rowHeight = fieldHeight/totalRows;
+ float lowerBound = (row+1)*rowHeight+sectionBegin;
+ float upperBound = lowerBound - rowHeight/3;
- return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
+ return randomPosition(lowerBound+platformHeight_/2, upperBound-platformHeight_/2);
}
float Jump::randomPosition(float lowerBoundary, float upperBoundary)
{
- if (lowerBoundary >= upperBoundary)
- {
- return (lowerBoundary + upperBoundary)/2;
- }
+ if (lowerBoundary >= upperBoundary)
+ {
+ return (lowerBoundary + upperBoundary)/2;
+ }
- return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
+ return (float)(rand()%(int)(100*(upperBoundary - lowerBoundary)))/100 + lowerBoundary;
}
float Jump::randomSpeed()
{
- float platformSpeed = center_->getPlatformSpeed();
- return randomPosition(0.5*platformSpeed, 1.5*platformSpeed);
+ float platformSpeed = center_->getPlatformSpeed();
+ return randomPosition(0.5*platformSpeed, 1.5*platformSpeed);
}
int Jump::getScore(PlayerInfo* player) const
Modified: code/branches/presentationFS14/src/modules/jump/JumpBoots.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpBoots.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpBoots.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -82,23 +82,23 @@
if(figurePosition.x > rocketPosition.x-width_ && figurePosition.x < rocketPosition.x+width_ && figurePosition.z > rocketPosition.z-height_ && figurePosition.z < rocketPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
else if (attachedToFigure_ == true)
{
- fuel_ -= dt;
- if (fuel_ < 0.0)
- {
- figure_->StopBoots(this);
- }
+ fuel_ -= dt;
+ if (fuel_ < 0.0)
+ {
+ figure_->StopBoots(this);
+ }
}
}
void JumpBoots::touchFigure()
{
- JumpItem::touchFigure();
+ JumpItem::touchFigure();
- attachedToFigure_ = figure_->StartBoots(this);
+ attachedToFigure_ = figure_->StartBoots(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpEnemy.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpEnemy.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpEnemy.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -106,12 +106,12 @@
if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0))
{
- velocity.x = -velocity.x;
+ velocity.x = -velocity.x;
}
if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
{
- velocity.z = -velocity.z;
+ velocity.z = -velocity.z;
}
// Set the position, velocity and acceleration of the enemy, if they have changed.
@@ -129,7 +129,7 @@
Vector3 figurePosition = figure_->getPosition();
if(figurePosition.x > enemyPosition.x-width_ && figurePosition.x < enemyPosition.x+width_ && figurePosition.z > enemyPosition.z-height_ && figurePosition.z < enemyPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
}
@@ -157,9 +157,9 @@
void JumpEnemy::touchFigure()
{
- if (dead_ == false)
- {
- figure_->CollisionWithEnemy(this);
- }
+ if (dead_ == false)
+ {
+ figure_->CollisionWithEnemy(this);
+ }
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpFigure.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpFigure.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpFigure.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -44,7 +44,7 @@
{
RegisterObject(JumpFigure);
- // initialize variables
+ // initialize variables
leftHand_ = NULL;
rightHand_ = NULL;
fieldHeight_ = 0;
@@ -97,99 +97,99 @@
void JumpFigure::tick(float dt)
{
- SUPER(JumpFigure, tick, dt);
+ SUPER(JumpFigure, tick, dt);
if (hasLocalController())
{
- timeSinceLastFire_ += dt;
+ timeSinceLastFire_ += dt;
- // Move up/down
- Vector3 velocity = getVelocity();
- if (rocketActive_ == true)
- {
- velocity.z = rocketSpeed_;
- }
- else if (propellerActive_ == true)
- {
- velocity.z = propellerSpeed_;
- }
- else
- {
- velocity.z -= gravityAcceleration_;
- }
+ // Move up/down
+ Vector3 velocity = getVelocity();
+ if (rocketActive_ == true)
+ {
+ velocity.z = rocketSpeed_;
+ }
+ else if (propellerActive_ == true)
+ {
+ velocity.z = propellerSpeed_;
+ }
+ else
+ {
+ velocity.z -= gravityAcceleration_;
+ }
- // Animate Hands
- if (animateHands_ == true)
- {
- if (turnUp_ == true)
- {
- handAngle_ += handSpeed_ * dt;
- }
- else
- {
- handAngle_ -= handSpeed_ * dt;
- }
- if (handAngle_ > handMaxAngle_)
- {
- turnUp_ = false;
- }
- if (handAngle_ <= handMinAngle_)
- {
- animateHands_ = false;
- }
+ // Animate Hands
+ if (animateHands_ == true)
+ {
+ if (turnUp_ == true)
+ {
+ handAngle_ += handSpeed_ * dt;
+ }
+ else
+ {
+ handAngle_ -= handSpeed_ * dt;
+ }
+ if (handAngle_ > handMaxAngle_)
+ {
+ turnUp_ = false;
+ }
+ if (handAngle_ <= handMinAngle_)
+ {
+ animateHands_ = false;
+ }
- if (leftHand_ != NULL)
- {
- leftHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(-handAngle_));
- }
- if (rightHand_ != NULL)
- {
- rightHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(handAngle_));
- }
- }
+ if (leftHand_ != NULL)
+ {
+ leftHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(-handAngle_));
+ }
+ if (rightHand_ != NULL)
+ {
+ rightHand_->setOrientation(Vector3(0.0, 1.0, 0.0), Degree(handAngle_));
+ }
+ }
- // Move left/right
- if (dead_ == false)
- {
- velocity.x = -mouseFactor_*horizontalSpeed_;
- }
- else
- {
- velocity.x = 0.0;
- }
+ // Move left/right
+ if (dead_ == false)
+ {
+ velocity.x = -mouseFactor_*horizontalSpeed_;
+ }
+ else
+ {
+ velocity.x = 0.0;
+ }
- // Cheats
- /*if (moveUpPressed_ == true)
- {
- velocity.z = 400.0f;
- moveUpPressed_ = false;
- dead_ = false;
- }
- if (moveDownPressed_ == true)
- {
- moveDownPressed_ = false;
- }*/
+ // Cheats
+ /*if (moveUpPressed_ == true)
+ {
+ velocity.z = 400.0f;
+ moveUpPressed_ = false;
+ dead_ = false;
+ }
+ if (moveDownPressed_ == true)
+ {
+ moveDownPressed_ = false;
+ }*/
- setVelocity(velocity);
+ setVelocity(velocity);
- if (firePressed_ && timeSinceLastFire_ >= maxFireRate_)
- {
- firePressed_ = false;
- timeSinceLastFire_ = 0.0;
- fireSignal_ = true;
- }
+ if (firePressed_ && timeSinceLastFire_ >= maxFireRate_)
+ {
+ firePressed_ = false;
+ timeSinceLastFire_ = 0.0;
+ fireSignal_ = true;
+ }
}
// Move through the left and right screen boundaries
Vector3 position = getPosition();
if (position.x < -fieldWidth_*1.1)
{
- position.x = fieldWidth_*1.1;
+ position.x = fieldWidth_*1.1;
}
else if (position.x > fieldWidth_*1.1)
{
- position.x = -fieldWidth_*1.1;
+ position.x = -fieldWidth_*1.1;
}
setPosition(position);
@@ -203,175 +203,175 @@
void JumpFigure::JumpFromPlatform(JumpPlatform* platform)
{
- if (dead_ == false)
- {
- Vector3 velocity = getVelocity();
- velocity.z = (bootsActive_ ? 1.2*jumpSpeed_ : jumpSpeed_);
- setVelocity(velocity);
+ if (dead_ == false)
+ {
+ Vector3 velocity = getVelocity();
+ velocity.z = (bootsActive_ ? 1.2*jumpSpeed_ : jumpSpeed_);
+ setVelocity(velocity);
- animateHands_ = true;
- handAngle_ = 0.0;
- turnUp_ = true;
- }
+ animateHands_ = true;
+ handAngle_ = 0.0;
+ turnUp_ = true;
+ }
}
void JumpFigure::JumpFromSpring(JumpSpring* spring)
{
- if (dead_ == false)
- {
- Vector3 velocity = getVelocity();
- velocity.z = 1.2*jumpSpeed_;
- setVelocity(velocity);
- }
+ if (dead_ == false)
+ {
+ Vector3 velocity = getVelocity();
+ velocity.z = 1.2*jumpSpeed_;
+ setVelocity(velocity);
+ }
}
void JumpFigure::CollisionWithEnemy(JumpEnemy* enemy)
- {
- if (rocketActive_ == false && propellerActive_ == false && shieldActive_ == false)
- {
- dead_ = true;
- }
- }
+ {
+ if (rocketActive_ == false && propellerActive_ == false && shieldActive_ == false)
+ {
+ dead_ = true;
+ }
+ }
bool JumpFigure::StartRocket(JumpRocket* rocket)
{
- if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
- {
- attach(rocket);
- rocket->setPosition(0.0, rocketPos_, 0.0);
- rocket->setVelocity(0.0, 0.0, 0.0);
- rocketActive_ = true;
+ if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
+ {
+ attach(rocket);
+ rocket->setPosition(0.0, rocketPos_, 0.0);
+ rocket->setVelocity(0.0, 0.0, 0.0);
+ rocketActive_ = true;
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
void JumpFigure::StopRocket(JumpRocket* rocket)
{
- rocket->setPosition(0.0, 0.0, -1000.0);
- rocket->setVelocity(0.0, 0.0, 0.0);
- detach(rocket);
- rocket->destroy();
- rocketActive_ = false;
+ rocket->setPosition(0.0, 0.0, -1000.0);
+ rocket->setVelocity(0.0, 0.0, 0.0);
+ detach(rocket);
+ rocket->destroy();
+ rocketActive_ = false;
}
bool JumpFigure::StartPropeller(JumpPropeller* propeller)
{
- if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
- {
- attach(propeller);
- propeller->setPosition(0.0, 0.0, propellerPos_);
- propeller->setVelocity(0.0, 0.0, 0.0);
- propellerActive_ = true;
+ if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
+ {
+ attach(propeller);
+ propeller->setPosition(0.0, 0.0, propellerPos_);
+ propeller->setVelocity(0.0, 0.0, 0.0);
+ propellerActive_ = true;
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
void JumpFigure::StopPropeller(JumpPropeller* propeller)
{
- propeller->setPosition(0.0, 0.0, -1000.0);
- propeller->setVelocity(0.0, 0.0, 0.0);
- detach(propeller);
- propeller->destroy();
- propellerActive_ = false;
+ propeller->setPosition(0.0, 0.0, -1000.0);
+ propeller->setVelocity(0.0, 0.0, 0.0);
+ detach(propeller);
+ propeller->destroy();
+ propellerActive_ = false;
}
bool JumpFigure::StartBoots(JumpBoots* boots)
{
- if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
- {
- attach(boots);
- boots->setPosition(0.0, 0.0, bootsPos_);
- boots->setVelocity(0.0, 0.0, 0.0);
- bootsActive_ = true;
+ if (rocketActive_ == false && propellerActive_ == false && bootsActive_ == false)
+ {
+ attach(boots);
+ boots->setPosition(0.0, 0.0, bootsPos_);
+ boots->setVelocity(0.0, 0.0, 0.0);
+ bootsActive_ = true;
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
void JumpFigure::StopBoots(JumpBoots* boots)
{
- boots->setPosition(0.0, 0.0, -1000.0);
- boots->setVelocity(0.0, 0.0, 0.0);
- detach(boots);
- boots->destroy();
- bootsActive_ = false;
+ boots->setPosition(0.0, 0.0, -1000.0);
+ boots->setVelocity(0.0, 0.0, 0.0);
+ detach(boots);
+ boots->destroy();
+ bootsActive_ = false;
}
bool JumpFigure::StartShield(JumpShield* shield)
{
- if (shieldActive_ == false)
- {
- attach(shield);
- shield->setPosition(0.0, 0.0, propellerPos_);
- shield->setVelocity(0.0, 0.0, 0.0);
- shieldActive_ = true;
+ if (shieldActive_ == false)
+ {
+ attach(shield);
+ shield->setPosition(0.0, 0.0, propellerPos_);
+ shield->setVelocity(0.0, 0.0, 0.0);
+ shieldActive_ = true;
- return true;
- }
+ return true;
+ }
- return false;
+ return false;
}
void JumpFigure::StopShield(JumpShield* shield)
{
- shield->setPosition(0.0, 0.0, -1000.0);
- shield->setVelocity(0.0, 0.0, 0.0);
- detach(shield);
- shield->destroy();
- shieldActive_ = false;
+ shield->setPosition(0.0, 0.0, -1000.0);
+ shield->setVelocity(0.0, 0.0, 0.0);
+ detach(shield);
+ shield->destroy();
+ shieldActive_ = false;
}
void JumpFigure::InitializeAnimation(Context* context)
{
- leftHand_ = new Model(context);
- rightHand_ = new Model(context);
+ leftHand_ = new Model(context);
+ rightHand_ = new Model(context);
- leftHand_->addTemplate(modelLeftHand_);
- rightHand_->addTemplate(modelRightHand_);
+ leftHand_->addTemplate(modelLeftHand_);
+ rightHand_->addTemplate(modelRightHand_);
- attach(leftHand_);
- attach(rightHand_);
+ attach(leftHand_);
+ attach(rightHand_);
}
void JumpFigure::moveFrontBack(const Vector2& value)
{
- if (value.x > 0)
- {
- moveUpPressed_ = true;
- moveDownPressed_ = false;
- }
- else
- {
- moveUpPressed_ = false;
- moveDownPressed_ = true;
- }
+ if (value.x > 0)
+ {
+ moveUpPressed_ = true;
+ moveDownPressed_ = false;
+ }
+ else
+ {
+ moveUpPressed_ = false;
+ moveDownPressed_ = true;
+ }
}
void JumpFigure::moveRightLeft(const Vector2& value)
{
- if (value.x > 0)
- {
- moveLeftPressed_ = false;
- moveRightPressed_ = true;
- }
- else
- {
- moveLeftPressed_ = true;
- moveRightPressed_ = false;
- }
+ if (value.x > 0)
+ {
+ moveLeftPressed_ = false;
+ moveRightPressed_ = true;
+ }
+ else
+ {
+ moveLeftPressed_ = true;
+ moveRightPressed_ = false;
+ }
}
void JumpFigure::rotateYaw(const Vector2& value)
{
- horizontalSpeed_ = value.x;
+ horizontalSpeed_ = value.x;
}
void JumpFigure::rotatePitch(const Vector2& value)
@@ -393,6 +393,6 @@
void JumpFigure::fired(unsigned int firemode)
{
- firePressed_ = true;
+ firePressed_ = true;
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpFigure.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpFigure.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpFigure.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -84,14 +84,14 @@
{ rocketPos_ = rocketPos; }
const float getRocketPos() const
{ return rocketPos_; }
- void setPropellerPos(const float propellerPos)
- { propellerPos_ = propellerPos; }
- const float getPropellerPos() const
- { return propellerPos_; }
- void setBootsPos(const float bootsPos)
- { bootsPos_ = bootsPos; }
- const float getBootsPos() const
- { return bootsPos_; }
+ void setPropellerPos(const float propellerPos)
+ { propellerPos_ = propellerPos; }
+ const float getPropellerPos() const
+ { return propellerPos_; }
+ void setBootsPos(const float bootsPos)
+ { bootsPos_ = bootsPos; }
+ const float getBootsPos() const
+ { return bootsPos_; }
void setJumpSpeed(const float jumpSpeed)
{ jumpSpeed_ = jumpSpeed; }
const float getJumpSpeed() const
Modified: code/branches/presentationFS14/src/modules/jump/JumpItem.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpItem.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpItem.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -83,12 +83,12 @@
if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0))
{
- velocity.x = -velocity.x;
+ velocity.x = -velocity.x;
}
if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
{
- velocity.z = -velocity.z;
+ velocity.z = -velocity.z;
}
// Set the position, velocity and acceleration of the item, if they have changed.
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatform.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatform.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatform.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -55,20 +55,20 @@
//initialize sound
if (GameMode::isMaster())
- {
- defScoreSound_ = new WorldSound(this->getContext());
- defScoreSound_->setVolume(1.0f);
- defBatSound_ = new WorldSound(this->getContext());
- defBatSound_->setVolume(0.4f);
- defBoundarySound_ = new WorldSound(this->getContext());
- defBoundarySound_->setVolume(0.5f);
- }
- else
- {
- defScoreSound_ = 0;
- defBatSound_ = 0;
- defBoundarySound_ = 0;
- }
+ {
+ defScoreSound_ = new WorldSound(this->getContext());
+ defScoreSound_->setVolume(1.0f);
+ defBatSound_ = new WorldSound(this->getContext());
+ defBatSound_->setVolume(0.4f);
+ defBoundarySound_ = new WorldSound(this->getContext());
+ defBoundarySound_->setVolume(0.5f);
+ }
+ else
+ {
+ defScoreSound_ = 0;
+ defBatSound_ = 0;
+ defBoundarySound_ = 0;
+ }
setPosition(Vector3(0,0,0));
setVelocity(Vector3(0,0,0));
@@ -119,7 +119,7 @@
if(figureVelocity.z < 0 && figurePosition.x > platformPosition.x-width_/2 && figurePosition.x < platformPosition.x+width_/2 && figurePosition.z > platformPosition.z-height_/2*tolerance && figurePosition.z < platformPosition.z+height_/2)
{
- touchFigure();
+ touchFigure();
}
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -71,20 +71,20 @@
void JumpPlatformDisappear::setProperties(bool active)
{
- active_ = active;
+ active_ = active;
}
bool JumpPlatformDisappear::isActive()
{
- return active_;
+ return active_;
}
void JumpPlatformDisappear::touchFigure()
{
- if (isActive())
- {
- figure_->JumpFromPlatform(this);
- active_ = false;
- }
+ if (isActive())
+ {
+ figure_->JumpFromPlatform(this);
+ active_ = false;
+ }
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformDisappear.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -44,7 +44,7 @@
class _JumpExport JumpPlatformDisappear : public JumpPlatform
{
public:
- JumpPlatformDisappear(Context* context);
+ JumpPlatformDisappear(Context* context);
virtual ~JumpPlatformDisappear();
virtual void tick(float dt);
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformFake.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformFake.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformFake.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -47,7 +47,7 @@
class _JumpExport JumpPlatformFake : public JumpPlatform
{
public:
- JumpPlatformFake(Context* context);
+ JumpPlatformFake(Context* context);
virtual ~JumpPlatformFake();
virtual void tick(float dt);
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -71,7 +71,7 @@
if ((position.x < leftBoundary_ && velocity.x < 0) || (position.x > rightBoundary_ && velocity.x > 0))
{
- velocity.x = -velocity.x;
+ velocity.x = -velocity.x;
}
// Set the position, velocity and acceleration of the ball, if they have changed.
@@ -87,13 +87,13 @@
void JumpPlatformHMove::setProperties(float leftBoundary, float rightBoundary, float speed)
{
- leftBoundary_ = leftBoundary;
- rightBoundary_ = rightBoundary;
+ leftBoundary_ = leftBoundary;
+ rightBoundary_ = rightBoundary;
setVelocity(Vector3(speed,0,0));
}
void JumpPlatformHMove::touchFigure()
{
- figure_->JumpFromPlatform(this);
+ figure_->JumpFromPlatform(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformHMove.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -42,7 +42,7 @@
class _JumpExport JumpPlatformHMove : public JumpPlatform
{
public:
- JumpPlatformHMove(Context* context);
+ JumpPlatformHMove(Context* context);
virtual ~JumpPlatformHMove();
virtual void tick(float dt);
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -67,6 +67,6 @@
void JumpPlatformStatic::touchFigure()
{
- figure_->JumpFromPlatform(this);
+ figure_->JumpFromPlatform(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformStatic.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -41,7 +41,7 @@
class _JumpExport JumpPlatformStatic : public JumpPlatform
{
public:
- JumpPlatformStatic(Context* context);
+ JumpPlatformStatic(Context* context);
virtual ~JumpPlatformStatic();
virtual void tick(float dt);
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -74,8 +74,8 @@
if (time_ < effectStartTime_ && particleSpawner_ == NULL)
{
- particleSpawner_ = new ParticleSpawner(getContext());
- particleSpawner_->setSource(effectPath_);
+ particleSpawner_ = new ParticleSpawner(getContext());
+ particleSpawner_->setSource(effectPath_);
particleSpawner_->setLoop(false);
particleSpawner_->setLOD(LODParticle::Low);
particleSpawner_->setLifetime(effectStartTime_);
@@ -86,19 +86,19 @@
void JumpPlatformTimer::setProperties(float time)
{
- time_ = time;
+ time_ = time;
}
bool JumpPlatformTimer::isActive(void)
{
- return time_ > 0.0;
+ return time_ > 0.0;
}
void JumpPlatformTimer::touchFigure()
{
- if (isActive())
- {
- figure_->JumpFromPlatform(this);
- }
+ if (isActive())
+ {
+ figure_->JumpFromPlatform(this);
+ }
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformTimer.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -48,7 +48,7 @@
class _JumpExport JumpPlatformTimer : public JumpPlatform
{
public:
- JumpPlatformTimer(Context* context);
+ JumpPlatformTimer(Context* context);
virtual ~JumpPlatformTimer();
virtual void tick(float dt);
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -70,7 +70,7 @@
if ((position.z < lowerBoundary_ && velocity.z < 0) || (position.z > upperBoundary_ && velocity.z > 0))
{
- velocity.z = -velocity.z;
+ velocity.z = -velocity.z;
}
// Set the position, velocity and acceleration of the ball, if they have changed.
@@ -86,8 +86,8 @@
void JumpPlatformVMove::setProperties(float lowerBoundary, float upperBoundary, float speed)
{
- lowerBoundary_ = lowerBoundary;
- upperBoundary_ = upperBoundary;
+ lowerBoundary_ = lowerBoundary;
+ upperBoundary_ = upperBoundary;
setVelocity(Vector3(0,0,speed));
@@ -95,6 +95,6 @@
void JumpPlatformVMove::touchFigure()
{
- figure_->JumpFromPlatform(this);
+ figure_->JumpFromPlatform(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.h
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPlatformVMove.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -38,7 +38,7 @@
class _JumpExport JumpPlatformVMove : public JumpPlatform
{
public:
- JumpPlatformVMove(Context* context);
+ JumpPlatformVMove(Context* context);
virtual ~JumpPlatformVMove();
virtual void tick(float dt);
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
Modified: code/branches/presentationFS14/src/modules/jump/JumpProjectile.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpProjectile.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpProjectile.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -70,17 +70,17 @@
Vector3 projectilePosition = getPosition();
- for (ObjectList<JumpEnemy>::iterator it = ObjectList<JumpEnemy>::begin(); it != ObjectList<JumpEnemy>::end(); ++it)
- {
- Vector3 enemyPosition = it->getPosition();
- float enemyWidth = it->getWidth();
- float enemyHeight = it->getHeight();
+ for (ObjectList<JumpEnemy>::iterator it = ObjectList<JumpEnemy>::begin(); it != ObjectList<JumpEnemy>::end(); ++it)
+ {
+ Vector3 enemyPosition = it->getPosition();
+ float enemyWidth = it->getWidth();
+ float enemyHeight = it->getHeight();
- if(projectilePosition.x > enemyPosition.x-enemyWidth && projectilePosition.x < enemyPosition.x+enemyWidth && projectilePosition.z > enemyPosition.z-enemyHeight && projectilePosition.z < enemyPosition.z+enemyHeight)
- {
- it->dead_ = true;
- }
- }
+ if(projectilePosition.x > enemyPosition.x-enemyWidth && projectilePosition.x < enemyPosition.x+enemyWidth && projectilePosition.z > enemyPosition.z-enemyHeight && projectilePosition.z < enemyPosition.z+enemyHeight)
+ {
+ it->dead_ = true;
+ }
+ }
}
void JumpProjectile::setFigure(WeakPtr<JumpFigure> figure)
Modified: code/branches/presentationFS14/src/modules/jump/JumpPropeller.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpPropeller.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpPropeller.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -82,27 +82,27 @@
if(figurePosition.x > PropellerPosition.x-width_ && figurePosition.x < PropellerPosition.x+width_ && figurePosition.z > PropellerPosition.z-height_ && figurePosition.z < PropellerPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
else if (attachedToFigure_ == true)
{
- fuel_ -= dt;
- if (fuel_ < 0.0)
- {
- figure_->StopPropeller(this);
- }
+ fuel_ -= dt;
+ if (fuel_ < 0.0)
+ {
+ figure_->StopPropeller(this);
+ }
}
}
void JumpPropeller::touchFigure()
{
- JumpItem::touchFigure();
+ JumpItem::touchFigure();
- attachedToFigure_ = figure_->StartPropeller(this);
- if (attachedToFigure_)
- {
- setAngularVelocity(Vector3(0,0,10.0));
- }
+ attachedToFigure_ = figure_->StartPropeller(this);
+ if (attachedToFigure_)
+ {
+ setAngularVelocity(Vector3(0,0,10.0));
+ }
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpRocket.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpRocket.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpRocket.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -79,23 +79,23 @@
if(figurePosition.x > rocketPosition.x-width_ && figurePosition.x < rocketPosition.x+width_ && figurePosition.z > rocketPosition.z-height_ && figurePosition.z < rocketPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
else if (attachedToFigure_ == true)
{
- fuel_ -= dt;
- if (fuel_ < 0.0)
- {
- figure_->StopRocket(this);
- }
+ fuel_ -= dt;
+ if (fuel_ < 0.0)
+ {
+ figure_->StopRocket(this);
+ }
}
}
void JumpRocket::touchFigure()
{
- JumpItem::touchFigure();
+ JumpItem::touchFigure();
- attachedToFigure_ = figure_->StartRocket(this);
+ attachedToFigure_ = figure_->StartRocket(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpScore.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpScore.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpScore.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -78,18 +78,18 @@
if (player_ != NULL)
{
- if (showScore_ == true)
- {
- int score = owner_->getScore(player_);
+ if (showScore_ == true)
+ {
+ int score = owner_->getScore(player_);
- std::string str = multi_cast<std::string>(score);
- setCaption(str);
- }
- else if (showMessages_ == true)
- {
+ std::string str = multi_cast<std::string>(score);
+ setCaption(str);
+ }
+ else if (showMessages_ == true)
+ {
- setCaption(owner_->getDead(player_) == true ? gameOverText_ : "");
- }
+ setCaption(owner_->getDead(player_) == true ? gameOverText_ : "");
+ }
}
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpShield.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpShield.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpShield.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -82,23 +82,23 @@
if(figurePosition.x > shieldPosition.x-width_ && figurePosition.x < shieldPosition.x+width_ && figurePosition.z > shieldPosition.z-height_ && figurePosition.z < shieldPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
else if (attachedToFigure_ == true)
{
- fuel_ -= dt;
- if (fuel_ < 0.0)
- {
- figure_->StopShield(this);
- }
+ fuel_ -= dt;
+ if (fuel_ < 0.0)
+ {
+ figure_->StopShield(this);
+ }
}
}
void JumpShield::touchFigure()
{
- JumpItem::touchFigure();
+ JumpItem::touchFigure();
- attachedToFigure_ = figure_->StartShield(this);
+ attachedToFigure_ = figure_->StartShield(this);
}
}
Modified: code/branches/presentationFS14/src/modules/jump/JumpSpring.cc
===================================================================
--- code/branches/presentationFS14/src/modules/jump/JumpSpring.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/jump/JumpSpring.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -73,8 +73,8 @@
if (stretch_ > 1.0)
{
- stretch_ -= dt;
- setScale3D(1.0, 1.0, stretch_);
+ stretch_ -= dt;
+ setScale3D(1.0, 1.0, stretch_);
}
Vector3 springPosition = getWorldPosition();
@@ -86,25 +86,25 @@
if(figureVelocity.z < 0 && figurePosition.x > springPosition.x-width_ && figurePosition.x < springPosition.x+width_ && figurePosition.z > springPosition.z-height_ && figurePosition.z < springPosition.z+height_)
{
- touchFigure();
+ touchFigure();
}
}
}
void JumpSpring::touchFigure()
{
- JumpItem::touchFigure();
+ JumpItem::touchFigure();
- stretch_ = 3.0;
+ stretch_ = 3.0;
- accelerateFigure();
+ accelerateFigure();
}
void JumpSpring::accelerateFigure()
{
- if (figure_ != 0)
- {
- figure_->JumpFromSpring(this);
- }
+ if (figure_ != 0)
+ {
+ figure_->JumpFromSpring(this);
+ }
}
}
Modified: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -32,7 +32,7 @@
namespace orxonox
{
- RegisterClass(TeamTargetProxy);
+ RegisterClass(TeamTargetProxy);
/**
@brief
@@ -41,20 +41,20 @@
@param context
The context
*/
- TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
- {
- RegisterObject(TeamTargetProxy);
+ TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
+ {
+ RegisterObject(TeamTargetProxy);
- this->once_ = false;
- }
+ this->once_ = false;
+ }
/**
@brief
Destructor. Nothing to see here.
*/
- TeamTargetProxy::~TeamTargetProxy()
- {
- }
+ TeamTargetProxy::~TeamTargetProxy()
+ {
+ }
/**
@brief
@@ -62,10 +62,10 @@
That's all there is.
*/
- void TeamTargetProxy::tick(float dt)
- {
- if (!this->isActive() || !this->getControllableEntity())
- return;
+ void TeamTargetProxy::tick(float dt)
+ {
+ if (!this->isActive() || !this->getControllableEntity())
+ return;
ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
@@ -101,5 +101,5 @@
this->getControllableEntity()->setTarget(parenttarget);
}
}
- }
-}
\ No newline at end of file
+ }
+}
Modified: code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TeamTargetProxy.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -34,27 +34,27 @@
namespace orxonox
{
- /**
- @brief
- A controller, that just copies the team and the target of a parent for itself and it's controllable entity.
+ /**
+ @brief
+ A controller, that just copies the team and the target of a parent for itself and it's controllable entity.
- Useful for following (and similar) situations: (-> means attached to)
- turret (rotates) -> some kind of turret base (looks nice) -> spaceship (flies around)
- The turret has a controller that wants to copy the spaceship's target and team. In this case it doesn't work though,
- because the turret isn't directly attached to the spaceship. Here's where this controller comes in. Drawback: the base
- has to be controllable and ticks every second (performance?)
- */
- class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
- {
- public:
- TeamTargetProxy(Context* context);
- virtual ~TeamTargetProxy();
+ Useful for following (and similar) situations: (-> means attached to)
+ turret (rotates) -> some kind of turret base (looks nice) -> spaceship (flies around)
+ The turret has a controller that wants to copy the spaceship's target and team. In this case it doesn't work though,
+ because the turret isn't directly attached to the spaceship. Here's where this controller comes in. Drawback: the base
+ has to be controllable and ticks every second (performance?)
+ */
+ class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
+ {
+ public:
+ TeamTargetProxy(Context* context);
+ virtual ~TeamTargetProxy();
- virtual void tick(float dt);
+ virtual void tick(float dt);
- private:
- bool once_; //!< Flag for executing code in the tick function only once.
- };
+ private:
+ bool once_; //!< Flag for executing code in the tick function only once.
+ };
}
- #endif
\ No newline at end of file
+ #endif
Modified: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -32,7 +32,7 @@
namespace orxonox
{
- RegisterClass(TurretController);
+ RegisterClass(TurretController);
/**
@brief
@@ -41,22 +41,22 @@
@param context
The context
*/
- TurretController::TurretController(Context* context) : ArtificialController(context)
- {
- RegisterObject(TurretController);
+ TurretController::TurretController(Context* context) : ArtificialController(context)
+ {
+ RegisterObject(TurretController);
- this->once_ = false;
+ this->once_ = false;
- }
+ }
/**
@brief
Destructor. Nothing to see here.
*/
- TurretController::~TurretController()
- {
+ TurretController::~TurretController()
+ {
- }
+ }
/**
@brief
@@ -68,65 +68,65 @@
@see targetScore
The function that scores the pawns.
*/
- void TurretController::searchTarget()
- {
+ void TurretController::searchTarget()
+ {
Turret* turret = orxonox_cast<Turret*>(this->getControllableEntity());
//The controller might find a target before teams are set, so we need to check again here.
if(this->target_ && turret->isInRange(target_) != -1.f && !FormationController::sameTeam(turret, this->target_, this->getGametype()))
{
- return;
+ return;
}
else
{
- this->forgetTarget();
- turret->setTarget(0);
+ this->forgetTarget();
+ turret->setTarget(0);
}
ControllableEntity* parent = orxonox_cast<ControllableEntity*>(turret->getParent());
if(parent)
{
- Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
- if(parenttarget && turret->isInRange(parenttarget))
- {
- this->setTarget(parenttarget);
- turret->setTarget(parenttarget);
- return;
- }
+ Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
+ if(parenttarget && turret->isInRange(parenttarget))
+ {
+ this->setTarget(parenttarget);
+ turret->setTarget(parenttarget);
+ return;
+ }
}
float minScore = FLT_MAX;
float tempScore;
Pawn* minScorePawn = 0;
- for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
{
- Pawn* entity = orxonox_cast<Pawn*>(*it);
+ Pawn* entity = orxonox_cast<Pawn*>(*it);
if (!entity || FormationController::sameTeam(this->getControllableEntity(), entity, this->getGametype()))
- continue;
+ continue;
tempScore = turret->isInRange(entity);
if(tempScore != -1.f)
{
- if(tempScore < minScore)
- {
- minScore = tempScore;
- minScorePawn = entity;
- }
+ if(tempScore < minScore)
+ {
+ minScore = tempScore;
+ minScorePawn = entity;
+ }
}
- }
+ }
this->setTarget(minScorePawn);
turret->setTarget(minScorePawn);
- }
+ }
/**
@brief
Tests, if the turret is looking at the target, with a specified tolerance
- This uses the world position as opposed to the local position in the old version.
+ This uses the world position as opposed to the local position in the old version.
- @param angle
- The tolerance, in radians
+ @param angle
+ The tolerance, in radians
*/
bool TurretController::isLookingAtTargetNew(float angle) const
{
@@ -139,28 +139,28 @@
The more health and distance a pawn has, the higher the score. This means lower equals better.
- @param pawn
- The pawn to score
+ @param pawn
+ The pawn to score
- @param distance
- The distance. Can be squared or normed, doesn't matter as long as all are treated the same.
+ @param distance
+ The distance. Can be squared or normed, doesn't matter as long as all are treated the same.
*/
- float TurretController::targetScore(Pawn* pawn, float distance) const
- {
- return pawn->getHealth()/pawn->getMaxHealth() + distance;
- }
+ float TurretController::targetScore(Pawn* pawn, float distance) const
+ {
+ return pawn->getHealth()/pawn->getMaxHealth() + distance;
+ }
/**
- @brief
- Does all the controlling of the turret.
+ @brief
+ Does all the controlling of the turret.
- If the turret has a parent, copies the team from there, if it's not already set.
- Other actions are: Search a target. If a target has been found, aim and shoot at it.
+ If the turret has a parent, copies the team from there, if it's not already set.
+ Other actions are: Search a target. If a target has been found, aim and shoot at it.
*/
- void TurretController::tick(float dt)
- {
- if (!this->isActive() || !this->getControllableEntity())
- return;
+ void TurretController::tick(float dt)
+ {
+ if (!this->isActive() || !this->getControllableEntity())
+ return;
ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
@@ -170,7 +170,7 @@
}
if(!this->once_)
- this->once_ = true;
+ this->once_ = true;
//Teams aren't set immediately, after creation, so we have to check every tick...
if(parent)
@@ -187,16 +187,16 @@
this->getControllableEntity()->setTeam(parent->getTeam());
}
- this->searchTarget();
- if(this->target_)
- {
- Turret* turret = orxonox_cast<Turret*> (this->getControllableEntity());
- this->aimAtTarget();
- turret->aimAtPosition(target_->getWorldPosition());
- if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
- {
- this->getControllableEntity()->fire(0);
- }
- }
- }
- }
\ No newline at end of file
+ this->searchTarget();
+ if(this->target_)
+ {
+ Turret* turret = orxonox_cast<Turret*> (this->getControllableEntity());
+ this->aimAtTarget();
+ turret->aimAtPosition(target_->getWorldPosition());
+ if(this->isLookingAtTargetNew(Degree(5).valueRadians()))
+ {
+ this->getControllableEntity()->fire(0);
+ }
+ }
+ }
+ }
Modified: code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h
===================================================================
--- code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/modules/objects/controllers/TurretController.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -38,28 +38,28 @@
namespace orxonox
{
- /**
- @brief
- Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
+ /**
+ @brief
+ Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
- The controllableEntity gets casted to Turret, so this controller won't work for anything else.
- */
- class _OrxonoxExport TurretController : public ArtificialController, public Tickable
- {
- public:
- TurretController(Context* context);
- virtual ~TurretController();
+ The controllableEntity gets casted to Turret, so this controller won't work for anything else.
+ */
+ class _OrxonoxExport TurretController : public ArtificialController, public Tickable
+ {
+ public:
+ TurretController(Context* context);
+ virtual ~TurretController();
- virtual void tick(float dt);
+ virtual void tick(float dt);
- private:
+ private:
- void searchTarget();
- bool isLookingAtTargetNew(float angle) const;
- float targetScore(Pawn* pawn, float distance) const;
+ void searchTarget();
+ bool isLookingAtTargetNew(float angle) const;
+ float targetScore(Pawn* pawn, float distance) const;
- bool once_; //!< Flag for executing code in the tick function only once.
- };
+ bool once_; //!< Flag for executing code in the tick function only once.
+ };
}
- #endif
\ No newline at end of file
+ #endif
Modified: code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.cc
===================================================================
--- code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.cc 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.cc 2015-01-31 16:31:23 UTC (rev 10215)
@@ -105,7 +105,6 @@
ctrlid += 1;
}
-
bool ControllerDirector::preparationToTakeControl(BaseObject * trigger)
{
this->pTrigger_ = orxonox_cast<PlayerTrigger*>(trigger);
@@ -129,8 +128,8 @@
return false;
}
- this->entity_ = this->player_->getControllableEntity();
- assert(this->entity_);
+ this->entity_ = this->player_->getControllableEntity();
+ assert(this->entity_);
return true;
}
Modified: code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.h
===================================================================
--- code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.h 2015-01-31 15:54:16 UTC (rev 10214)
+++ code/branches/presentationFS14/src/orxonox/controllers/ControllerDirector.h 2015-01-31 16:31:23 UTC (rev 10215)
@@ -44,26 +44,21 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
bool party(bool bTriggered, BaseObject* trigger);
- virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
-
-
+ virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+
+
/* Take over control of a given object */
- void takeControl(Controller * controller, BaseObject * trigger);
- bool preparationToTakeControl(BaseObject * trigger);
+ void takeControl(Controller * controller, BaseObject * trigger);
+ bool preparationToTakeControl(BaseObject * trigger);
// currently unused
- //void setNewController(Controller * controller);
-
+ //void setNewController(Controller * controller);
-
private:
-
PlayerInfo* player_;
ControllableEntity* entity_;
PlayerTrigger * pTrigger_;
Context* context_;
-
-
};
}
More information about the Orxonox-commit
mailing list