Changeset 11412
- Timestamp:
- May 4, 2017, 3:17:59 PM (8 years ago)
- Location:
- code/branches/SuperOrxoBros_FS17
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
r11411 r11412 118 118 119 119 120 <SOBGumba collisionType="dynamic" speed=30> 121 <attached> 122 <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/> 123 124 </attached> 125 <collisionShapes> 126 <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" /> <!-- ?????? --> 127 </collisionShapes> 128 </SOBGumba> 129 130 131 132 133 120 134 <Model mesh="Cube2.12.mesh" position="0,0,-30" scale=10 Pitch=90/> <!-- B1.1 --> 121 135 <Model mesh="Cube2.12.mesh" position="120,0,-30" scale=10 Pitch=90/> <!-- B1.2--> … … 127 141 128 142 129 <StaticEntity collisionType="static" >143 <StaticEntity collisionType="static" mass='-1'> 130 144 <collisionShapes> 131 145 <BoxCollisionShape position="340,0,-20" halfExtents="345,5,5" /> … … 139 153 <!-- BLOCK 1 in der LUFT - alle analog wie diesen :) --> 140 154 <!-- Sobald ein QBlock von unten gehittet wird, wechselt die Visibility von allen attached Models. Hier wuerde also Cube1.1 invisible und Cube2.12 visible. Die Collisionshape wird ja sowieso beibehalten. --> 141 <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20" > <!-- L1.1 -->155 <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20" mass=-1> <!-- L1.1 --> 142 156 <attached> 143 157 <Model mesh="QCube.mesh" scale=10 pitch=90 /> … … 205 219 206 220 207 208 209 210 <SOBMushroom collisionType="dynamic" speed=30>211 <attached>212 <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>213 214 </attached>215 <collisionShapes>216 <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" /> <!-- ?????? -->217 </collisionShapes>218 </SOBMushroom>219 220 <SOBMushroom collisionType="dynamic" speed=30>221 <attached>222 <Model mesh="Alien.mesh" position="30,0,21" scale=3 pitch=90/>223 224 </attached>225 <collisionShapes>226 <BoxCollisionShape position="30,0,20" halfExtents="5,5,3" /> <!-- ?????? -->227 </collisionShapes>228 </SOBMushroom>229 221 230 222 -
code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo
r11405 r11412 48 48 textsize = 0.04 49 49 colour = "1.0, 1.0, 1.0, 1.0" 50 align = " middle"51 caption = "WORLD\n 50 align = "center" 51 caption = "WORLD\n1-1" 52 52 /> 53 53 … … 79 79 80 80 81 <SOBHUDInfo 82 position = "0.5,0.5" 83 pickpoint = "0.5, 0.5" 84 textposition = "0.5, 0.5" 85 textpickpoint = "0.5, 0.5" 86 font = "ShareTechMono" 87 textsize = 0.07 88 colour = "1.0, 1.0, 1.0, 1.0" 89 align = "center" 90 type = "Info" 91 92 /> 81 93 82 94 -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt
r11405 r11412 8 8 SOBMushroom.cc 9 9 SOBHUDInfo.cc 10 SOBGumba.cc 11 SOBFlagstone.cc 10 12 11 13 ) -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
r11405 r11412 38 38 #include "core/command/Executor.h" 39 39 #include "core/config/ConfigValueIncludes.h" 40 #include "core/Game.h" 40 41 41 42 #include "gamestates/GSLevel.h" … … 68 69 points_=0; 69 70 timeLeft_=400.0; 71 72 lvl_ = 1; 70 73 71 74 } … … 86 89 } 87 90 88 91 void SOB::start() 89 92 { 90 93 if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place. … … 125 128 } 126 129 130 void SOB::restart() { 131 cleanup(); 132 133 // HACK 134 Game::getInstance().popState(); 135 Game::getInstance().popState(); 136 Game::getInstance().requestStates("standalone, level"); 137 138 139 } 127 140 void SOB::spawnPlayer(PlayerInfo* player) 128 141 { … … 148 161 } 149 162 150 void SOB::tick(float dt)163 void SOB::tick(float dt) 151 164 { 152 165 SUPER(SOB, tick, dt); 153 166 154 if (this->figure_ != nullptr && figure_->dead_) 167 if (this->figure_ != nullptr && figure_->dead_) { 168 info_ = "Game over. Press <Space> to restart"; 155 169 orxout() << "DEED" << endl; 156 170 } 171 157 172 158 timeLeft_-=dt*2.5;173 timeLeft_-=dt*2.5; 159 174 } 160 175 -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
r11405 r11412 62 62 PlayerInfo* getPlayer() const; 63 63 64 void restart(); 64 65 int getPoints() { 65 66 return points_; … … 75 76 points_+=1000; 76 77 } 78 void addGumba() { 79 points_+=100; 80 } 77 81 int getTimeLeft() { 78 82 return timeLeft_; 79 83 } 84 std::string getInfoText() { 85 return info_; 86 } 80 87 81 82 virtual void playerEntered(PlayerInfo* player) override 88 void setLvl(int lvl) { 89 lvl_ = lvl; 90 } 91 int getLvl() { 92 return lvl_; 93 } 94 virtual void playerEntered(PlayerInfo* player) override 83 95 { 84 96 Gametype::playerEntered(player); … … 97 109 int coins_; 98 110 float timeLeft_; 111 112 int lvl_; 113 std::string info_; 99 114 100 115 -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
r11405 r11412 41 41 42 42 #include "SOBMushroom.h" 43 #include "SOBGumba.h" 43 44 #include "SOB.h" 45 #include "SOBFlagstone.h" 44 46 45 47 namespace orxonox … … 66 68 pitch_ = 0.0; 67 69 70 predead_ = false; 68 71 dead_ = false; 69 72 gotPowerUp_ = false; … … 79 82 isColliding_ = true; 80 83 SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject); 81 // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION 84 SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject); 85 SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject); 86 82 87 if (mush != nullptr && !(mush->hasCollided_)) { 83 88 otherObject->destroyLater(); … … 87 92 mush->hasCollided_ = true; 88 93 89 } 90 91 return true; 92 } 93 94 95 96 void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode) 97 { 98 SUPER(SOBFigure, XMLPort, xmlelement, mode); 99 100 } 101 102 103 104 void SOBFigure::tick(float dt) 105 { 106 SUPER(SOBFigure, tick, dt); 107 108 if (particlespawner_ == NULL) { 109 for (WorldEntity* object : this->getAttachedObjects()) 110 { 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; 94 } else if (gumba != nullptr && !(gumba->hasCollided_)) { 95 96 if (getVelocity().z >= -20) { 97 Vector3 vel = getVelocity(); 98 vel.y = -80; 99 vel.z = 200; 100 setVelocity(vel); 101 predead_=true; 102 } else { 103 gumba->destroyLater(); 104 gumba->hasCollided_ = true; 105 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 106 SOBGame->addGumba(); 107 108 109 } 110 } 111 112 if (flagstone != nullptr && !(flagstone->hasCollided_)) { 113 flagstone->hasCollided_ = true; 114 115 } 116 117 return true; 118 } 119 120 121 122 void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode) 123 { 124 SUPER(SOBFigure, XMLPort, xmlelement, mode); 125 126 } 127 128 129 int SOBFigure::sgn(float x) { 130 131 if (x < 0.0) return -1; 132 return 1; 133 } 134 135 void SOBFigure::tick(float dt) 136 { 137 SUPER(SOBFigure, tick, dt); 138 139 if (particlespawner_ == NULL) { 140 for (WorldEntity* object : this->getAttachedObjects()) 141 { 142 if (object->isA(Class(ParticleSpawner))) 143 particlespawner_ = object; 144 145 } 146 147 } 148 149 150 151 152 153 154 if (firePressed_ == false) { 155 gravityAcceleration_ = 350.0; 156 157 } 158 159 if (hasLocalController()) 160 { 161 Vector3 velocity = getVelocity(); 162 Vector3 position = getPosition(); 163 164 if (!predead_) 165 velocity.y = 0; 166 if (position.z < -100) { 167 dead_ = true; 168 169 } 170 171 if (dead_) { 172 velocity.x = 0; 173 velocity.z = 0; 174 setVelocity(velocity); 175 SOB* SOBGame = orxonox_cast<SOB*>(getGametype()); 176 if (firePressed_) 177 SOBGame->restart(); 178 return; 179 } 180 181 182 int maxvelocity_x = 100; 183 int speedAddedPerTick = 5; 184 int camMaxOffset = 25; 185 186 timeSinceLastFire_ += dt; 187 lastSpeed_z = velocity.z; 151 188 152 189 153 190 154 191 //Handle the rocket fire from the jetpack 155 156 157 158 192 if (velocity.z > 40) 193 particlespawner_->setVisible(true); 194 else 195 particlespawner_->setVisible(false); 159 196 160 197 //If player hits space and does not move in z-dir 161 162 198 if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) { 199 gravityAcceleration_ = 100.0; 163 200 velocity.z = 110; //150 164 201 } … … 169 206 //Left-right movement with acceleration 170 207 float rot = getOrientation().getRoll().valueDegrees(); 208 orxout() << rot << endl; 171 209 if (moveRightPressed_) { 172 if (rot < 0.0) 173 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6)); 210 if (!(rot < 5.0 && -5.0 < rot)) 211 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() - sgn(rot)*dt*Radian(6)); 212 174 213 175 214 if (std::abs(velocity.x) < maxvelocity_x) { 176 215 velocity.x += speedAddedPerTick; 177 216 178 179 180 181 182 // if (pitch_ > 0.0) {183 // pitch -= turn_fac*dt);184 // }185 217 } 186 218 } else if (moveLeftPressed_) { 187 if (rot >= 0.0) 188 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6)); 219 if (!(abs(rot) > 175.0 )) 220 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + sgn(rot)*dt*Radian(6)); 221 222 189 223 190 224 if (std::abs(velocity.x) < maxvelocity_x) { -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
r11405 r11412 38 38 class _SOBExport SOBFigure : public ControllableEntity 39 39 { 40 40 public: 41 41 SOBFigure(Context* context); //!< Constructor. Registers and initializes the object. 42 42 virtual ~SOBFigure() {} … … 46 46 virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the figure up and down. 47 47 48 48 49 49 virtual void boost(bool boost) override; 50 50 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 51 51 52 52 53 53 //virtual void CollisionWithEnemy(SOBEnemy* enemy); 54 54 55 55 56 57 56 57 58 58 bool dead_; 59 bool predead_; 59 60 60 61 61 private: 62 62 63 63 bool gotPowerUp_; 64 64 bool moveUpPressed_; … … 74 74 bool isColliding_; 75 75 WorldEntity* particlespawner_; 76 int sgn(float x); 76 77 77 78 79 78 80 79 80 };81 }81 82 }; 83 } 82 84 83 85 #endif /* _SOBFigure_H__ */ -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc
r11405 r11412 66 66 if (this->type_ == "Coins") { 67 67 // this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!"); 68 69 68 69 70 70 std::stringstream ss; 71 71 ss << "cc x " << std::setw(2) << std::setfill('0') << SOBGame->getCoins(); … … 74 74 this->setCaption(s); 75 75 76 77 76 } 77 if (this->type_ == "Points") { 78 78 std::stringstream ss; 79 79 ss << std::setw(6) << std::setfill('0') << SOBGame->getPoints(); 80 80 std::string s = ss.str(); 81 81 this->setCaption(s); 82 83 82 } 83 if (this->type_ == "Time") { 84 84 std::stringstream ss; 85 85 ss << SOBGame->getTimeLeft(); 86 86 std::string s = ss.str(); 87 87 this->setCaption(s); 88 } 89 88 } 89 if (this->type_ == "Info") { 90 std::stringstream ss; 91 ss << SOBGame->getInfoText(); 92 std::string s = ss.str(); 93 this->setCaption(s); 94 } 95 90 96 91 92 // const std::string& Level = multi_cast<std::string>(this->SOBGame->getLevel()); 93 // if (this->SOBGame->lives <= 0) 94 // { 95 // setPosition(Vector2(0.1, 0.65)); 96 // this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!"); 97 // setTextSize(0.05); 98 // this->SOBGame->bEndGame = true; 99 // } 100 // else if (this->SOBGame->bShowLevel) 101 // { 102 // setTextSize(0.1); 103 // setPosition(Vector2(0.3, 0.55)); 104 // std::stringstream sstm; 105 // sstm << "Level " << Level; 106 // this->setCaption(sstm.str()); // + level 107 // } 108 // else 109 // { 110 // setTextSize(0.04); 111 // setPosition(Vector2(0.14, 0.055)); 112 // this->setCaption(Level); 113 // } 114 // //////////// 115 // const std::string& points = multi_cast<std::string>(this->SOBGame->getPoints()); 116 // if (this->SOBGame->lives <= 0) 117 // { 118 // setTextSize(0.2); 119 // setPosition(Vector2(0.1, 0.25)); 120 // this->setCaption("Final score:\n" + points); 121 // this->setColour(ColourValue(1, 0, 0, 1)); 122 // } 123 // else 124 // { 125 // setTextSize(0.04); 126 // setPosition(Vector2(0.14, 0.1)); 127 // this->setColour(ColourValue(1, 1, 1, 1)); 128 // this->setCaption(points); 129 // } 130 131 // ///////////// 132 // int mult = this->SOBGame->getMultiplier(); 133 // const std::string& Multiplier = "X " + multi_cast<std::string>(mult); 134 // this->setCaption(Multiplier); 135 // this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f))); 136 // this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f); 137 138 } 139 } 140 141 void SOBHUDInfo::changedOwner() 142 { 143 SUPER(SOBHUDInfo, changedOwner); 144 145 if (this->getOwner() && this->getOwner()->getGametype()) 146 { 147 this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype()); 148 } 149 else 150 { 151 this->SOBGame = nullptr; 152 } 97 153 98 } 154 99 } 100 101 void SOBHUDInfo::changedOwner() 102 { 103 SUPER(SOBHUDInfo, changedOwner); 104 105 if (this->getOwner() && this->getOwner()->getGametype()) 106 { 107 this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype()); 108 } 109 else 110 { 111 this->SOBGame = nullptr; 112 } 113 } 114 } -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc
r11405 r11412 55 55 speed_ = 0.0; 56 56 hasCollided_=false; 57 goesRight_ = true; 58 lastPos_ = getPosition(); 59 lastPos_.x -= 20; 60 changeAllowed_ = true; 61 changedOn_ = 0.0; 57 62 58 63 } … … 71 76 bool SOBMushroom::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) { 72 77 73 //orxout() << "Watshc bum baem" << endl; 78 79 if (changeAllowed_ && otherObject->getMass() != -1) { 80 goesRight_ = !goesRight_; 81 changeAllowed_ = false; 82 } 83 84 orxout() << "Watshc bum baem" << otherObject->getMass()<< endl; 74 85 return true; 75 86 } … … 90 101 SUPER(SOBMushroom, tick, dt); 91 102 92 Vector3 velocity = getVelocity(); 103 if (!changeAllowed_) { 104 changedOn_+= dt; 105 if (changedOn_> 200) { 106 changeAllowed_ = true; 107 changedOn_ = 0.0; 108 109 } 110 } 111 112 113 int dir = 1; 114 if (!goesRight_) 115 dir = -1; 116 117 Vector3 velocity = getVelocity(); 93 118 velocity.z -= gravityAcceleration_*dt; 94 velocity.x = speed_;119 velocity.x = dir*speed_; 95 120 setVelocity(velocity); 96 121 97 122 98 123 124 lastPos_ = getPosition(); 125 } 126 99 127 100 128 } 101 } -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h
r11405 r11412 65 65 float speed_; 66 66 WeakPtr<SOBFigure> figure_; 67 bool goesRight_; 68 Vector3 lastPos_; 69 bool changeAllowed_; 70 float changedOn_; 67 71 68 72 }; -
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h
r11405 r11412 81 81 class SOBMushroom; 82 82 class SOBHUDInfo; 83 class SOBGumba; 84 class SOBFlagstone; 83 85 /* 84 86 class PongScore;*/
Note: See TracChangeset
for help on using the changeset viewer.