Changeset 11660 for code/branches/Asteroid_HS17/src/modules
- Timestamp:
- Dec 11, 2017, 4:06:44 PM (7 years ago)
- Location:
- code/branches/Asteroid_HS17/src/modules/asteroids2D
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc
r11645 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * ... … … 27 27 */ 28 28 29 /*TODO: Punktesystem aufbauen -> in HUD anzeigen 30 Schwierigkeitsgrad mit jedem levelup erhöhen -> mehr Steine spawnen? 31 spawnStone Methode schreiben 32 templates für die drei Grössen von Asteroiden erstellen 29 33 30 34 31 /** 35 32 @file Asteroids2D.cc 36 33 @brief Implementation of the Asteroids2D class. 34 35 TODO: 36 - Implement a counting system for the score 37 - HUD can be improved (display health, points, level etc.) 38 - Projectiles still 37 39 */ 38 40 … … 62 64 this->center_ = nullptr; 63 65 this->setHUDTemplate("Asteroids2DHUD"); 64 levelupTimer.setTimer( 60.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));66 levelupTimer.setTimer(30.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this))); //level up every 30s 65 67 } 66 68 … … 92 94 93 95 94 // Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad96 //After level up -> spawn stones 95 97 for(int i = 0; i < level*2; i++){ 96 98 spawnStone(); … … 101 103 void Asteroids2D::tick(float dt) 102 104 { 103 //Do this only for the first tick, generate 5 stones forthe beginning105 //Do this only for the first tick, generate 5 stones in the beginning 104 106 if(this->firstTick_) 105 107 { … … 118 120 void Asteroids2D::spawnStone() 119 121 { 122 123 //stones are created with a size 120 124 Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext()); 121 125 newStone->setAsteroids2DPlayer(player); … … 158 162 }; 159 163 160 //Funktion wird als erstes im Level aufgerufen 164 //The first function that will be called 161 165 void Asteroids2D::start() 162 166 { -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h
r11637 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * ... … … 31 31 /** 32 32 @file Asteroids2D.h 33 @brief Gametype. 33 @brief Gametype: 34 - Goal: Survive as long as you can, do not collide with stones 35 - spawns stones in every level up 36 - if you shoot and hit a stone, it will spit into two smaller stones 37 - 34 38 @ingroup Asteroids2D 35 39 */ -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc
r11613 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * ... … … 54 54 @brief 55 55 Method to create a Asteroids2DCenterpoint through XML. 56 Set dimension of the field with "width_, height_" 56 57 */ 57 58 void Asteroids2DCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 61 62 XMLPortParam(Asteroids2DCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode); 62 63 } 64 65 63 66 void Asteroids2DCenterPoint::checkGametype() 64 67 { -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h
r11608 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * ... … … 64 64 65 65 private: 66 void checkGametype(); 66 void checkGametype(); //checks whether the gametype actually is Asteroids2D 67 67 float width_, height_; 68 68 -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc
r11645 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * ... … … 27 27 */ 28 28 29 /*TODO: orientation/direction of the ship must be defined 30 implement shoot function ->or switch it on? 31 switch off boosting particles in the back of the ship 29 /* TODO: 32 30 33 31 /** … … 54 52 this->height = 646; 55 53 56 timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showposition, this)));54 //timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showorientation, this))); 57 55 } 58 56 … … 64 62 } 65 63 64 //Same thing for orientation 65 void Asteroids2DShip::showorientation() 66 { 67 Quaternion ort = this->getOrientation(); 68 orxout() << "w = " << ort.w << " x = " << ort.x << " y = " << ort.y << "z = " << ort.z << endl; 69 } 70 66 71 void Asteroids2DShip::tick(float dt) 67 72 { … … 69 74 Vector3 pos = this->getPosition(); 70 75 71 // haelt ship innerhalb des Kamerafensters, kommt oben bzw seitlich wieder raus. Man spawnt in (0,0)76 //ensure that the ship stays in playing field 72 77 if(pos.x > width/2) pos.x = -width/2; 73 78 if(pos.x < -width/2) pos.x = width/2; … … 79 84 this->setPosition(pos); 80 85 81 //update level 86 82 87 83 88 //shoot? 89 } 90 91 void Asteroids2DShip::boost(bool bBoost) 92 { 93 isFireing = bBoost; 84 94 } 85 95 … … 88 98 if (getGame()) 89 99 getGame()->levelUp(); 90 }91 92 void Asteroids2DShip::boost(bool bBoost)93 {94 //getGame()->bEndGame = bBoost;95 100 } 96 101 … … 107 112 bImmune = true; 108 113 isimmune.setTimer(3.0f, false, createExecutor(createFunctor(&Asteroids2DShip::toggleImmune, this))); 109 orxout()<< "touched" << endl;110 114 } 111 115 return false; -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h
r11645 r11660 60 60 virtual void tick(float dt) override; 61 61 62 // Starts or stops fireing63 virtual void boost(bool bBoost) override;64 65 62 //no rotation in x and z direction! 66 //virtual void rotateYaw(const Vector2& value) override{}; // Rotate in yaw direction.67 63 virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction. 68 64 virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction. 69 65 virtual void boost(bool boost) override; 70 66 virtual void updateLevel(); 71 67 72 68 virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override; 73 69 74 float speed, damping , posforeward;70 float speed, damping; 75 71 bool isFireing; 76 72 void showposition(); 73 void showorientation(); 77 74 void toggleImmune() 78 75 { -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc
r11637 r11660 20 20 * 21 21 * Author: 22 * Samuel Riedel22 * Viviane Yang 23 23 * Co-authors: 24 24 * ... … … 26 26 */ 27 27 28 29 28 30 /** 29 31 @file Asteroids2DStone.cc 32 30 33 @brief Implementation of the Asteroids2DStone class. 31 */ 34 35 TO DO: 36 - instead of moving over the boarders of the playing field, modify the tick function so that the stones bounce back 37 - when to split? It does not work if you override kill() function...->damage() function? 38 */ 32 39 33 40 #include "Asteroids2DStone.h" … … 87 94 Vector3 pos = this->getPosition(); 88 95 96 89 97 if(pos.x >= width/2){ 90 98 pos.x = -width/2; … … 103 111 inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) 104 112 { 113 orxout() << "AsteroidStone getroffen" << endl; 105 114 if(orxonox_cast<Asteroids2DShip*>(otherObject)) 106 115 { 107 this->split(); 116 orxout() << "getroffen von Ship" << endl; 117 split(); 108 118 } 109 119 return false; … … 112 122 void Asteroids2DStone::split() 113 123 { 124 orxout() << "split" << endl; 114 125 if(size == 1) 115 126 { … … 117 128 118 129 }else if(size == 2){ 130 131 132 //Templates can be found in data/levels/templates/asteroidsAsteroids2D.oxt 119 133 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition()); 120 134 newStone1->addTemplate("stone1"); 121 135 Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition()); 122 136 newStone2->addTemplate("stone1"); 137 123 138 }else{ 124 139 Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition()); … … 129 144 } 130 145 131 132 133 134 //Overload kill function to generate 2 asteriods135 /*void Asteroids2DStone::kill()136 {137 this->damage(this->health)138 if(this->size < 1)139 {140 this->death();141 }else{142 size -= 1;143 144 }145 146 147 }*/148 149 150 146 } -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc
r11645 r11660 21 21 * 22 22 * Author: 23 * Florian Zinggeler23 * Viviane Yang 24 24 * Co-authors: 25 25 * -- … … 48 48 #include "weapons/MuzzleFlash.h" 49 49 50 #include "Asteroids2D.h" 51 50 52 namespace orxonox 51 53 { … … 55 57 { 56 58 RegisterObject(Asteroids2DWeapon); 59 60 57 61 } 58 62 … … 61 65 62 66 } 67 68 Asteroids2D* Asteroids2DWeapon::getGame() 69 { 70 if (game == nullptr) 71 { 72 for (Asteroids2D* race : ObjectList<Asteroids2D>()) 73 { 74 game = race; 75 } 76 } 77 return game; 78 } 79 63 80 64 81 void Asteroids2DWeapon::shot() … … 75 92 76 93 this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition()); 77 projectile->setOrientation(this->getMuzzleOrientation()); 94 95 //projectile->setOrientation(this->getGame()->getPlayer()->getOrientation()); 78 96 projectile->setPosition(this->getMuzzlePosition()); 79 97 98 99 //auf 2D Ebene druecken 80 100 Vector3 muzzle2D = this->getMuzzleDirection(); 81 101 muzzle2D.y = 0; -
code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h
r11645 r11660 40 40 #include "weapons/weaponmodes/HsW01.h" 41 41 42 #include "Asteroids2D.h" 43 42 44 namespace orxonox 43 45 { … … 47 49 Asteroids2DWeapon(Context* context); 48 50 virtual ~Asteroids2DWeapon(); 51 Asteroids2D* getGame(); 52 53 49 54 protected: 50 55 virtual void shot() override; 51 56 WeakPtr<Projectile> projectile; 57 WeakPtr<Asteroids2D> game; 52 58 }; 53 59 }
Note: See TracChangeset
for help on using the changeset viewer.