Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11528


Ignore:
Timestamp:
Nov 4, 2017, 5:04:59 PM (6 years ago)
Author:
vyang
Message:

Spawn Funktion fuer die Asteroiden veraendert

Location:
code/branches/Asteroid_HS17
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Asteroid_HS17/data/levels/Asteroids.oxw

    r11516 r11528  
    1  <LevelInfo
     1<LevelInfo
    22 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."
    44 tags = "asteroids, minigame"
    55 screenshot = "emptylevel.png"
    66/>
     7
    78
    89<?lua
     
    1415  include("templates/spaceshipAssff2.oxt")
    1516  include("templates/spaceshipPirate.oxt")
    16   include("templates/spaceshipDodgeRace.oxt")
     17  include("templates/spaceshipInvader.oxt")
    1718  include("templates/enemyInvader.oxt")
    18   include("templates/DodgeRacePattern.oxt")
    19   include("overlays/DodgeRaceHUD.oxo")
     19  include("overlays/InvaderHUD.oxo")
    2020?>
    2121
    22 
    23 
    2422<Level
    25     plugin = asteroids
    26     gametype = Asteroids
    27     >
    28 
    29 
     23  plugins = invader
     24  gametype = Invader
     25>
    3026  <templates>
    3127    <Template link=lodtemplate_default />
     
    3329  <?lua include("includes/notifications.oxi") ?>
    3430
     31    <!-- ambientlight = "0.8, 0.8, 0.8"
     32    skybox       = "Orxonox/Starbox" -->
    3533  <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"
    4036  >
    4137
    42   <WorldAmbientSound
    43     source="Earth.ogg"
    44     looping="true"
    45     playOnLoad="true"
    46   />
    47 
    4838    <!-- <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 />
    5141
    5242    <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 />
    5343
    5444
    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    >
    5861      <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" />
    6063      </attached>
     64      <collisionShapes>
     65        <SphereCollisionShape radius="<?lua print(j * 350) ?>" />
     66      </collisionShapes>
     67    </MovableEntity>
    6168
    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    ?>
    7272   
    7373  </Scene>
  • code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc

    r11516 r11528  
    6464        point = 0;
    6565
     66        // Pre-set the timer, but don't start it yet.
     67        this->enemySpawnTimer_.setTimer(5.0, true, createExecutor(createFunctor(&Asteroids::spawnStone, this)));
    6668    }
    6769
     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    }
    68137
    69138    AsteroidsShip* Asteroids::getPlayer()
     
    87156        lives = 0;
    88157    };
    89 
    90158    void Asteroids::start()
    91159    {
    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.
    96161        {
    97             orxout(internal_error) << "Invader: No Centerpoint specified." << endl;
     162            orxout(internal_error) << "Asteroids: No Centerpoint specified." << endl;
    98163            GSLevel::startMainMenu();
    99164            return;
    100165        }
     166
     167        // Set variable to temporarily force the player to spawn.
     168        bool temp = this->bForceSpawn_;
     169        this->bForceSpawn_ = true;
     170
    101171        // Call start for the parent class.
    102172        Deathmatch::start();
     173
     174        // Reset the variable.
     175        this->bForceSpawn_ = temp;
    103176    }
    104177
  • code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.h

    r11516 r11528  
    6161            void addPoints(int numPoints);
    6262
     63            void spawnStone();
     64
    6365            int lives;
    6466            bool bEndGame;
     
    6668        private:
    6769            void toggleShowLevel(){bShowLevel = !bShowLevel;}
     70            void cleanup(void); //!< Cleans up the Gametype by destroying the ball and the bats.
    6871            AsteroidsShip* getPlayer();
    6972            WeakPtr<AsteroidsCenterPoint> center_;
    7073            WeakPtr<AsteroidsShip> player;
    7174            WeakPtr<Camera> camera;
     75            WeakPtr<AsteroidsStones> stones_;
    7276
    7377            Timer enemySpawnTimer;
    74             Timer comboTimer;
    75             Timer showLevelTimer;
    7678            //Context* context;
    7779            int level;
    7880            int point;
    7981            bool b_combo;
     82
     83            Timer starttimer_; //!< A timer to delay the start of the game.
    8084    };
    8185}
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.cc

    r11516 r11528  
    4646        RegisterObject(AsteroidsCenterPoint);
    4747
     48
     49        //Werte ausprobieren und testen!
     50        this->width_ = 500;
     51        this->height_= 300;
     52
    4853        this->checkGametype();
    4954    }
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h

    r11516 r11528  
    4747            AsteroidsCenterPoint(Context* context); //checks whether the gametype is actually Invader.
    4848
     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
    4962        private:
    5063            void checkGametype();
     64            //Spielfeld liegt in x-z Ebene, x ist LeftRight(Horizontale), z ist UpDown (Vertikale)
     65            float width_;
     66            float height_;
    5167
    5268    };
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc

    r11516 r11528  
    55#include "Asteroids.h"
    66#include "graphics/Camera.h"
    7 #include "asteroids/AsteroidStone"
     7#include "asteroids/AsteroidStone.h"
    88#include "weapons/projectiles/Projectile.h"
     9#include "asteroids/AsteroidsCenterpoint.h"
    910
    1011
     
    108109
    109110            pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
     111
    110112        }
    111113
    112114
    113         // Camera
     115
     116        //Camera ticken? Bleibt eigentlich am selben Ort...irgendwo initialisieren
    114117        Camera* camera = this->getCamera();
    115118        if (camera != nullptr)
     
    132135        SUPER(AsteroidsShip, tick, dt);
    133136    }
    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
    135153    Asteroids* AsteroidsShip::getGame()
    136154    {
     
    143161    }
    144162
    145     void InvaderShip::death()
     163    void AsteroidsShip::death()
    146164    {
    147165        getGame()->costLife();
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h

    r11516 r11528  
    5656            virtual void moveFrontBack(const Vector2& value) override;
    5757            virtual void moveRightLeft(const Vector2& value) override;
     58            virtual void moveUpDown(const Vector2& value) override;
    5859
    5960            // Starts or stops fireing
     
    6162
    6263
    63             void setCenterpoint(DodgeRaceCenterPoint* center)
     64            void setCenterpoint(AsteroidsCenterPoint* center)
    6465                       { this->center_ = center; }
     66
     67
    6568            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
    6669
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc

    r11516 r11528  
    4242{
    4343    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)
    4646    {
    4747        RegisterObject(AsteroidsStone);
     48
     49
    4850
    4951        maxspeed = 50.0f;
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h

    r11516 r11528  
    2828
    2929/**
    30     @file InvaderEnemy.h
    31     @brief Declaration of the InvaderEnemy class.
     30    @file AsteroidsStone.h
     31    @brief Declaration of the AsteroidsStone class.
    3232*/
    3333
     
    3737#include "asteroids/AsteroidsPrereqs.h"
    3838
    39 #include "worldentities/MovableEntity.h"
     39#include "worldentities/Pawn.h"
    4040
    4141namespace orxonox
    4242{
    43     class _AsteroidsExport AsteroidsStone : public MovableEntity
     43    class _AsteroidsExport AsteroidsStone : public Pawn
    4444    {
    4545        public:
     
    4747            virtual void tick(float dt) override;
    4848
     49            //Radius of the asteroid
    4950            float r;
    5051            int level;
     52            virtual void setAsteroidsPlayer(AsteroidsShip* player){this->player = player;}
     53
    5154        protected:
    52             float fieldWidth_;
    53             float fieldHeight_;
     55
     56            //herausfinden->ueber Kamera Einstellung wie bei Pong?
     57            float fieldWidth_=500;
     58            float fieldHeight_=700;
    5459            Vector2 velocity;
    5560            float maxspeed;
    56 
    57 
    58 
    5961    };
    6062}
    6163
    62 #endif /* _InvaderEnemy_H__ */
     64#endif /* _AsteroidsStone_H__ */
  • code/branches/Asteroid_HS17/src/modules/asteroids/CMakeLists.txt

    r11516 r11528  
    33  Asteroids.cc
    44  AsteroidsCenterPoint.cc
    5   InvaderShip.cc
     5  AsteroidsShip.cc
    66  AsteroidsStone.cc
    77  AsteroidsWeapon.cc
Note: See TracChangeset for help on using the changeset viewer.