- Timestamp:
- Nov 13, 2017, 4:05:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
r11541 r11555 28 28 29 29 /** 30 @file InvaderEnemy.h31 @brief Declaration of the InvaderEnemy class.30 @file AsteroidsEnemy.h 31 @brief Declaration of the AsteroidsEnemy class. 32 32 */ 33 33 … … 36 36 #include "Asteroids.h" 37 37 #include "AsteroidsShip.h" 38 #include <cstdlib> 38 39 #include <cmath> 39 40 #include "util/Math.h" 40 41 42 const float delta = 3; 41 43 42 44 namespace orxonox … … 48 50 RegisterObject(AsteroidsStone); 49 51 52 direction = 0; 53 //Spielfeld x als Horizontale und z als Vertikale 54 fieldWidth_ = this->getGame()->center_->getFieldWidth; 55 fieldHeigth_ = this->getGame()->center_->getFieldHeight; 56 57 58 //Random size 1, 2, 3 ->muss noch realisiert werden. Templates erstellen 59 this.size = 1; 50 60 maxspeed = 50.0f; 51 61 //Random Spawn? pos= random? -> spawn durch timer in der Asteroids Klasse 52 this->setPosition(rnd( 0, fieldWidth_), rnd(0, fieldHeigth_), 0);62 this->setPosition(rnd(fieldWidth_), 0, rnd(fieldHeigth)); 53 63 54 //random Geschwindigkeit und Richtung 55 velocity.x = rnd(0, maxspeed); 56 velocity.y = rnd(0, maxspeed); 57 this->context = context; 64 //random Geschwindigkeit und Richtung 65 velocity.x = rnd(maxspeed); 66 velocity.y = rnd(maxspeed); 67 } 68 69 inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 70 { 71 if(orxonox_cast<AsteroidsShip*>(otherObject)) 72 removeHealth(2000); 73 return false; 58 74 } 59 75 … … 64 80 }else if(this->size == 2){ 65 81 Pawn::death(); 66 67 82 //Wie mache ich das ? Eigentlich in der game Klasse? sonst zeigt der Pointer auf einen falschen Bereich 68 69 83 for(int i = 0; i<2; i++) 70 84 { 71 85 AsteroidsStone* newStone; 72 newStone = new AsteroidsStone(this-> context);86 newStone = new AsteroidsStone(this->getGame()->center_->getContext()); 73 87 newStone->addTemplate("asteroidsstone"); 74 newStone->setAsteroidsPlayer( player);88 newStone->setAsteroidsPlayer(this->getGame()->player); 75 89 } 76 90 77 91 } 92 } 93 94 95 Asteroids* AsteroidsStone::getGame() 96 { 97 if (game == nullptr) 98 { 99 for (Asteroids* Asteroids : ObjectList<Asteroids>()) 100 game = asteroids; 101 } 102 return game; 78 103 } 79 104 … … 82 107 void AsteroidsStone::tick(float dt) 83 108 { 84 Vector3 pos = this->getPosition(); 85 pos.x += velocity.x*dt; 86 pos.z += velocity.y*dt; 109 Vector3 pos = getPosition(); 87 110 111 112 113 114 //bounce on the borders 115 if(pos.x-delta <= 0 || pos.x+delta >= fieldWidth_) 116 direction = -direction; 117 118 119 120 //zurück bringen 88 121 if(pos.y != 0){ 89 122 pos.y=0; 90 123 } 124 125 //spin 126 127 setOrientation() 91 128 setPosition(pos); 129 92 130 SUPER(AsteroidsStone, tick, dt); 93 131 } … … 95 133 inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 96 134 { 97 if(orxonox_cast< InvaderShip*>(otherObject))135 if(orxonox_cast<AsteroidsShip*>(otherObject)) 98 136 removeHealth(2000); 99 137 return false;
Note: See TracChangeset
for help on using the changeset viewer.