Changeset 11528
- Timestamp:
- Nov 4, 2017, 5:04:59 PM (7 years ago)
- Location:
- code/branches/Asteroid_HS17
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/data/levels/Asteroids.oxw
r11516 r11528 1 1 <LevelInfo 2 2 name = "Asteroids" 3 description = "Try to prevent asteroids from colliding into your spaceshuttle. Be prepared to dodge all asteroids or destroy them ;"3 description = "Try to prevent asteroids from colliding into your spaceshuttle. Be prepared to dodge all asteroids or destroy them." 4 4 tags = "asteroids, minigame" 5 5 screenshot = "emptylevel.png" 6 6 /> 7 7 8 8 9 <?lua … … 14 15 include("templates/spaceshipAssff2.oxt") 15 16 include("templates/spaceshipPirate.oxt") 16 include("templates/spaceship DodgeRace.oxt")17 include("templates/spaceshipInvader.oxt") 17 18 include("templates/enemyInvader.oxt") 18 include("templates/DodgeRacePattern.oxt") 19 include("overlays/DodgeRaceHUD.oxo") 19 include("overlays/InvaderHUD.oxo") 20 20 ?> 21 21 22 23 24 22 <Level 25 plugin = asteroids 26 gametype = Asteroids 27 > 28 29 23 plugins = invader 24 gametype = Invader 25 > 30 26 <templates> 31 27 <Template link=lodtemplate_default /> … … 33 29 <?lua include("includes/notifications.oxi") ?> 34 30 31 <!-- ambientlight = "0.8, 0.8, 0.8" 32 skybox = "Orxonox/Starbox" --> 35 33 <Scene 36 ambientlight = "1.0, 1.0, 1.0" 37 skybox = "Orxonox/skyBoxClouds" 38 negativeWorldRange = "-100000, -100000, -100000" 39 positiveWorldRange = " 100000, 100000, 100000" 34 ambientlight = "0.8, 0.7, 0.4" 35 skybox = "Orxonox/skyBoxBasic" 40 36 > 41 37 42 <WorldAmbientSound43 source="Earth.ogg"44 looping="true"45 playOnLoad="true"46 />47 48 38 <!-- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> --> 49 <Light type=directional position=" -100, 10000, -700" lookat="0.2, -1, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />50 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass= AsteroidsShip pawndesign=spaceshipdodgerace/>39 <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> 40 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=InvaderShip pawndesign=spaceshipinvader /> 51 41 52 42 <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 /> 53 43 54 44 55 <DodgeRaceCenterPoint name=invadercenter /> 56 57 <StaticEntity position="0,-50,0" direction="0,0,0" scale="1" collisionType=static mass=1 friction=0.01 > 45 <InvaderCenterPoint name=invadercenter /> 46 47 <?lua 48 for i = 1, 300, 1 do 49 j = math.random() 50 ?> 51 52 <MovableEntity 53 position = "<?lua print(math.random()* 40000 + 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>" 54 collisionType = dynamic 55 linearDamping = 0.8 56 angularDamping = 0 57 scale = "<?lua print(j * 150)?>" 58 collisiondamage = 0 59 enablecollisiondamage = true 60 > 58 61 <attached> 59 <Model position="0,0,0" mesh="plane.mesh" scale3D="100000,0,100000" />62 <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" /> 60 63 </attached> 64 <collisionShapes> 65 <SphereCollisionShape radius="<?lua print(j * 350) ?>" /> 66 </collisionShapes> 67 </MovableEntity> 61 68 62 <collisionShapes> 63 <BoxCollisionShape position="0,0,0" halfExtents="1,1,1" /> 64 </collisionShapes> 65 66 </StaticEntity> 67 68 69 70 71 69 <?lua 70 end 71 ?> 72 72 73 73 </Scene> -
code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
r11516 r11528 64 64 point = 0; 65 65 66 // Pre-set the timer, but don't start it yet. 67 this->enemySpawnTimer_.setTimer(5.0, true, createExecutor(createFunctor(&Asteroids::spawnStone, this))); 66 68 } 67 69 70 //spawnt durch den Timer Asteroiden, denk dran, dass falls ein Asteroid stirbt er in 2 teile geteilt wird 71 Asteroids::spawnStone(){ 72 if(getPlayer() == nullptr){ 73 return; 74 } 75 76 AsteroidsStone* newStone; 77 newStone = new AsteroidsStone(this->center_->getContext()); 78 newStone->addTemplate("asteroidsstone"); 79 newStone->setAsteroidsPlayer(player); 80 } 81 82 void Invader::spawnEnemy() 83 { 84 if (getPlayer() == nullptr) 85 return; 86 87 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++) 88 { 89 InvaderEnemy* newPawn; 90 if (rand() % 42/(1 + level*level) == 0) 91 { 92 newPawn = new InvaderEnemyShooter(this->center_->getContext()); 93 newPawn->addTemplate("enemyinvadershooter"); 94 } 95 else 96 { 97 newPawn = new InvaderEnemy(this->center_->getContext()); 98 newPawn->addTemplate("enemyinvader"); 99 } 100 newPawn->setInvaderPlayer(player); 101 newPawn->level = level; 102 // spawn enemy at random points in front of player. 103 newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 104 } 105 } 106 107 /** 108 @brief 109 Destructor. Cleans up, if initialized. 110 */ 111 Asteroids::~Asteroids() 112 { 113 if (this->isInitialized()) 114 this->cleanup(); 115 } 116 117 /** 118 @brief 119 Cleans up the Gametype by destroying all of the objects in the game - spaceship and asteroids. 120 */ 121 void Asteroids::cleanup() 122 { 123 if (this->stones_ != nullptr) // Destroy the ball, if present. 124 { 125 this->stones_->destroy(); 126 this->stones_ = nullptr; 127 } 128 129 // Destroy AsteroidsShip 130 131 if (this->player != nullptr) 132 { 133 this->player->destroy(); 134 this->player = nullptr; 135 } 136 } 68 137 69 138 AsteroidsShip* Asteroids::getPlayer() … … 87 156 lives = 0; 88 157 }; 89 90 158 void Asteroids::start() 91 159 { 92 // Set variable to temporarily force the player to spawn. 93 this->bForceSpawn_ = true; 94 95 if (this->center_ == nullptr) // abandon mission! 160 if (this->center_ == nullptr) // There needs to be a AsteroidsCenterpoint, i.e. the area the game takes place. If no centerpoint was specified, an error is thrown and the level is exited. 96 161 { 97 orxout(internal_error) << " Invader: No Centerpoint specified." << endl;162 orxout(internal_error) << "Asteroids: No Centerpoint specified." << endl; 98 163 GSLevel::startMainMenu(); 99 164 return; 100 165 } 166 167 // Set variable to temporarily force the player to spawn. 168 bool temp = this->bForceSpawn_; 169 this->bForceSpawn_ = true; 170 101 171 // Call start for the parent class. 102 172 Deathmatch::start(); 173 174 // Reset the variable. 175 this->bForceSpawn_ = temp; 103 176 } 104 177 -
code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h
r11516 r11528 61 61 void addPoints(int numPoints); 62 62 63 void spawnStone(); 64 63 65 int lives; 64 66 bool bEndGame; … … 66 68 private: 67 69 void toggleShowLevel(){bShowLevel = !bShowLevel;} 70 void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats. 68 71 AsteroidsShip* getPlayer(); 69 72 WeakPtr<AsteroidsCenterPoint> center_; 70 73 WeakPtr<AsteroidsShip> player; 71 74 WeakPtr<Camera> camera; 75 WeakPtr<AsteroidsStones> stones_; 72 76 73 77 Timer enemySpawnTimer; 74 Timer comboTimer;75 Timer showLevelTimer;76 78 //Context* context; 77 79 int level; 78 80 int point; 79 81 bool b_combo; 82 83 Timer starttimer_; //!< A timer to delay the start of the game. 80 84 }; 81 85 } -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc
r11516 r11528 46 46 RegisterObject(AsteroidsCenterPoint); 47 47 48 49 //Werte ausprobieren und testen! 50 this->width_ = 500; 51 this->height_= 300; 52 48 53 this->checkGametype(); 49 54 } -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h
r11516 r11528 47 47 AsteroidsCenterPoint(Context* context); //checks whether the gametype is actually Invader. 48 48 49 /** 50 @brief Set the dimensions of the playing field. 51 @param dimension A vector with the width of the playing field as first component and the height as second. 52 */ 53 void setFieldDimension(const Vector2& dimension) 54 { this->width_ = dimension.x; this->height_ = dimension.y; } 55 /** 56 @brief Get the dimensions of the playing field. 57 @return Returns a vector with the width of the playing field as first component and the height as second. 58 */ 59 Vector2 getFieldDimension() const 60 { return Vector2(this->width_, this->height_); } 61 49 62 private: 50 63 void checkGametype(); 64 //Spielfeld liegt in x-z Ebene, x ist LeftRight(Horizontale), z ist UpDown (Vertikale) 65 float width_; 66 float height_; 51 67 52 68 }; -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
r11516 r11528 5 5 #include "Asteroids.h" 6 6 #include "graphics/Camera.h" 7 #include "asteroids/AsteroidStone "7 #include "asteroids/AsteroidStone.h" 8 8 #include "weapons/projectiles/Projectile.h" 9 #include "asteroids/AsteroidsCenterpoint.h" 9 10 10 11 … … 108 109 109 110 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 111 110 112 } 111 113 112 114 113 // Camera 115 116 //Camera ticken? Bleibt eigentlich am selben Ort...irgendwo initialisieren 114 117 Camera* camera = this->getCamera(); 115 118 if (camera != nullptr) … … 132 135 SUPER(AsteroidsShip, tick, dt); 133 136 } 134 137 138 void AsteroidsShip::moveFrontBack(const Vector2& value) 139 { 140 141 142 } 143 144 void AsteroidsShip::moveFrontBack(const Vector2& value) 145 { 146 147 } 148 void AsteroidsShip::moveFrontBack(const Vector2& value) 149 { 150 151 } 152 135 153 Asteroids* AsteroidsShip::getGame() 136 154 { … … 143 161 } 144 162 145 void InvaderShip::death()163 void AsteroidsShip::death() 146 164 { 147 165 getGame()->costLife(); -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
r11516 r11528 56 56 virtual void moveFrontBack(const Vector2& value) override; 57 57 virtual void moveRightLeft(const Vector2& value) override; 58 virtual void moveUpDown(const Vector2& value) override; 58 59 59 60 // Starts or stops fireing … … 61 62 62 63 63 void setCenterpoint( DodgeRaceCenterPoint* center)64 void setCenterpoint(AsteroidsCenterPoint* center) 64 65 { this->center_ = center; } 66 67 65 68 virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command 66 69 -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
r11516 r11528 42 42 { 43 43 RegisterClass(AsteroidsStone); 44 45 AsteroidsStone::AsteroidsStone(Context* context) : MovableEntity(context)44 //pawn kann sterben -> nach dem Tot sollen aber 2 Asteroiden spawnen 45 AsteroidsStone::AsteroidsStone(Context* context) : Pawn(context) 46 46 { 47 47 RegisterObject(AsteroidsStone); 48 49 48 50 49 51 maxspeed = 50.0f; -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
r11516 r11528 28 28 29 29 /** 30 @file InvaderEnemy.h31 @brief Declaration of the InvaderEnemyclass.30 @file AsteroidsStone.h 31 @brief Declaration of the AsteroidsStone class. 32 32 */ 33 33 … … 37 37 #include "asteroids/AsteroidsPrereqs.h" 38 38 39 #include "worldentities/ MovableEntity.h"39 #include "worldentities/Pawn.h" 40 40 41 41 namespace orxonox 42 42 { 43 class _AsteroidsExport AsteroidsStone : public MovableEntity43 class _AsteroidsExport AsteroidsStone : public Pawn 44 44 { 45 45 public: … … 47 47 virtual void tick(float dt) override; 48 48 49 //Radius of the asteroid 49 50 float r; 50 51 int level; 52 virtual void setAsteroidsPlayer(AsteroidsShip* player){this->player = player;} 53 51 54 protected: 52 float fieldWidth_; 53 float fieldHeight_; 55 56 //herausfinden->ueber Kamera Einstellung wie bei Pong? 57 float fieldWidth_=500; 58 float fieldHeight_=700; 54 59 Vector2 velocity; 55 60 float maxspeed; 56 57 58 59 61 }; 60 62 } 61 63 62 #endif /* _ InvaderEnemy_H__ */64 #endif /* _AsteroidsStone_H__ */ -
code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt
r11516 r11528 3 3 Asteroids.cc 4 4 AsteroidsCenterPoint.cc 5 InvaderShip.cc5 AsteroidsShip.cc 6 6 AsteroidsStone.cc 7 7 AsteroidsWeapon.cc
Note: See TracChangeset
for help on using the changeset viewer.