Changeset 11405 for code/branches/SuperOrxoBros_FS17/src
- Timestamp:
 - Apr 27, 2017, 3:08:16 PM (9 years ago)
 - Location:
 - code/branches/SuperOrxoBros_FS17/src/modules/superorxobros
 - Files:
 - 
          
- 2 added
 - 11 edited
 
- 
          CMakeLists.txt (modified) (1 diff)
 - 
          Orxo.h (modified) (1 diff)
 - 
          SOB.cc (modified) (3 diffs)
 - 
          SOB.h (modified) (1 diff)
 - 
          SOBFigure.cc (modified) (7 diffs)
 - 
          SOBFigure.h (modified) (1 diff)
 - 
          SOBHUDInfo.cc (added)
 - 
          SOBHUDInfo.h (added)
 - 
          SOBMushroom.cc (modified) (1 diff)
 - 
          SOBMushroom.h (modified) (1 diff)
 - 
          SOBPrereqs.h (modified) (1 diff)
 - 
          SOBQBlock.cc (modified) (3 diffs)
 - 
          SOBQBlock.h (modified) (1 diff)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
r11402 r11405 7 7 SOBQBlock.cc 8 8 SOBMushroom.cc 9 SOBHUDInfo.cc 9 10 10 11 )  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/Orxo.h
r11392 r11405 44 44 class Orxo : public SpaceShip 45 45 { 46 public:47 Orxo(Context* context);46 public: 47 Orxo(Context* context); 48 48 49 virtual void tick(float dt) override;49 virtual void tick(float dt) override; 50 50 51 51 52 52 // overwrite for 2d movement 53 virtual void moveFrontBack(const Vector2& value) override;54 virtual void moveRightLeft(const Vector2& value) override;53 virtual void moveFrontBack(const Vector2& value) override; 54 virtual void moveRightLeft(const Vector2& value) override; 55 55 56 56 // Starts or stops fireing 57 virtual void boost(bool bBoost) override;57 virtual void boost(bool bBoost) override; 58 58 59 59 //no rotation! 60 virtual void rotateYaw(const Vector2& value) override{};61 virtual void rotatePitch(const Vector2& value) override{};60 virtual void rotateYaw(const Vector2& value) override{}; 61 virtual void rotatePitch(const Vector2& value) override{}; 62 62 //return to main menu if game has ended. 63 virtual void rotateRoll(const Vector2& value) override;63 virtual void rotateRoll(const Vector2& value) override; 64 64 65 virtual void updateLevel();65 virtual void updateLevel(); 66 66 67 virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;67 virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 68 68 69 protected: 70 virtual void death() override; 71 private: 69 70 71 72 73 74 75 protected: 76 virtual void death() override; 77 private: 72 78 //SOB* getGame(); 73 79 //WeakPtr<SOB> game; 74 Camera* camera;75 float speed, damping, posforeward;76 float lastTimeFront, lastTimeLeft, lastTime;77 struct Velocity78 {79 float x;80 float y;81 } velocity, desiredVelocity;80 Camera* camera; 81 float speed, damping, posforeward; 82 float lastTimeFront, lastTimeLeft, lastTime; 83 struct Velocity 84 { 85 float x; 86 float y; 87 } velocity, desiredVelocity; 82 88 83 89 // WeakPtr<InvaderEnemy> lastEnemy;  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
r11402 r11405 64 64 this->center_ = nullptr; 65 65 figure_ = nullptr; 66 setHUDTemplate("JumpHUD"); 66 setHUDTemplate("SOBHUD"); 67 coins_=0; 68 points_=0; 69 timeLeft_=400.0; 67 70 68 71 } … … 105 108 106 109 // Call start for the parent class. 107 Deathmatch::start();110 Gametype::start(); 108 111 109 112 if (figure_ != nullptr) … … 152 155 orxout() << "DEED" << endl; 153 156 157 158 timeLeft_-=dt*2.5; 154 159 } 155 160  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
r11402 r11405 46 46 { 47 47 48 48 49 49 class _SOBExport SOB : public Deathmatch 50 50 { 51 public:51 public: 52 52 SOB(Context* context); //!< Constructor. Registers and initializes the object. 53 53 virtual ~SOB(); //!< Destructor. Cleans up, if initialized. 54 54 virtual void tick(float dt) override; 55 55 56 56 57 57 void setCenterpoint(SOBCenterpoint* center) 58 { this->center_ = center; }59 virtual void start() override;58 { this->center_ = center; } 59 virtual void start() override; 60 60 virtual void end() override; 61 61 virtual void spawnPlayer(PlayerInfo* player) override; 62 PlayerInfo* getPlayer() const;62 PlayerInfo* getPlayer() const; 63 63 64 65 64 int getPoints() { 65 return points_; 66 } 67 int getCoins() { 68 return coins_; 69 } 70 void addCoin() { 71 ++coins_; 72 points_+=200; 73 } 74 void addMushroom() { 75 points_+=1000; 76 } 77 int getTimeLeft() { 78 return timeLeft_; 79 } 80 81 82 virtual void playerEntered(PlayerInfo* player) override 83 { 84 Gametype::playerEntered(player); 85 } 86 87 88 WeakPtr<SOBCenterpoint> center_; 89 66 90 protected: 67 91 68 92 69 93 void cleanup(); //!< Cleans up the Gametype 70 WeakPtr<SOBCenterpoint> center_;71 94 WeakPtr<SOBFigure> figure_; 72 95 WeakPtr<Camera> camera; 73 74 75 }; 76 } 96 int points_; 97 int coins_; 98 float timeLeft_; 99 100 101 }; 102 } 77 103 78 104 #endif /* _Pong_H__ */  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
r11402 r11405 41 41 42 42 #include "SOBMushroom.h" 43 #include "SOB.h" 43 44 44 45 namespace orxonox … … 66 67 67 68 dead_ = false; 69 gotPowerUp_ = false; 70 68 71 setAngularFactor(0.0); 69 this->enableCollisionCallback();72 this->enableCollisionCallback(); 70 73 } 71 74 … … 76 79 isColliding_ = true; 77 80 SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject); 78 if (mush != nullptr) { 79 orxout() << "YEPPIE" << endl; 80 //DESTROY THE OTHER OBJECT otherObject.destroyLater(); 81 } 82 83 return true; 81 // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION 82 if (mush != nullptr && !(mush->hasCollided_)) { 83 otherObject->destroyLater(); 84 gotPowerUp_ = true; 85 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 86 SOBGame->addMushroom(); 87 mush->hasCollided_ = true; 88 89 } 90 91 return true; 84 92 } 85 93 … … 101 109 for (WorldEntity* object : this->getAttachedObjects()) 102 110 { 103 if (object->isA(Class(ParticleSpawner)))104 particlespawner_ = object;105 106 }107 108 }109 110 111 112 113 114 115 if (firePressed_ == false) {116 gravityAcceleration_ = 350.0;117 118 }119 120 if (hasLocalController())121 {122 Vector3 velocity = getVelocity();123 Vector3 position = getPosition();124 125 126 if (position.z < -100)127 dead_ = true;128 129 if (dead_) {130 velocity.x = 0;131 velocity.z = 0;132 setVelocity(velocity);133 return;134 }135 136 137 int maxvelocity_x = 100;138 int speedAddedPerTick = 5;139 int camMaxOffset = 25;140 141 timeSinceLastFire_ += dt;142 lastSpeed_z = velocity.z;111 if (object->isA(Class(ParticleSpawner))) 112 particlespawner_ = object; 113 114 } 115 116 } 117 118 119 120 121 122 123 if (firePressed_ == false) { 124 gravityAcceleration_ = 350.0; 125 126 } 127 128 if (hasLocalController()) 129 { 130 Vector3 velocity = getVelocity(); 131 Vector3 position = getPosition(); 132 133 134 if (position.z < -100) 135 dead_ = true; 136 137 if (dead_) { 138 velocity.x = 0; 139 velocity.z = 0; 140 setVelocity(velocity); 141 return; 142 } 143 144 145 int maxvelocity_x = 100; 146 int speedAddedPerTick = 5; 147 int camMaxOffset = 25; 148 149 timeSinceLastFire_ += dt; 150 lastSpeed_z = velocity.z; 143 151 144 152 145 153 146 154 //Handle the rocket fire from the jetpack 147 if (velocity.z > 40)148 particlespawner_->setVisible(true);149 else150 particlespawner_->setVisible(false);155 if (velocity.z > 40) 156 particlespawner_->setVisible(true); 157 else 158 particlespawner_->setVisible(false); 151 159 152 160 //If player hits space and does not move in z-dir 153 if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {154 gravityAcceleration_ = 100.0;161 if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) { 162 gravityAcceleration_ = 100.0; 155 163 velocity.z = 110; //150 156 164 } … … 163 171 if (moveRightPressed_) { 164 172 if (rot < 0.0) 165 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));173 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6)); 166 174 167 175 if (std::abs(velocity.x) < maxvelocity_x) { … … 178 186 } else if (moveLeftPressed_) { 179 187 if (rot >= 0.0) 180 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));188 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6)); 181 189 182 190 if (std::abs(velocity.x) < maxvelocity_x) { … … 200 208 cam->setPosition(campos); 201 209 } 202 if (campos.x - camMaxOffset > position.x) {210 if (campos.x - camMaxOffset > position.x) { 203 211 campos.x = position.x + camMaxOffset; 204 212 cam->setPosition(campos);  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
r11400 r11405 61 61 private: 62 62 63 bool gotPowerUp_; 63 64 bool moveUpPressed_; 64 65 bool moveDownPressed_;  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc
r11402 r11405 54 54 gravityAcceleration_ = 350.0; 55 55 speed_ = 0.0; 56 hasCollided_=false; 56 57 57 58 }  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h
r11402 r11405 60 60 { return speed_; } 61 61 62 62 bool hasCollided_; 63 63 protected: 64 64 float gravityAcceleration_;  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h
r11402 r11405 80 80 class SOBQBlock; 81 81 class SOBMushroom; 82 class SOBHUDInfo; 82 83 /* 83 84 class PongScore;*/  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBQBlock.cc
r11400 r11405 35 35 36 36 #include "core/CoreIncludes.h" 37 #include "core/XMLPort.h" 38 #include "SOB.h" 39 #include "SOBMushroom.h" 37 40 38 41 namespace orxonox … … 62 65 if (!used_ && v_z > 50.0) { 63 66 used_ = true; 64 orxout() << "WDestrozed the block" << v_z << endl;65 67 66 for (WorldEntity* object : this->getAttachedObjects()) 67 { 68 69 70 object->setVisible(!object->isVisible()); 68 for (WorldEntity* object : this->getAttachedObjects()) 69 object->setVisible(!object->isVisible()); 70 71 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 72 if (type_ == "Coin") { 73 SOBGame->addCoin(); 71 74 } 72 73 75 if (type_ == "Mushroom") { 76 spawnMushroom(); 77 } 74 78 75 79 } … … 78 82 79 83 84 void SOBQBlock::XMLPort(Element& xmlelement, XMLPort::Mode mode) 85 { 86 SUPER(SOBQBlock, XMLPort, xmlelement, mode); 87 XMLPortParam(SOBQBlock, "type", setType, getType, xmlelement, mode).defaultValues(false); 88 89 90 } 91 92 93 void SOBQBlock::spawnMushroom() { 94 SOBCenterpoint* center_ = ((SOB*)getGametype())->center_; 95 96 SOBMushroom* mush = new SOBMushroom(center_->getContext()); 97 Vector3 spawnpos = this->getWorldPosition(); 98 spawnpos.z += 0; 99 100 if (mush != nullptr && center_ != nullptr) 101 { 102 mush->addTemplate("mushroom"); 103 104 105 106 //newBoots->addTemplate(center_->getBootsTemplate()); 107 mush->setPosition(spawnpos); 108 //newBoots->setProperties(leftBoundary, rightBoundary, lowerBoundary, upperBoundary, xVelocity, zVelocity); 109 //newBoots->setFigure(figure_); 110 //center_->attach(newBoots); 111 } 112 } 113 114 80 115 }  - 
        
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBQBlock.h
r11400 r11405 41 41 virtual ~SOBQBlock(); 42 42 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 43 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 43 44 45 void setType(std::string type) { 46 this->type_=type; 47 } 48 std::string getType() { 49 return this->type_; 50 } 44 51 protected: 45 52 bool used_; 53 std::string type_; 54 void spawnMushroom(); 46 55 }; 47 56  
Note: See TracChangeset
          for help on using the changeset viewer.
      


            






