Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11608


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

Asteroids2D erfolgreich als Minigame eingebunden, Dimensionen des Spielfeldes werden im CenterPoint gesetzt.

Location:
code/branches/Asteroid_HS17
Files:
2 added
17 edited

Legend:

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

    r11593 r11608  
    66/>
    77
    8 
    9 <!--wird immer gebraucht-->
    108<?lua
    119  include("stats.oxo")
     
    1311?>
    1412
    15 
    1613<?lua
    17   include ("overlays/HUDTemplates3.oxo")
     14  include("templates/spaceshipAssff2.oxt")
     15  include("templates/spaceshipPirate.oxt")
    1816  include("templates/spaceshipAsteroids2D.oxt")
     17  include("templates/enemyInvader.oxt")
     18  include("overlays/Asteroids2DHUD.oxo")
    1919?>
    2020
    21 <!--Templates schreiben oder von spaceship kopieren-->
    22 
    2321<Level
    24   plugin = asteroids2D
     22  plugins = asteroids2D
    2523  gametype = Asteroids2D
    2624>
     
    3028  <?lua include("includes/notifications.oxi") ?>
    3129
    32     <!-- ambientlight = "0.8, 0.8, 0.8"
    33     skybox       = "Orxonox/Starbox"
    34     WorldRange lieber im src einschraenken-->
    3530  <Scene
    36     ambientlight = "0.8, 0.7, 0.4"
    37     skybox     = "Orxonox/skyBoxBasic"
     31    ambientlight = "1.0, 1.0, 1.0"
     32    skybox       = "Orxonox/Starbox"
     33    negativeWorldRange = "-100000, -100000, -100000"
     34    positiveWorldRange = " 100000,  100000,  100000"
    3835  >
     36
     37  <WorldAmbientSound
     38    source="Earth.ogg"
     39    looping="true"
     40    playOnLoad="true"
     41  />
     42
     43    <!-- <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"/> -->
     44    <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" />
     45    <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass= Asteroids2DShip pawndesign=spaceshipasteroids2d />
     46
     47    <Model mesh="axes.mesh" scale=10 position="0,0,0" />
     48    <Asteroids2DCenterPoint name=asteroids2Dcenter />
    3949 
    40     <!-- <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"/> -->
    41     <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" />
    42 
    43     <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=Asteroids2DShip pawndesign=spaceshipasteroids2D/>
    44  
    45     <Asteroids2DCenterPoint name=asteroids2Dcenter />
    46 
    47     <Model mesh="axes.mesh" scale=10 position="0,0,-100" />
    48    
    4950   
    5051  </Scene>
    5152</Level>
    52 
    53 
  • code/branches/Asteroid_HS17/data/levels/MiniGameTest.oxw

    r11593 r11608  
    1515  include("templates/spaceshipMiniGameTest.oxt")
    1616  include("templates/enemyInvader.oxt")
    17   include("templates/DodgeRacePattern.oxt")
    18   include("overlays/DodgeRaceHUD.oxo")
     17  include("overlays/MiniGameTestHUD.oxo")
    1918?>
    2019
     
    3029  <Scene
    3130    ambientlight = "1.0, 1.0, 1.0"
    32     skybox       = "Orxonox/skyBoxClouds"
     31    skybox       = "Orxonox/Starbox"
    3332    negativeWorldRange = "-100000, -100000, -100000"
    3433    positiveWorldRange = " 100000,  100000,  100000"
     
    4342    <!-- <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"/> -->
    4443    <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" />
    45     <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass= MiniGameTestShip pawndesign=spaceshipdodgerace />
     44    <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass= MiniGameTestShip pawndesign=spaceshipminigametest />
     45
     46    <Model mesh="axes.mesh" scale=10 position="0,0,0" />
    4647
    4748    <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 />
     
    5051    <MiniGameTestCenterPoint name=invadercenter />
    5152 
    52   <StaticEntity position="0,-50,0" direction="0,0,0"   scale="1" collisionType=static mass=1 friction=0.01 >
    53       <attached>
    54         <Model position="0,0,0" mesh="plane.mesh" scale3D="100000,0,100000" />
    55       </attached>
    5653
    57       <collisionShapes>
    58         <BoxCollisionShape position="0,0,0" halfExtents="1,1,1" />
    59       </collisionShapes>
    60 
    61   </StaticEntity>
    6254   
    6355 
  • code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt

    r11593 r11608  
    1 <Template name=spaceshipasteroids2D>
    2   <SpaceShip
     1<Template name=spaceshipasteroids2d>
     2  <Asteroids2DShip
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipescortcameras
    55   spawnparticlesource    = "Orxonox/fairytwirl"
    66   spawnparticleduration  = 3
    7    explosionchunks        = 10
     7   explosionchunks        = 4
    88
    9    health            = 80
    10    maxhealth         = 200
    11    initialhealth     = 80
     9   health            = 40
     10   maxhealth         = 40
     11   initialhealth     = 40
    1212
    13    shieldhealth        = 35
    14    initialshieldhealth = 35
    15    maxshieldhealth     = 60
    16    shieldabsorption    = 0.9
     13   shieldhealth        = 20
     14   initialshieldhealth = 20
     15   maxshieldhealth     = 20
     16   shieldabsorption    = 0.1
    1717   shieldrechargerate  = 1
    1818   shieldrechargewaittime = 1
     
    3434
    3535   collisionType     = "dynamic"
    36    mass              = 80
    37    linearDamping     = 0.7
     36   mass              = 4200000
     37   linearDamping     = 0.9999999
    3838   angularDamping    = 0.9999999
     39
     40   collisiondamage = 100
     41   enablecollisiondamage = true
     42   
    3943  >
    4044    <engines>
    41       <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
    42       <MultiStateEngine position="-7.6, 0, 0" template=spaceshipescortengine />
     45      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipinvaderengine />
     46      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipinvaderengine />
    4347    </engines>
    4448    <attached>
     
    5660      <BoxCollisionShape position="0,     0,-12" halfExtents="4  , 4 ,7" />
    5761    </collisionShapes>
    58     <explosion>
     62    <explosion >
    5963      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_flash2" effect2="orxonox/explosion_flame2" />
    6064      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_shockwave2" effect2="orxonox/explosion_sparks2" />
    6165      <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_streak2" effect2="orxonox/explosion_afterglow" />
    6266
    63       <ExplosionPart mesh="explosionparts/escort_part_1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    64       <ExplosionPart mesh="explosionparts/escort_part_2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    65       <ExplosionPart mesh="explosionparts/escort_part_3.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    66       <ExplosionPart mesh="explosionparts/escort_part_4.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    67       <ExplosionPart mesh="explosionparts/escort_part_5.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    68       <ExplosionPart mesh="explosionparts/escort_part_6.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
     67      <ExplosionPart minspeed=0 maxspeed=0 effect1="Orxonox/explosion2b" effect2="Orxonox/smoke6" />
     68      <ExplosionPart mesh="CockpitDebris.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
     69      <ExplosionPart mesh="BodyDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
     70      <ExplosionPart mesh="WingDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
     71      <ExplosionPart mesh="WingDebris2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
    6972    </explosion>
    7073<?lua
    71   include("../includes/weaponSettingsEscort.oxi")
     74  include("../includes/invaderWeapon.oxi")
    7275?>
    73   </SpaceShip>
     76  </Asteroids2DShip>
    7477</Template>
    7578
    7679<Template name=spaceshipescortcameras defaults=0>
    77   <SpaceShip>
     80  <Asteroids2DShip>
    7881    <camerapositions>
    79       <CameraPosition position="0,600,0" pitch=-90 absolute=true />
    80       <CameraPosition position="0,50,160" drag=true mouselook=false />
    81       <CameraPosition position="0,40,125" drag=true mouselook=false/>
    82       <CameraPosition position="0,30, 90" drag=true mouselook=false/>
     82    <!--<CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
     83    <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true />
     84    <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
     85    <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
     86-->
     87    <CameraPosition position="0,600,0" pitch=-90 absolute=true />
     88    <CameraPosition position="0,50,160" drag=true mouselook=true />
     89    <CameraPosition position="0,40,125" drag=true mouselook=true />
     90    <CameraPosition position="0,30, 90" drag=true mouselook=true />
    8391    </camerapositions>
    84   </SpaceShip>
     92  </Asteroids2DShip>
    8593</Template>
    8694
    87 <Template name=spaceshipescortengine baseclass=MultiStateEngine>
     95<Template name=spaceshipinvaderengine baseclass=MultiStateEngine>
    8896  <MultiStateEngine
    8997   boostfactor    = 2.2
     
    105113    <EffectContainer condition="idle">
    106114      <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
    107        />
    108       <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, -2, 14" colour="0.2, 0.5, 0.65, 1.0" width=150 length=15 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=2 turnofftime=1 material="Flares/ThrusterFlare1" />
    109       <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, -2, 14" colour="0.2, 0.5, 0.65, 1.0" width=15 length=15 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=2 turnofftime=1 material="Flares/ThrusterFlare1" />
    110115    </EffectContainer>
    111116    <EffectContainer condition="not idle">
     
    117122    </EffectContainer>
    118123    <EffectContainer condition="normal or boost">
    119       <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, -2, 14" colour="0.2, 1.0, 0.65, 1.0" width=5 length=1500 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
    120       <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, -2, 14" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=1 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
     124      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
     125      <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
    121126    </EffectContainer>
    122 
    123127    <EffectContainer condition="boost">
    124128      <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
  • code/branches/Asteroid_HS17/data/levels/templates/spaceshipMiniGameTest.oxt

    r11593 r11608  
    1 <Template name=spaceshipdodgerace>
     1<Template name=spaceshipminigametest>
    22  <MiniGameTestShip
    33   hudtemplate            = spaceshiphud
     
    8080  <MiniGameTestShip>
    8181    <camerapositions>
    82                 <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
    83                 <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true />
    84                 <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
    85                 <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
     82    <!--<CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true />
     83    <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true />
     84    <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true />
     85    <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true />
     86-->
     87    <CameraPosition position="0,600,0" pitch=-90 absolute=true />
     88    <CameraPosition position="0,50,160" drag=true mouselook=true />
     89    <CameraPosition position="0,40,125" drag=true mouselook=true />
     90    <CameraPosition position="0,30, 90" drag=true mouselook=true />
    8691    </camerapositions>
    8792  </MiniGameTestShip>
  • code/branches/Asteroid_HS17/src/modules/CMakeLists.txt

    r11593 r11608  
    4747ADD_SUBDIRECTORY(superorxobros)
    4848ADD_SUBDIRECTORY(minigametest)
     49ADD_SUBDIRECTORY(asteroids2D)
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc

    r11593 r11608  
    3535#include "Asteroids2DShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
    3636#include "core/CoreIncludes.h"
    37 
     37#include "Highscore.h"
    3838
    3939namespace orxonox
     
    4444    {
    4545        RegisterObject(Asteroids2D);
    46         this->bEndGame = false;
    4746
     47        bEndGame = false;
     48        lives = 1;
     49        level = 1;
     50        point = 0;
     51        bShowLevel = false;
     52        multiplier = 1;
     53        b_combo = false;
     54        counter = 5000;
     55        pattern = 1;
     56        lastPosition = 0;
     57        // spawn enemy every 3.5 seconds
     58        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2D::spawnEnemy, this)));
     59        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
     60        this->center_ = nullptr;
     61        this->setHUDTemplate("Asteroids2DHUD");
     62    }
     63
     64    void Asteroids2D::levelUp()
     65    {
     66        level++;
     67        if (getPlayer() != nullptr)
     68        {
     69            for (int i = 0; i < 7; i++)
     70            {
     71                WeakPtr<ExplosionPart> chunk5 = new ExplosionPart(this->center_->getContext());
     72                chunk5->setPosition(Vector3(600, 0, 100.f * i - 300));
     73                chunk5->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
     74                chunk5->setScale(10);
     75                chunk5->setEffect1("Orxonox/explosion2b");
     76                chunk5->setEffect2("Orxonox/smoke6");
     77                chunk5->Explode();
     78
     79            }
     80        }
     81        addPoints(multiplier * 42);
     82        multiplier *= 2;
     83        toggleShowLevel();
     84        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
    4885    }
    4986
    5087    void Asteroids2D::tick(float dt)
    5188    {
    52 
     89       
    5390        SUPER(Asteroids2D, tick, dt);
    5491    }
     
    66103    }
    67104
     105    void Asteroids2D::costLife()
     106    {
     107        //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&Asteroids2D::end, this)));
     108        lives = 0;
     109    };
     110
    68111    void Asteroids2D::start()
    69112    {
    70113        orxout() << "start" << endl;
    71        
     114
    72115        // Set variable to temporarily force the player to spawn.
    73116        this->bForceSpawn_ = false;
     
    83126    }
    84127
     128    void Asteroids2D::playerPreSpawn(PlayerInfo* player)
     129    {
     130        if(lives <= 0)
     131        {
     132            this->end();
     133        }
     134    }
     135
     136    void Asteroids2D::addPoints(int numPoints)
     137    {
     138        if (!bEndGame)
     139        {
     140            point += numPoints * multiplier;
     141            b_combo = true;
     142        }
     143    }
     144
    85145    void Asteroids2D::end()
    86146    {
     
    89149        // It will misteriously crash the game!
    90150        // Instead startMainMenu, this won't crash.
    91         orxout() << "Asteroids2D Game has ended" << endl;
     151        if (Highscore::exists()){
     152                    int score = this->getPoints();
     153                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
     154                        Highscore::getInstance().storeHighscore("Dodge Race",score);
     155
     156          }
    92157        GSLevel::startMainMenu();
    93158    }
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h

    r11593 r11608  
    5050#include "gamestates/GSLevel.h"
    5151#include "chat/ChatManager.h"
    52 
     52#include <vector>
    5353
    5454// ! HACK
     
    5858
    5959#include "gametypes/Deathmatch.h"
     60#include "tools/Timer.h"
    6061
    6162namespace orxonox
     
    6970            virtual void start() override;
    7071            virtual void end() override;
     72
    7173            virtual void tick(float dt) override;
     74
     75            virtual void playerPreSpawn(PlayerInfo* player) override;
     76
     77            void levelUp();
     78
     79            int getLives(){return this->lives;}
     80            int getLevel(){return this->level;}
     81            int getPoints(){return this->point;}
     82            int getMultiplier(){return this->multiplier;}
    7283
    7384            void setCenterpoint(Asteroids2DCenterPoint* center)
    7485                       { this->center_ = center; }
     86            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
    7587
    76             virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
     88            // checks if multiplier should be reset.
     89            void costLife();
     90
    7791            bool bEndGame;
     92            bool bShowLevel;
     93            int lives;
     94            int multiplier;
     95            float counter;
     96            int pattern;
     97            float currentPosition;
     98            float lastPosition;
    7899
    79100       private:
    80 
     101            Timer endGameTimer;
    81102
    82103            Asteroids2DShip* getPlayer();
    83104            WeakPtr<Asteroids2DShip> player;
     105            std::vector<Asteroids2DCube*> cubeList;
     106            void toggleShowLevel(){bShowLevel = !bShowLevel;}
     107            void addPoints(int numPoints);
     108
    84109            WeakPtr<Asteroids2DCenterPoint> center_;
     110            int level;
     111            int point;
     112            bool b_combo;
     113
     114            Timer enemySpawnTimer;
     115            Timer comboTimer;
     116            Timer showLevelTimer;
    85117
    86118
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc

    r11593 r11608  
    3535
    3636#include "core/CoreIncludes.h"
     37#include "core/XMLPort.h"
    3738
    3839#include "Asteroids2D.h"
     
    4748
    4849        this->checkGametype();
     50        this->width_ = 200;
     51        this->height_ = 120;
    4952    }
     53    /**
     54    @brief
     55        Method to create a Asteroids2DCenterpoint through XML.
     56    */
     57    void Asteroids2DCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     58    {
     59        SUPER(Asteroids2DCenterPoint, XMLPort, xmlelement, mode);
    5060
     61        XMLPortParam(Asteroids2DCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
     62    }
    5163    void Asteroids2DCenterPoint::checkGametype()
    5264    {
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h

    r11593 r11608  
    4949        public:
    5050            Asteroids2DCenterPoint(Context* context); //checks whether the gametype is actually Asteroids2D.
     51            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method to create a PongCenterpoint through XML.
     52            /**
     53            @brief Set the dimensions of the playing field.
     54            @param dimension A vector with the width of the playing field as first component and the height as second.
     55            */
     56            void setFieldDimension(const Vector2& dimension)
     57                { this->width_ = dimension.x; this->height_ = dimension.y; }
     58            /**
     59            @brief Get the dimensions of the playing field.
     60            @return Returns a vector with the width of the playing field as first component and the height as second.
     61            */
     62            Vector2 getFieldDimension() const
     63                { return Vector2(this->width_, this->height_); }
    5164
    5265        private:
    5366            void checkGametype();
     67            float width_, height_;
    5468
    5569    };
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc

    r11593 r11608  
    2525 */
    2626
    27 #include "DodgeRaceHUDinfo.h"
     27#include "Asteroids2DHUDinfo.h"
    2828
    2929#include "core/CoreIncludes.h"
    3030#include "core/XMLPort.h"
    3131#include "util/Convert.h"
    32 //#include "DodgeRace.h"
     32//#include "Asteroids2D.h"
    3333
    3434namespace orxonox
    3535{
    36     RegisterClass(DodgeRaceHUDinfo);
     36    RegisterClass(Asteroids2DHUDinfo);
    3737
    38     DodgeRaceHUDinfo::DodgeRaceHUDinfo(Context* context) : OverlayText(context)
     38    Asteroids2DHUDinfo::Asteroids2DHUDinfo(Context* context) : OverlayText(context)
    3939    {
    40         RegisterObject(DodgeRaceHUDinfo);
     40        RegisterObject(Asteroids2DHUDinfo);
    4141
    42         this->DodgeRaceGame = nullptr;
     42        this->Asteroids2DGame = nullptr;
    4343        this->bShowPoints_ = true;
    4444    }
    4545
    46     void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     46    void Asteroids2DHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    4747    {
    48         SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode);
     48        SUPER(Asteroids2DHUDinfo, XMLPort, xmlelement, mode);
    4949
    50         XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
     50        XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
    5151    }
    5252
    53     void DodgeRaceHUDinfo::tick(float dt)
     53    void Asteroids2DHUDinfo::tick(float dt)
    5454    {
    55         SUPER(DodgeRaceHUDinfo, tick, dt);
     55        SUPER(Asteroids2DHUDinfo, tick, dt);
    5656
    5757
    5858        if(this->bShowPoints_)
    5959        {
    60             const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints());
    61             if (this->DodgeRaceGame->lives <= 0)
     60            const std::string& points = multi_cast<std::string>(this->Asteroids2DGame->getPoints());
     61            if (this->Asteroids2DGame->lives <= 0)
    6262            {
    6363                setTextSize(0.2);
     
    7676    }
    7777
    78     void DodgeRaceHUDinfo::changedOwner()
     78    void Asteroids2DHUDinfo::changedOwner()
    7979    {
    80         SUPER(DodgeRaceHUDinfo, changedOwner);
     80        SUPER(Asteroids2DHUDinfo, changedOwner);
    8181
    8282        if (this->getOwner() && this->getOwner()->getGametype())
    8383        {
    84             this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype());
     84            this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype());
    8585        }
    8686        else
    8787        {
    88             this->DodgeRaceGame = nullptr;
     88            this->Asteroids2DGame = nullptr;
    8989        }
    9090    }
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc

    r11593 r11608  
    5555    void Asteroids2DShip::tick(float dt)
    5656    {
    57         Vector3 pos = getPosition();
    58 
    59         //Movement calculation
    60         lastTimeFront += dt * damping;
    61         lastTimeLeft += dt * damping;
    62         lastTime += dt;
    63 
    64         velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
    65         velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
    66 
    67         //Execute movement
    68         if (this->hasLocalController())
    69         {
    70             float dist_y = velocity.y * dt;
    71             //float dist_x = velocity.x * dt;
    72             if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
    73                 posforeward += dist_y;
    74             else
    75             {
    76                 velocity.y = 0;
    77                 // restart if game ended
    78 /*
    79                 if (getGame())
    80                     if (getGame()->bEndGame)
    81                     {
    82                         getGame()->start();
    83                         return;
    84                     }*/
    85             }
    86 
    87             pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
    88         }
    89 
    90         // bring back on track!
    91         if(pos.y != 0)
    92         {
    93             pos.y = 0;
    94         }
    95 
    96         setPosition(pos);
    97         setOrientation(Vector3::UNIT_Y, Degree(270));
    98 
    9957        SUPER(Asteroids2DShip, tick, dt);
    10058    }
    10159
    102     void Asteroids2DShip::moveFrontBack(const Vector2& value)
     60    void Asteroids2DShip::updateLevel()
     61    {
     62        lastTime = 0;
     63        if (getGame())
     64            getGame()->levelUp();
     65    }
     66
     67/*    void Asteroids2DShip::moveFrontBack(const Vector2& value)
    10368    {
    10469        //lastTimeFront = 0;
    10570        //desiredVelocity.y = value.y * speed * 42;
    106 
     71        orxout() << "FrontBack" << endl;
     72        SUPER(Asteroids2DShip, moveFrontBack, value);
    10773    }
    10874
    10975    void Asteroids2DShip::moveRightLeft(const Vector2& value)
    11076    {
    111         lastTimeLeft = 0;
    112         desiredVelocity.x = value.x * speed;
     77        //lastTimeLeft = 0;
     78        //desiredVelocity.x = value.x * speed;
     79        orxout() << "RightLeft" << endl;
     80        SUPER(Asteroids2DShip, moveFrontBack, value);       
    11381    }
     82 */
    11483    void Asteroids2DShip::boost(bool bBoost)
    11584    {
     
    139108    void Asteroids2DShip::death()
    140109    {
    141         //getGame()->costLife();
     110        getGame()->costLife();
    142111        SpaceShip::death();
    143112    }
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h

    r11593 r11608  
    5555
    5656            // overwrite for 2d movement
    57             virtual void moveFrontBack(const Vector2& value) override;
    58             virtual void moveRightLeft(const Vector2& value) override;
     57            //virtual void moveFrontBack(const Vector2& value) override;
     58            //virtual void moveRightLeft(const Vector2& value) override;
    5959
    6060            // Starts or stops fireing
     
    6262
    6363            //no rotation!
     64            virtual void rotateYaw(const Vector2& value) override{};
    6465            virtual void rotatePitch(const Vector2& value) override{};
    6566
    6667            //return to main menu if game has ended.
    6768            virtual void rotateRoll(const Vector2& value) override{if (getGame()) if (getGame()->bEndGame) getGame()->end();};
     69
     70            virtual void updateLevel();
    6871
    6972            virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/CMakeLists.txt

    r11593 r11608  
    1 SET_SOURCE_FILES(Asteroids2D_SRC_FILES
     1SET_SOURCE_FILES(MINIGAMESTEST_SRC_FILES
    22Asteroids2D.cc
    33Asteroids2DCenterPoint.cc
    44Asteroids2DShip.cc
     5Asteroids2DCube.cc
     6Asteroids2DHUDinfo.cc
    57)
    68
     
    1113    orxonox
    1214    overlays
    13   SOURCE_FILES ${ASTEROIDS2D_SRC_FILES}
     15  SOURCE_FILES ${MINIGAMESTEST_SRC_FILES}
    1416)
  • code/branches/Asteroid_HS17/src/modules/minigametest/MiniGameTest.cc

    r11593 r11608  
    3434#include "MiniGameTest.h"
    3535#include "MiniGameTestShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
    36 #include "MiniGameTestCube.h"
    3736#include "core/CoreIncludes.h"
    3837#include "Highscore.h"
     
    5857        // spawn enemy every 3.5 seconds
    5958        //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&MiniGameTest::spawnEnemy, this)));
    60         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&MiniGameTest::comboControll, this)));
    6159        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
    6260        this->center_ = nullptr;
    63 
    6461        this->setHUDTemplate("MiniGameTestHUD");
    6562    }
     
    9087    void MiniGameTest::tick(float dt)
    9188    {
    92         if (getPlayer() != nullptr)
    93         {
    94             currentPosition = getPlayer()->getWorldPosition().x;
    95             counter = counter + (currentPosition - lastPosition);
    96             lastPosition = currentPosition;
    97             point = (int) currentPosition;
    98             getPlayer()->speed = 830.0f - (point / 1000);
    99 
    100             for(unsigned int i=0; i < cubeList.size();i++)
    101             {
    102                 if(cubeList.at(i)->getPosition().x < currentPosition-3000)
    103                 {
    104                     cubeList.at(i)->destroy();
    105                     cubeList.erase(cubeList.begin()+i);
    106                 }
    107             }
    108 
    109             if(counter >= 3000)
    110             {
    111                 counter = 0;
    112                 for(int i = 0; i<6; i++)
    113                 {
    114                     MiniGameTestCube* cube = new MiniGameTestCube(this->center_->getContext());
    115                     cubeList.push_back(cube);
    116                     switch(pattern)
    117                     {
    118                     case 1: cube->addTemplate("MiniGameTestCube01");
    119                     break;
    120                     case 2: cube->addTemplate("MiniGameTestCube02");
    121                     break;
    122 
    123                     }
    124 
    125                     cube->setPosition(getPlayer()->getWorldPosition() + Vector3(5000.0f, 0.0f, -3600.0f + (i*1200)));
    126                     //stEntity->setScale3D(50,50,50);
    127                 }
    128 
    129 
    130                 pattern %= 2;
    131                 pattern ++;
    132 
    133             }
    134 
    135         }
     89       
    13690        SUPER(MiniGameTest, tick, dt);
    13791    }
     
    155109    };
    156110
    157     void MiniGameTest::comboControll()
    158     {
    159         if (b_combo)
    160             multiplier++;
    161         // if no combo was performed before, reset multiplier
    162         else
    163             multiplier = 1;
    164         b_combo = false;
    165     }
    166 
    167111    void MiniGameTest::start()
    168112    {
    169113        orxout() << "start" << endl;
    170         for(unsigned int i=0; i< cubeList.size();i++)
    171         {
    172             cubeList.at(i)->destroy();
    173             cubeList.erase(cubeList.begin()+i);
    174114
    175         }
    176         cubeList.clear();
    177115        // Set variable to temporarily force the player to spawn.
    178116        this->bForceSpawn_ = false;
     
    194132            this->end();
    195133        }
    196 
    197         // Reset all the cubes
    198         /*
    199         orxout() << "prespawn" << endl;
    200         for(int i=0; i< cubeList.size();i++)
    201         {
    202             cubeList.at(i)->destroy();
    203             cubeList.erase(cubeList.begin()+i);
    204         }
    205         cubeList.clear();
    206         lives = 1;
    207         point = 0;
    208         lastPosition = 0;
    209         */
    210134    }
    211135
  • code/branches/Asteroid_HS17/src/modules/minigametest/MiniGameTest.h

    r11593 r11608  
    8787
    8888            // checks if multiplier should be reset.
    89             void comboControll();
    9089            void costLife();
    9190
  • code/branches/Asteroid_HS17/src/modules/minigametest/MiniGameTestShip.cc

    r11593 r11608  
    5555    void MiniGameTestShip::tick(float dt)
    5656    {
    57         Vector3 pos = getPosition();
    58 
    59         //Movement calculation
    60         lastTimeFront += dt * damping;
    61         lastTimeLeft += dt * damping;
    62         lastTime += dt;
    63 
    64         velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
    65         velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
    66 
    67         //Execute movement
    68         if (this->hasLocalController())
    69         {
    70             float dist_y = velocity.y * dt;
    71             //float dist_x = velocity.x * dt;
    72             if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
    73                 posforeward += dist_y;
    74             else
    75             {
    76                 velocity.y = 0;
    77                 // restart if game ended
    78 /*
    79                 if (getGame())
    80                     if (getGame()->bEndGame)
    81                     {
    82                         getGame()->start();
    83                         return;
    84                     }*/
    85             }
    86 
    87             pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
    88         }
    89 
    90 
    91         // Camera
    92         Camera* camera = this->getCamera();
    93         if (camera != nullptr)
    94         {
    95             // camera->setPosition(Vector3(-pos.z, -posforeward, 0));
    96             camera->setOrientation(Vector3::UNIT_Z, Degree(0));
    97         }
    98 
    99 
    100 
    101         // bring back on track!
    102         if(pos.y != 0)
    103         {
    104             pos.y = 0;
    105         }
    106 
    107         setPosition(pos);
    108         setOrientation(Vector3::UNIT_Y, Degree(270));
    109 
    110         // Level up!
    111         if (pos.x > 42000)
    112         {
    113             updateLevel();
    114             setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
    115         }
    116 
    11757        SUPER(MiniGameTestShip, tick, dt);
    11858    }
     
    12565    }
    12666
    127     void MiniGameTestShip::moveFrontBack(const Vector2& value)
     67/*    void MiniGameTestShip::moveFrontBack(const Vector2& value)
    12868    {
    12969        //lastTimeFront = 0;
    13070        //desiredVelocity.y = value.y * speed * 42;
    131 
     71        orxout() << "FrontBack" << endl;
     72        SUPER(MiniGameTestShip, moveFrontBack, value);
    13273    }
    13374
    13475    void MiniGameTestShip::moveRightLeft(const Vector2& value)
    13576    {
    136         lastTimeLeft = 0;
    137         desiredVelocity.x = value.x * speed;
     77        //lastTimeLeft = 0;
     78        //desiredVelocity.x = value.x * speed;
     79        orxout() << "RightLeft" << endl;
     80        SUPER(MiniGameTestShip, moveFrontBack, value);       
    13881    }
     82 */
    13983    void MiniGameTestShip::boost(bool bBoost)
    14084    {
  • code/branches/Asteroid_HS17/src/modules/minigametest/MiniGameTestShip.h

    r11593 r11608  
    5555
    5656            // overwrite for 2d movement
    57             virtual void moveFrontBack(const Vector2& value) override;
    58             virtual void moveRightLeft(const Vector2& value) override;
     57            //virtual void moveFrontBack(const Vector2& value) override;
     58            //virtual void moveRightLeft(const Vector2& value) override;
    5959
    6060            // Starts or stops fireing
     
    8282            WeakPtr<MiniGameTest> game;
    8383            WeakPtr<WorldEntity> lastEntity;
    84             Camera* camera;
    8584            float lastTimeFront, lastTimeLeft, lastTime;
    8685            struct Velocity
Note: See TracChangeset for help on using the changeset viewer.