Changeset 11637
- Timestamp:
- Dec 4, 2017, 4:17:43 PM (7 years ago)
- Location:
- code/branches/Asteroid_HS17
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/data/levels/Asteroids2D.oxw
r11617 r11637 17 17 include("templates/enemyInvader.oxt") 18 18 include("overlays/Asteroids2DHUD.oxo") 19 include("templates/asteroidsAsteroids2D.oxt )19 include("templates/asteroidsAsteroids2D.oxt") 20 20 ?> 21 21 … … 76 76 ?>--> 77 77 78 79 <Asteroids2DStone80 collisionType = dynamic81 linearDamping = 0.882 angularDamping = 183 scale= 1084 enablecollisiondamage = true85 >86 <attached>87 <Model mass= 8000 mesh="ast1.mesh" />88 </attached>89 <collisionShapes>90 <SphereCollisionShape radius="10" />91 </collisionShapes>92 </Asteroids2DStone>93 94 78 <Asteroids2DCenterPoint name=asteroids2Dcenter /> 95 79 -
code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt
r11617 r11637 2 2 <Asteroids2DStone 3 3 collisionType = dynamic 4 linearDamping = 0 .85 angularDamping = 14 linearDamping = 0 5 angularDamping = 0 6 6 scale= 10 7 7 enablecollisiondamage = true … … 23 23 <Asteroids2DStone 24 24 collisionType = dynamic 25 linearDamping = 0 .826 angularDamping = 125 linearDamping = 0 26 angularDamping = 0 27 27 scale= 20 28 28 enablecollisiondamage = true … … 33 33 > 34 34 <attached> 35 <Model mass= 8000 mesh="ast 2.mesh" />35 <Model mass= 8000 mesh="ast1.mesh" /> 36 36 </attached> 37 37 <collisionShapes> … … 44 44 <Asteroids2DStone 45 45 collisionType = dynamic 46 linearDamping = 0 .847 angularDamping = 146 linearDamping = 0 47 angularDamping = 0 48 48 scale= 30 49 49 enablecollisiondamage = true … … 54 54 > 55 55 <attached> 56 <Model mass= 16000 mesh="ast 3.mesh" />56 <Model mass= 16000 mesh="ast1.mesh" /> 57 57 </attached> 58 58 <collisionShapes> -
code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt
r11614 r11637 7 7 explosionchunks = 4 8 8 9 health = 4010 maxhealth = 4011 initialhealth = 409 health = 1000 10 maxhealth = 1000 11 initialhealth = 1000 12 12 13 13 shieldhealth = 20 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
r11619 r11637 52 52 53 53 bEndGame = false; 54 lives = 3;54 lives = 5; 55 55 level = 1; 56 56 point = 0; … … 62 62 this->center_ = nullptr; 63 63 this->setHUDTemplate("Asteroids2DHUD"); 64 levelupTimer.setTimer( 100.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));64 levelupTimer.setTimer(60.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this))); 65 65 } 66 66 … … 72 72 if (getPlayer() != nullptr) 73 73 { 74 75 //kann schoener gemacht werden 74 76 for (int i = 0; i < 7; i++) 75 77 { … … 84 86 } 85 87 } 86 addPoints(multiplier * 42);88 addPoints(multiplier * 20); 87 89 multiplier *= 2; 88 90 toggleShowLevel(); 89 91 showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this))); 92 93 90 94 //Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad 91 95 for(int i = 0; i < level*2; i++){ … … 100 104 if(this->firstTick_) 101 105 { 106 getPlayer(); 102 107 for(int i = 0; i < 5; ++i) 103 108 { 104 109 spawnStone(); 105 110 } 111 106 112 this->firstTick_ = false; 107 113 } … … 112 118 void Asteroids2D::spawnStone() 113 119 { 114 if (getPlayer() == nullptr)115 return;116 120 Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext()); 117 121 newStone->setAsteroids2DPlayer(player); … … 132 136 133 137 } 134 135 136 138 } 137 139 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
r11619 r11637 79 79 void levelUp(); 80 80 81 82 //For HUD 81 83 int getLives(){return this->lives;} 82 84 int getLevel(){return this->level;} … … 84 86 int getMultiplier(){return this->multiplier;} 85 87 88 //Generate Stones 86 89 void spawnStone(); 87 90 void setCenterpoint(Asteroids2DCenterPoint* center) 88 { this->center_ = center; } 91 { this->center_ = center; } 92 void addPoints(int numPoints); 89 93 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 90 94 91 95 // checks if multiplier should be reset. 92 96 void costLife(); 93 97 Asteroids2DShip* getPlayer(); 94 98 95 99 bool bEndGame; … … 101 105 102 106 103 Asteroids2DShip* getPlayer(); 107 104 108 WeakPtr<Asteroids2DShip> player; 105 109 void toggleShowLevel(){bShowLevel = !bShowLevel;} 106 void addPoints(int numPoints);107 110 108 111 WeakPtr<Asteroids2DCenterPoint> center_; -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc
r11608 r11637 41 41 42 42 this->Asteroids2DGame = nullptr; 43 this->Ship = nullptr; 43 44 this->bShowPoints_ = true; 45 this->bShowHealth_ = true; 44 46 } 45 47 … … 49 51 50 52 XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 53 XMLPortParam(Asteroids2DHUDinfo,"showHealth", setShowHealth, getShowHealth, xmlelement, mode).defaultValues(false); 51 54 } 52 55 … … 74 77 } 75 78 } 79 80 /*if(this->bShowHealth_) 81 { 82 const std::string& health = multi_cast<std::string>(this->Ship->getHealth()); 83 if (this->Asteroids2DGame->lives <= 0) 84 { 85 setTextSize(0.2); 86 setPosition(Vector2(0.1, 0.02)); 87 this->setCaption("Final score:\n" + health); 88 this->setColour(ColourValue(1, 0, 0, 1)); 89 } 90 else 91 { 92 setTextSize(0.04); 93 setPosition(Vector2(0.2, 0.02)); 94 this->setColour(ColourValue(1, 1, 1, 1)); 95 this->setCaption(health); 96 } 97 }*/ 76 98 } 77 99 … … 80 102 SUPER(Asteroids2DHUDinfo, changedOwner); 81 103 82 if (this->getOwner() && this->getOwner()->getGametype()) 104 if (this->getOwner() && this->getOwner()->getGametype())//&& this->getOwner->getPlayer()) 83 105 { 84 106 this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype()); 107 //this->Ship = orxonox_cast<Asteroids2DShip*>(this->getOwner()->getPlayer()); 85 108 } 86 109 else -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h
r11593 r11637 53 53 { return this->bShowPoints_; } 54 54 55 inline void setShowHealth(bool value) 56 { this->bShowHealth_ = value; } 57 inline bool getShowHealth() const 58 { return this->bShowHealth_; } 59 55 60 56 61 private: 57 62 Asteroids2D* Asteroids2DGame; 63 Asteroids2DShip* Ship; 58 64 bool bShowPoints_; 65 bool bShowHealth_; 59 66 }; 60 67 } -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
r11617 r11637 37 37 38 38 #include "Asteroids2DShip.h" 39 #include "Asteroids2DStone.h" 39 40 #include "core/CoreIncludes.h" 40 41 … … 89 90 } 90 91 91 /* void Asteroids2DShip::moveFrontBack(const Vector2& value)92 {93 //lastTimeFront = 0;94 //desiredVelocity.y = value.y * speed * 42;95 orxout() << "FrontBack" << endl;96 SUPER(Asteroids2DShip, moveFrontBack, value);97 }98 99 void Asteroids2DShip::moveRightLeft(const Vector2& value)100 {101 //lastTimeLeft = 0;102 //desiredVelocity.x = value.x * speed;103 orxout() << "RightLeft" << endl;104 SUPER(Asteroids2DShip, moveFrontBack, value);105 }106 */107 92 void Asteroids2DShip::boost(bool bBoost) 108 93 { … … 112 97 inline bool Asteroids2DShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 113 98 { 114 115 99 removeHealth(100); 116 this->death();100 getGame()->addPoints(10); 117 101 return false; 118 102 } -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
r11617 r11637 57 57 virtual void tick(float dt) override; 58 58 59 // overwrite for 2d movement60 //virtual void moveFrontBack(const Vector2& value) override;61 //virtual void moveRightLeft(const Vector2& value) override;62 63 59 // Starts or stops fireing 64 60 virtual void boost(bool bBoost) override; -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
r11616 r11637 44 44 { 45 45 RegisterObject(Asteroids2DStone); 46 this->size = 1;46 this->size = rand()%3+1; 47 47 this->width = 1043; 48 48 this->height = 646; 49 49 this->setPosition(randomPosition(this->width, this->height)); 50 this->setCollisionTypeStr("dynamic"); 51 this->setVelocity(randomVelocity(MAX_SPEED)); 52 } 53 54 Asteroids2DStone::Asteroids2DStone(Context* c, int sze, Vector3 pos) : Pawn(c) 55 { 56 RegisterObject(Asteroids2DStone); 57 this->size = sze; 58 this->width = 1043; 59 this->height = 646; 60 this->setPosition(pos); 61 this->setCollisionTypeStr("dynamic"); 50 62 this->setVelocity(randomVelocity(MAX_SPEED)); 51 63 } … … 74 86 SUPER(Asteroids2DStone, tick, dt); 75 87 Vector3 pos = this->getPosition(); 76 if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2) 77 { 78 Quaternion orientation = this->getOrientation(); 79 orientation.w -= 180; 80 this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w)); 88 89 if(pos.x >= width/2){ 90 pos.x = -width/2; 91 }else if(pos.x <= -width/2){ 92 pos.x = -width/2; 93 }else if(pos.z >= height/2){ 94 pos.z = -height/2; 95 }else if(pos.z <= -height/2){ 96 pos.z = -width/2; 81 97 } 82 98 99 this->setPosition(pos); 100 83 101 } 102 103 inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 104 { 105 if(orxonox_cast<Asteroids2DShip*>(otherObject)) 106 { 107 this->split(); 108 } 109 return false; 110 } 111 112 void Asteroids2DStone::split() 113 { 114 if(size == 1) 115 { 116 this->death(); 117 118 }else if(size == 2){ 119 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition()); 120 newStone1->addTemplate("stone1"); 121 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition()); 122 newStone2->addTemplate("stone1"); 123 }else{ 124 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 125 newStone1->addTemplate("stone1"); 126 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); 127 newStone2->addTemplate("stone1"); 128 } 129 } 130 131 84 132 85 133 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h
r11619 r11637 48 48 public: 49 49 Asteroids2DStone(Context* context); 50 Asteroids2DStone(Context* c, int sze, Vector3 pos); 51 50 52 virtual void tick(float dt) override; 51 53 Vector3 randomPosition (float maxwidth, float maxheight); … … 53 55 void setAsteroids2DPlayer(Asteroids2DShip* player){this->player = player;}; 54 56 virtual int getSize(){ return this->size;} 57 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 58 virtual void split(); 55 59 56 60 private: … … 58 62 int size; // three sizes, 3-> two 2s, 2-> two 1s, 1-> die 59 63 float width, height; //field 60 float MAX_SPEED = 500; 64 float MAX_SPEED = 100; 65 float delta = 5; 61 66 }; 62 67 }
Note: See TracChangeset
for help on using the changeset viewer.