Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11660


Ignore:
Timestamp:
Dec 11, 2017, 4:06:44 PM (6 years ago)
Author:
vyang
Message:

Projektile fliegen in 2D Ebene, jedoch in eine falsche Richtung. Kommentare hinzugefuegt

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  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      ...
     
    2727 */
    2828
    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
    3330
    3431/**
    3532    @file Asteroids2D.cc
    3633    @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
    3739*/
    3840
     
    6264        this->center_ = nullptr;
    6365        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
    6567    }
    6668
     
    9294
    9395
    94         //Nach jedem Level Up werden mehr Steine gespawnt -> abhängig vom Schwierigkeitsgrad
     96        //After level up -> spawn stones
    9597        for(int i = 0; i < level*2; i++){
    9698            spawnStone();
     
    101103    void Asteroids2D::tick(float dt)
    102104    {
    103         //Do this only for the first tick, generate 5 stones for the beginning
     105        //Do this only for the first tick, generate 5 stones in the beginning
    104106        if(this->firstTick_)
    105107        {
     
    118120    void Asteroids2D::spawnStone()
    119121    {
     122
     123        //stones are created with a size
    120124        Asteroids2DStone* newStone = new Asteroids2DStone(this->center_->getContext());
    121125        newStone->setAsteroids2DPlayer(player);
     
    158162    };
    159163   
    160 //Funktion wird als erstes im Level aufgerufen
     164    //The first function that will be called
    161165    void Asteroids2D::start()
    162166    {
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2D.h

    r11637 r11660  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      ...
     
    3131/**
    3232    @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     -
    3438    @ingroup Asteroids2D
    3539*/
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.cc

    r11613 r11660  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      ...
     
    5454    @brief
    5555        Method to create a Asteroids2DCenterpoint through XML.
     56        Set dimension of the field with "width_, height_"
    5657    */
    5758    void Asteroids2DCenterPoint::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    6162        XMLPortParam(Asteroids2DCenterPoint, "dimension", setFieldDimension, getFieldDimension, xmlelement, mode);
    6263    }
     64
     65
    6366    void Asteroids2DCenterPoint::checkGametype()
    6467    {
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DCenterPoint.h

    r11608 r11660  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      ...
     
    6464
    6565        private:
    66             void checkGametype();
     66            void checkGametype(); //checks whether the gametype actually is Asteroids2D
    6767            float width_, height_;
    6868
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.cc

    r11645 r11660  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      ...
     
    2727 */
    2828
    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:
    3230
    3331/**
     
    5452        this->height = 646;
    5553
    56         timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showposition, this)));
     54        //timer.setTimer(3.5f, true, createExecutor(createFunctor(&Asteroids2DShip::showorientation, this)));
    5755    }
    5856
     
    6462    }
    6563
     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
    6671    void Asteroids2DShip::tick(float dt)
    6772    {
     
    6974        Vector3 pos = this->getPosition();
    7075
    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
    7277        if(pos.x > width/2)   pos.x = -width/2;
    7378        if(pos.x < -width/2)  pos.x = width/2;
     
    7984        this->setPosition(pos);
    8085
    81         //update level
     86
    8287
    8388        //shoot?
     89    }
     90
     91    void Asteroids2DShip::boost(bool bBoost)
     92    {
     93        isFireing = bBoost;
    8494    }
    8595
     
    8898        if (getGame())
    8999            getGame()->levelUp();
    90     }
    91 
    92     void Asteroids2DShip::boost(bool bBoost)
    93     {
    94         //getGame()->bEndGame = bBoost;
    95100    }
    96101
     
    107112            bImmune = true;
    108113            isimmune.setTimer(3.0f, false, createExecutor(createFunctor(&Asteroids2DShip::toggleImmune, this)));
    109             orxout()<< "touched" << endl;
    110114        }
    111115        return false;
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DShip.h

    r11645 r11660  
    6060            virtual void tick(float dt) override;
    6161
    62             // Starts or stops fireing
    63             virtual void boost(bool bBoost) override;
    64 
    6562            //no rotation in x and z direction!
    66             //virtual void rotateYaw(const Vector2& value) override{}; // Rotate in yaw direction.
    6763            virtual void rotatePitch(const Vector2& value) override{}; // Rotate in pitch direction.
    6864            virtual void rotateRoll(const Vector2& value) override{}; // Rotate in roll direction.
    69 
     65            virtual void boost(bool boost) override;
    7066            virtual void updateLevel();
    7167
    7268            virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    7369
    74             float speed, damping, posforeward;
     70            float speed, damping;
    7571            bool isFireing;
    7672            void showposition();
     73            void showorientation();
    7774            void toggleImmune()
    7875            {
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DStone.cc

    r11637 r11660  
    2020 *
    2121 *   Author:
    22  *      Samuel Riedel
     22 *      Viviane Yang
    2323 *   Co-authors:
    2424 *      ...
     
    2626 */
    2727
     28
     29
    2830/**
    2931    @file Asteroids2DStone.cc
     32
    3033    @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*/
    3239
    3340#include "Asteroids2DStone.h"
     
    8794        Vector3 pos = this->getPosition();
    8895
     96
    8997        if(pos.x >= width/2){
    9098            pos.x = -width/2;
     
    103111    inline bool Asteroids2DStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    104112    {
     113        orxout() << "AsteroidStone getroffen" << endl;
    105114        if(orxonox_cast<Asteroids2DShip*>(otherObject))
    106115        {
    107             this->split();
     116            orxout() << "getroffen von Ship" << endl;
     117            split();
    108118        }
    109119        return false;
     
    112122    void Asteroids2DStone::split()
    113123    {
     124        orxout() << "split" << endl;
    114125        if(size == 1)
    115126        {
     
    117128
    118129        }else if(size == 2){
     130
     131
     132            //Templates can be found in data/levels/templates/asteroidsAsteroids2D.oxt
    119133            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
    120134            newStone1->addTemplate("stone1");
    121135            Asteroids2DStone* newStone2 = new Asteroids2DStone(this->getContext(), 1, this->getPosition());
    122136            newStone2->addTemplate("stone1");
     137           
    123138        }else{
    124139            Asteroids2DStone* newStone1 = new Asteroids2DStone(this->getContext(), 2, this->getPosition());
     
    129144    }
    130145
    131 
    132 
    133 
    134     //Overload kill function to generate 2 asteriods
    135     /*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 
    150146}
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.cc

    r11645 r11660  
    2121 *
    2222 *   Author:
    23  *      Florian Zinggeler
     23 *      Viviane Yang
    2424 *   Co-authors:
    2525 *      --
     
    4848#include "weapons/MuzzleFlash.h"
    4949
     50#include "Asteroids2D.h"
     51
    5052namespace orxonox
    5153{
     
    5557    {
    5658        RegisterObject(Asteroids2DWeapon);
     59
     60
    5761    }
    5862
     
    6165
    6266    }
     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
    6380
    6481    void Asteroids2DWeapon::shot()
     
    7592
    7693        this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
    77         projectile->setOrientation(this->getMuzzleOrientation());
     94
     95        //projectile->setOrientation(this->getGame()->getPlayer()->getOrientation());
    7896        projectile->setPosition(this->getMuzzlePosition());
    7997
     98
     99        //auf 2D Ebene druecken
    80100        Vector3 muzzle2D = this->getMuzzleDirection();
    81101        muzzle2D.y = 0;
  • code/branches/Asteroid_HS17/src/modules/asteroids2D/Asteroids2DWeapon.h

    r11645 r11660  
    4040#include "weapons/weaponmodes/HsW01.h"
    4141
     42#include "Asteroids2D.h"
     43
    4244namespace orxonox
    4345{
     
    4749            Asteroids2DWeapon(Context* context);
    4850            virtual ~Asteroids2DWeapon();
     51            Asteroids2D* getGame();
     52
     53
    4954        protected:
    5055            virtual void shot() override;
    5156            WeakPtr<Projectile> projectile;
     57            WeakPtr<Asteroids2D> game;
    5258    };
    5359}
Note: See TracChangeset for help on using the changeset viewer.