Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11637


Ignore:
Timestamp:
Dec 4, 2017, 4:17:43 PM (6 years ago)
Author:
vyang
Message:

Asteroiden werden generiert und bewegen sich, HUD muss noch angepasst werden, Punkte und Health und Leben anzeigen. Raumschiff kann noch nicht schiessen, evtl auch Schutzfunktion → nachdem ein Leben verloren wurde 2s Immunitaet?

Location:
code/branches/Asteroid_HS17
Files:
11 edited

Legend:

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

    r11617 r11637  
    1717  include("templates/enemyInvader.oxt")
    1818  include("overlays/Asteroids2DHUD.oxo")
    19   include("templates/asteroidsAsteroids2D.oxt)
     19  include("templates/asteroidsAsteroids2D.oxt")
    2020?>
    2121
     
    7676    ?>-->
    7777
    78 
    79     <Asteroids2DStone
    80       collisionType = dynamic
    81       linearDamping = 0.8
    82       angularDamping = 1
    83       scale= 10
    84       enablecollisiondamage = true
    85     >
    86       <attached>
    87         <Model mass= 8000 mesh="ast1.mesh" />
    88       </attached>
    89       <collisionShapes>
    90         <SphereCollisionShape radius="10" />
    91       </collisionShapes>
    92     </Asteroids2DStone>
    93 
    9478    <Asteroids2DCenterPoint name=asteroids2Dcenter />
    9579 
  • code/branches/Asteroid_HS17/data/levels/templates/asteroidsAsteroids2D.oxt

    r11617 r11637  
    22  <Asteroids2DStone
    33    collisionType = dynamic
    4     linearDamping = 0.8
    5     angularDamping = 1
     4    linearDamping = 0
     5    angularDamping = 0
    66    scale= 10
    77    enablecollisiondamage = true
     
    2323  <Asteroids2DStone
    2424    collisionType = dynamic
    25     linearDamping = 0.8
    26     angularDamping = 1
     25    linearDamping = 0
     26    angularDamping = 0
    2727    scale= 20
    2828    enablecollisiondamage = true
     
    3333  >
    3434    <attached>
    35       <Model mass= 8000 mesh="ast2.mesh" />
     35      <Model mass= 8000 mesh="ast1.mesh" />
    3636    </attached>
    3737    <collisionShapes>
     
    4444  <Asteroids2DStone
    4545    collisionType = dynamic
    46     linearDamping = 0.8
    47     angularDamping = 1
     46    linearDamping = 0
     47    angularDamping = 0
    4848    scale= 30
    4949    enablecollisiondamage = true
     
    5454  >
    5555    <attached>
    56       <Model mass= 16000 mesh="ast3.mesh" />
     56      <Model mass= 16000 mesh="ast1.mesh" />
    5757    </attached>
    5858    <collisionShapes>
  • code/branches/Asteroid_HS17/data/levels/templates/spaceshipAsteroids2D.oxt

    r11614 r11637  
    77   explosionchunks        = 4
    88
    9    health            = 40
    10    maxhealth         = 40
    11    initialhealth     = 40
     9   health            = 1000
     10   maxhealth         = 1000
     11   initialhealth     = 1000
    1212
    1313   shieldhealth        = 20
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.cc

    r11619 r11637  
    5252
    5353        bEndGame = false;
    54         lives = 3;
     54        lives = 5;
    5555        level = 1;
    5656        point = 0;
     
    6262        this->center_ = nullptr;
    6363        this->setHUDTemplate("Asteroids2DHUD");
    64         levelupTimer.setTimer(100.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));
     64        levelupTimer.setTimer(60.0f, true, createExecutor(createFunctor(&Asteroids2D::levelUp, this)));
    6565    }
    6666
     
    7272        if (getPlayer() != nullptr)
    7373        {
     74
     75            //kann schoener gemacht werden
    7476            for (int i = 0; i < 7; i++)
    7577            {
     
    8486            }
    8587        }
    86         addPoints(multiplier * 42);
     88        addPoints(multiplier * 20);
    8789        multiplier *= 2;
    8890        toggleShowLevel();
    8991        showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Asteroids2D::toggleShowLevel, this)));
     92
     93
    9094        //Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad
    9195        for(int i = 0; i < level*2; i++){
     
    100104        if(this->firstTick_)
    101105        {
     106            getPlayer();
    102107            for(int i = 0; i < 5; ++i)
    103108            {
    104109                spawnStone();
    105110            }
     111
    106112            this->firstTick_ = false;
    107113        }
     
    112118    void Asteroids2D::spawnStone()
    113119    {
    114         if (getPlayer() == nullptr)
    115             return;
    116120        Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
    117121        newStone->setAsteroids2DPlayer(player);
     
    132136
    133137        }
    134 
    135 
    136138    }
    137139
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h

    r11619 r11637  
    7979            void levelUp();
    8080
     81
     82            //For HUD
    8183            int getLives(){return this->lives;}
    8284            int getLevel(){return this->level;}
     
    8486            int getMultiplier(){return this->multiplier;}
    8587
     88            //Generate Stones
    8689            void spawnStone();
    8790            void setCenterpoint(Asteroids2DCenterPoint* center)
    88                        { this->center_ = center; }
     91                { this->center_ = center; }
     92            void addPoints(int numPoints);
    8993            virtual void addBots(unsigned int amount) override{} //<! overwrite function in order to bypass the addbots command
    9094
    9195            // checks if multiplier should be reset.
    9296            void costLife();
    93 
     97            Asteroids2DShip* getPlayer();
    9498
    9599            bool bEndGame;
     
    101105
    102106
    103             Asteroids2DShip* getPlayer();
     107
    104108            WeakPtr<Asteroids2DShip> player;
    105109            void toggleShowLevel(){bShowLevel = !bShowLevel;}
    106             void addPoints(int numPoints);
    107110
    108111            WeakPtr<Asteroids2DCenterPoint> center_;
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.cc

    r11608 r11637  
    4141
    4242        this->Asteroids2DGame = nullptr;
     43        this->Ship = nullptr;
    4344        this->bShowPoints_ = true;
     45        this->bShowHealth_ = true;
    4446    }
    4547
     
    4951
    5052        XMLPortParam(Asteroids2DHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
     53        XMLPortParam(Asteroids2DHUDinfo,"showHealth", setShowHealth, getShowHealth, xmlelement, mode).defaultValues(false);
    5154    }
    5255
     
    7477            }
    7578        }
     79
     80        /*if(this->bShowHealth_)
     81        {
     82            const std::string& health = multi_cast<std::string>(this->Ship->getHealth());
     83            if (this->Asteroids2DGame->lives <= 0)
     84            {
     85                setTextSize(0.2);
     86                setPosition(Vector2(0.1, 0.02));
     87                this->setCaption("Final score:\n" + health);
     88                this->setColour(ColourValue(1, 0, 0, 1));
     89            }
     90            else
     91            {
     92                setTextSize(0.04);
     93                setPosition(Vector2(0.2, 0.02));
     94                this->setColour(ColourValue(1, 1, 1, 1));
     95                this->setCaption(health);
     96            }
     97        }*/
    7698    }
    7799
     
    80102        SUPER(Asteroids2DHUDinfo, changedOwner);
    81103
    82         if (this->getOwner() && this->getOwner()->getGametype())
     104        if (this->getOwner() && this->getOwner()->getGametype())//&& this->getOwner->getPlayer())
    83105        {
    84106            this->Asteroids2DGame = orxonox_cast<Asteroids2D*>(this->getOwner()->getGametype());
     107            //this->Ship = orxonox_cast<Asteroids2DShip*>(this->getOwner()->getPlayer());
    85108        }
    86109        else
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DHUDinfo.h

    r11593 r11637  
    5353                { return this->bShowPoints_; }
    5454
     55            inline void setShowHealth(bool value)
     56                { this->bShowHealth_ = value; }
     57            inline bool getShowHealth() const
     58                { return this->bShowHealth_; }
     59
    5560
    5661        private:
    5762            Asteroids2D* Asteroids2DGame;
     63            Asteroids2DShip* Ship;
    5864            bool bShowPoints_;
     65            bool bShowHealth_;
    5966    };
    6067}
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc

    r11617 r11637  
    3737
    3838#include "Asteroids2DShip.h"
     39#include "Asteroids2DStone.h"
    3940#include "core/CoreIncludes.h"
    4041
     
    8990    }
    9091
    91 /*    void Asteroids2DShip::moveFrontBack(const Vector2& value)
    92     {
    93         //lastTimeFront = 0;
    94         //desiredVelocity.y = value.y * speed * 42;
    95         orxout() << "FrontBack" << endl;
    96         SUPER(Asteroids2DShip, moveFrontBack, value);
    97     }
    98 
    99     void Asteroids2DShip::moveRightLeft(const Vector2& value)
    100     {
    101         //lastTimeLeft = 0;
    102         //desiredVelocity.x = value.x * speed;
    103         orxout() << "RightLeft" << endl;
    104         SUPER(Asteroids2DShip, moveFrontBack, value);       
    105     }
    106  */
    10792    void Asteroids2DShip::boost(bool bBoost)
    10893    {
     
    11297    inline bool Asteroids2DShip::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    11398    {
    114 
    11599        removeHealth(100);
    116         this->death();
     100        getGame()->addPoints(10);
    117101        return false;
    118102    }
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h

    r11617 r11637  
    5757            virtual void tick(float dt) override;
    5858
    59             // overwrite for 2d movement
    60             //virtual void moveFrontBack(const Vector2& value) override;
    61             //virtual void moveRightLeft(const Vector2& value) override;
    62 
    6359            // Starts or stops fireing
    6460            virtual void boost(bool bBoost) override;
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc

    r11616 r11637  
    4444    {
    4545        RegisterObject(Asteroids2DStone);
    46         this->size = 1;
     46        this->size = rand()%3+1;
    4747        this->width = 1043;
    4848        this->height = 646;
    4949        this->setPosition(randomPosition(this->width, this->height));
     50        this->setCollisionTypeStr("dynamic");
     51        this->setVelocity(randomVelocity(MAX_SPEED));
     52    }
     53
     54    Asteroids2DStone::Asteroids2DStone(Context* c, int sze, Vector3 pos) : Pawn(c)
     55    {
     56        RegisterObject(Asteroids2DStone);
     57        this->size = sze;
     58        this->width = 1043;
     59        this->height = 646;
     60        this->setPosition(pos);
     61        this->setCollisionTypeStr("dynamic");
    5062        this->setVelocity(randomVelocity(MAX_SPEED));
    5163    }
     
    7486        SUPER(Asteroids2DStone, tick, dt);
    7587        Vector3 pos = this->getPosition();
    76         if(pos.x >= width/2 || pos.x <= -width/2 || pos.z >= height/2 || pos.z <= -height/2)
    77         {
    78             Quaternion orientation = this->getOrientation();
    79             orientation.w -= 180;
    80             this->setOrientation(Vector3::UNIT_Y, Degree(orientation.w));
     88
     89        if(pos.x >= width/2){
     90            pos.x = -width/2;
     91        }else if(pos.x <= -width/2){
     92            pos.x = -width/2;
     93        }else if(pos.z >= height/2){
     94            pos.z = -height/2;
     95        }else if(pos.z <= -height/2){
     96            pos.z = -width/2;
    8197        }
    8298
     99        this->setPosition(pos);
     100
    83101    }
     102
     103    inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     104    {
     105        if(orxonox_cast<Asteroids2DShip*>(otherObject))
     106        {
     107            this->split();
     108        }
     109        return false;
     110    }
     111
     112    void Asteroids2DStone::split()
     113    {
     114        if(size == 1)
     115        {
     116            this->death();
     117
     118        }else if(size == 2){
     119            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
     120            newStone1->addTemplate("stone1");
     121            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
     122            newStone2->addTemplate("stone1");
     123        }else{
     124            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
     125            newStone1->addTemplate("stone1");
     126            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
     127            newStone2->addTemplate("stone1");
     128        }
     129    }
     130
     131
    84132
    85133
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.h

    r11619 r11637  
    4848       public:
    4949            Asteroids2DStone(Context* context);
     50            Asteroids2DStone(Context* c, int sze, Vector3 pos);
     51
    5052            virtual void tick(float dt) override;
    5153            Vector3 randomPosition (float maxwidth, float maxheight);
     
    5355            void setAsteroids2DPlayer(Asteroids2DShip* player){this->player = player;};
    5456            virtual int getSize(){ return this->size;}
     57            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
     58            virtual void split();
    5559
    5660       private:
     
    5862                int size;                               // three sizes, 3-> two 2s, 2-> two 1s, 1-> die
    5963                float width, height;    //field
    60           float MAX_SPEED = 500;
     64          float MAX_SPEED = 100;
     65          float delta = 5;
    6166    };
    6267}
Note: See TracChangeset for help on using the changeset viewer.