Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11412


Ignore:
Timestamp:
May 4, 2017, 3:17:59 PM (7 years ago)
Author:
jkindle
Message:

Fixed turning, added and finished Gumbas, added turnOnCollide for all NPC and items, added Flagstone - todo: add points on flagstone hit and go into a between lvl mode, then warp to lvl 2. AAH, and added onDeath fcts…

Location:
code/branches/SuperOrxoBros_FS17
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw

    r11411 r11412  
    118118
    119119
     120                                        <SOBGumba collisionType="dynamic" speed=30>
     121                                                <attached>
     122                                                        <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>
     123                                                       
     124                                                </attached>
     125                                                <collisionShapes>
     126                                                        <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" />                                             <!-- ?????? -->
     127                                                </collisionShapes>
     128                                        </SOBGumba>
     129
     130                                       
     131
     132
     133
    120134                                        <Model mesh="Cube2.12.mesh" position="0,0,-30" scale=10 Pitch=90/>                                      <!-- B1.1 -->
    121135                                        <Model mesh="Cube2.12.mesh" position="120,0,-30" scale=10 Pitch=90/>                            <!-- B1.2-->
     
    127141
    128142
    129                                         <StaticEntity collisionType="static">
     143                                        <StaticEntity collisionType="static" mass='-1'>
    130144                                                <collisionShapes>
    131145                                                        <BoxCollisionShape position="340,0,-20" halfExtents="345,5,5" />
     
    139153                                        <!--                                    BLOCK 1 in der LUFT - alle analog wie diesen :) -->
    140154                                        <!-- Sobald ein QBlock von unten gehittet wird, wechselt die Visibility von allen attached Models. Hier wuerde also Cube1.1 invisible und Cube2.12 visible. Die Collisionshape wird ja sowieso beibehalten. -->
    141                                         <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20">                                                                  <!-- L1.1 -->
     155                                        <SOBQBlock collisionType="static" type="Mushroom" position="170,0,20" mass=-1>                                                                  <!-- L1.1 -->
    142156                                                <attached>
    143157                                                        <Model mesh="QCube.mesh" scale=10 pitch=90 />
     
    205219                                       
    206220
    207 
    208 
    209 
    210                                         <SOBMushroom collisionType="dynamic" speed=30>
    211                                                 <attached>
    212                                                         <Model mesh="Goomba.mesh" position="0,0,21" scale=3 pitch=90/>
    213                                                        
    214                                                 </attached>
    215                                                 <collisionShapes>
    216                                                         <BoxCollisionShape position="0,0,20" halfExtents="5,5,3" />                                             <!-- ?????? -->
    217                                                 </collisionShapes>
    218                                         </SOBMushroom>
    219 
    220                                         <SOBMushroom collisionType="dynamic" speed=30>
    221                                                 <attached>
    222                                                         <Model mesh="Alien.mesh" position="30,0,21" scale=3 pitch=90/>
    223                                                        
    224                                                 </attached>
    225                                                 <collisionShapes>
    226                                                         <BoxCollisionShape position="30,0,20" halfExtents="5,5,3" />                                            <!-- ?????? -->
    227                                                 </collisionShapes>
    228                                         </SOBMushroom>
    229221
    230222
  • code/branches/SuperOrxoBros_FS17/data/overlays/SOBHUD.oxo

    r11405 r11412  
    4848     textsize  = 0.04
    4949     colour    = "1.0, 1.0, 1.0, 1.0"
    50      align     = "middle"
    51      caption   = "WORLD\n 1-1"
     50     align     = "center"
     51     caption   = "WORLD\n1-1"
    5252    />
    5353
     
    7979   
    8080
     81    <SOBHUDInfo
     82     position = "0.5,0.5"
     83     pickpoint = "0.5, 0.5"
     84     textposition  = "0.5, 0.5"
     85     textpickpoint = "0.5, 0.5"
     86     font      = "ShareTechMono"
     87     textsize  = 0.07
     88     colour    = "1.0, 1.0, 1.0, 1.0"
     89     align     = "center"
     90     type      = "Info"
     91     
     92    />
    8193   
    8294
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/CMakeLists.txt

    r11405 r11412  
    88  SOBMushroom.cc
    99  SOBHUDInfo.cc
     10  SOBGumba.cc
     11  SOBFlagstone.cc
    1012
    1113)
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc

    r11405 r11412  
    3838#include "core/command/Executor.h"
    3939#include "core/config/ConfigValueIncludes.h"
     40#include "core/Game.h"
    4041
    4142#include "gamestates/GSLevel.h"
     
    6869        points_=0;
    6970        timeLeft_=400.0;
     71       
     72        lvl_ = 1;
    7073
    7174    }
     
    8689    }
    8790
    88         void SOB::start()
     91    void SOB::start()
    8992    {
    9093        if (center_ != nullptr) // There needs to be a SOBCenterpoint, i.e. the area the game takes place.
     
    125128    }
    126129
     130    void SOB::restart() {
     131        cleanup();
     132
     133        // HACK
     134        Game::getInstance().popState();
     135        Game::getInstance().popState();
     136        Game::getInstance().requestStates("standalone, level");
     137
     138       
     139    }
    127140    void SOB::spawnPlayer(PlayerInfo* player)
    128141    {
     
    148161    }
    149162
    150 void SOB::tick(float dt)
     163    void SOB::tick(float dt)
    151164    {
    152165        SUPER(SOB, tick, dt);
    153166
    154         if (this->figure_ != nullptr && figure_->dead_)
     167        if (this->figure_ != nullptr && figure_->dead_) {
     168            info_ = "Game over. Press <Space> to restart";
    155169            orxout() << "DEED" << endl;
    156        
     170        }
     171       
    157172
    158        timeLeft_-=dt*2.5;
     173        timeLeft_-=dt*2.5;
    159174    }
    160175
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h

    r11405 r11412  
    6262            PlayerInfo* getPlayer() const;
    6363
     64            void restart();
    6465            int getPoints() {
    6566                return points_;
     
    7576                points_+=1000;
    7677            }
     78            void addGumba() {
     79                points_+=100;
     80            }
    7781            int getTimeLeft() {
    7882                return timeLeft_;
    7983            }
     84            std::string getInfoText() {
     85                return info_;
     86            }
    8087           
    81 
    82            virtual void playerEntered(PlayerInfo* player) override
     88            void setLvl(int lvl) {
     89                lvl_ = lvl;
     90            }
     91            int getLvl() {
     92                return lvl_;
     93            }
     94            virtual void playerEntered(PlayerInfo* player) override
    8395            {
    8496                Gametype::playerEntered(player);
     
    97109            int coins_;
    98110            float timeLeft_;
     111       
     112            int lvl_;
     113            std::string info_;
    99114
    100115
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc

    r11405 r11412  
    4141
    4242#include "SOBMushroom.h"
     43#include "SOBGumba.h"
    4344#include "SOB.h"
     45#include "SOBFlagstone.h"
    4446
    4547namespace orxonox
     
    6668        pitch_ = 0.0;
    6769
     70        predead_ = false;
    6871        dead_ = false;
    6972        gotPowerUp_ = false;
     
    7982        isColliding_ = true;
    8083        SOBMushroom* mush = orxonox_cast<SOBMushroom*>(otherObject);
    81         // ADD ANOTHER OBJECT FOR BAD GUMBAS AND REMOVE POWERUP OR KILL PLAYER ON COLLISION WITHOUT Z-ACCELERATION
     84        SOBGumba* gumba = orxonox_cast<SOBGumba*>(otherObject);
     85        SOBFlagstone* flagstone = orxonox_cast<SOBFlagstone*>(otherObject);
     86
    8287        if (mush != nullptr && !(mush->hasCollided_)) {
    8388            otherObject->destroyLater();
     
    8792            mush->hasCollided_ = true;
    8893
    89         }
    90 
    91         return true;
    92     }
    93 
    94 
    95 
    96     void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    97     {
    98         SUPER(SOBFigure, XMLPort, xmlelement, mode);
    99 
    100     }
    101 
    102 
    103 
    104     void SOBFigure::tick(float dt)
    105     {
    106         SUPER(SOBFigure, tick, dt);
    107 
    108         if (particlespawner_ == NULL) {
    109             for (WorldEntity* object : this->getAttachedObjects())
    110             {
    111                if (object->isA(Class(ParticleSpawner)))
    112                 particlespawner_ = object;
    113 
    114         }
    115 
    116     }
    117 
    118 
    119 
    120 
    121 
    122 
    123     if (firePressed_ == false) {
    124        gravityAcceleration_ = 350.0;
    125 
    126    }
    127 
    128    if (hasLocalController())
    129    {
    130       Vector3 velocity = getVelocity();
    131       Vector3 position = getPosition();
    132 
    133 
    134       if (position.z < -100)
    135         dead_ = true;
    136 
    137     if (dead_) {
    138         velocity.x = 0;
    139         velocity.z = 0;
    140         setVelocity(velocity);
    141         return;
    142     }
    143 
    144 
    145     int maxvelocity_x = 100;
    146     int speedAddedPerTick = 5;
    147     int camMaxOffset = 25;
    148 
    149     timeSinceLastFire_ += dt;
    150     lastSpeed_z = velocity.z;
     94        } else if (gumba != nullptr && !(gumba->hasCollided_)) {
     95
     96            if (getVelocity().z >= -20) {
     97              Vector3 vel = getVelocity();
     98              vel.y = -80;
     99              vel.z = 200;
     100              setVelocity(vel);
     101              predead_=true;
     102          } else {
     103            gumba->destroyLater();
     104            gumba->hasCollided_ = true;
     105            SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     106            SOBGame->addGumba();
     107
     108
     109        }
     110    }
     111
     112     if (flagstone != nullptr && !(flagstone->hasCollided_)) {
     113            flagstone->hasCollided_ = true;
     114
     115     }
     116
     117    return true;
     118}
     119
     120
     121
     122void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     123{
     124    SUPER(SOBFigure, XMLPort, xmlelement, mode);
     125
     126}
     127
     128
     129int SOBFigure::sgn(float x) {
     130
     131    if (x < 0.0) return -1;
     132    return 1;
     133}
     134
     135void SOBFigure::tick(float dt)
     136{
     137    SUPER(SOBFigure, tick, dt);
     138
     139    if (particlespawner_ == NULL) {
     140        for (WorldEntity* object : this->getAttachedObjects())
     141        {
     142         if (object->isA(Class(ParticleSpawner)))
     143            particlespawner_ = object;
     144
     145    }
     146
     147}
     148
     149
     150
     151
     152
     153
     154if (firePressed_ == false) {
     155 gravityAcceleration_ = 350.0;
     156
     157}
     158
     159if (hasLocalController())
     160{
     161  Vector3 velocity = getVelocity();
     162  Vector3 position = getPosition();
     163
     164  if (!predead_)
     165    velocity.y = 0;
     166if (position.z < -100) {
     167    dead_ = true;
     168
     169}
     170
     171if (dead_) {
     172    velocity.x = 0;
     173    velocity.z = 0;
     174    setVelocity(velocity);
     175    SOB* SOBGame = orxonox_cast<SOB*>(getGametype());
     176    if (firePressed_)
     177        SOBGame->restart();
     178    return;
     179}
     180
     181
     182int maxvelocity_x = 100;
     183int speedAddedPerTick = 5;
     184int camMaxOffset = 25;
     185
     186timeSinceLastFire_ += dt;
     187lastSpeed_z = velocity.z;
    151188
    152189
    153190
    154191        //Handle the rocket fire from the jetpack
    155     if (velocity.z > 40)
    156         particlespawner_->setVisible(true);
    157     else
    158         particlespawner_->setVisible(false);
     192if (velocity.z > 40)
     193    particlespawner_->setVisible(true);
     194else
     195    particlespawner_->setVisible(false);
    159196
    160197        //If player hits space and does not move in z-dir
    161     if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
    162         gravityAcceleration_ = 100.0;
     198if (firePressed_ && isColliding_ && std::abs(velocity.z) < 0.1 && std::abs(lastSpeed_z) < 0.1) {
     199    gravityAcceleration_ = 100.0;
    163200            velocity.z = 110; //150
    164201        }
     
    169206        //Left-right movement with acceleration
    170207        float rot = getOrientation().getRoll().valueDegrees();
     208        orxout() << rot << endl;
    171209        if (moveRightPressed_) {
    172             if (rot < 0.0)
    173                 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     210            if (!(rot < 5.0 && -5.0 < rot))
     211                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() - sgn(rot)*dt*Radian(6));
     212
    174213
    175214            if (std::abs(velocity.x) < maxvelocity_x) {
    176215                velocity.x += speedAddedPerTick;
    177216
    178                
    179 
    180                
    181 
    182                 // if (pitch_ > 0.0) {
    183                 //     pitch -= turn_fac*dt);
    184                 // }
    185217            }
    186218        } else if (moveLeftPressed_) {
    187             if (rot >= 0.0)
    188                 setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + dt*Radian(6));
     219            if (!(abs(rot) > 175.0 ))
     220                setOrientation(Vector3::UNIT_Z, getOrientation().getRoll() + sgn(rot)*dt*Radian(6));
     221
     222
    189223
    190224            if (std::abs(velocity.x) < maxvelocity_x) {
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h

    r11405 r11412  
    3838    class _SOBExport SOBFigure : public ControllableEntity
    3939    {
    40         public:
     40    public:
    4141            SOBFigure(Context* context); //!< Constructor. Registers and initializes the object.
    4242            virtual ~SOBFigure() {}
     
    4646            virtual void moveRightLeft(const Vector2& value) override; //!< Overloaded the function to steer the figure up and down.
    4747           
    48          
     48
    4949            virtual void boost(bool boost) override;
    5050            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    5151
    52        
     52
    5353            //virtual void CollisionWithEnemy(SOBEnemy* enemy);
    5454           
    5555           
    56    
    57          
     56
     57
    5858            bool dead_;
     59            bool predead_;
    5960
    60          
    6161        private:
    62            
     62
    6363            bool gotPowerUp_;
    6464            bool moveUpPressed_;
     
    7474            bool isColliding_;
    7575            WorldEntity* particlespawner_;
     76            int sgn(float x);
    7677
    77            
     78
     79
    7880           
    79            
    80     };
    81 }
     81
     82        };
     83    }
    8284
    8385#endif /* _SOBFigure_H__ */
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBHUDInfo.cc

    r11405 r11412  
    6666          if (this->type_ == "Coins") {
    6767                // this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
    68                    
    69                    
     68           
     69           
    7070            std::stringstream ss;
    7171            ss << "cc x " << std::setw(2) << std::setfill('0') << SOBGame->getCoins();
     
    7474            this->setCaption(s);
    7575           
    76           }
    77            if (this->type_ == "Points") {
     76        }
     77        if (this->type_ == "Points") {
    7878            std::stringstream ss;
    7979            ss << std::setw(6) << std::setfill('0') << SOBGame->getPoints();
    8080            std::string s = ss.str();
    8181            this->setCaption(s);
    82           }
    83           if (this->type_ == "Time") {
     82        }
     83        if (this->type_ == "Time") {
    8484            std::stringstream ss;
    8585            ss << SOBGame->getTimeLeft();
    8686            std::string s = ss.str();
    8787            this->setCaption(s);
    88           }
    89                
     88        }
     89        if (this->type_ == "Info") {
     90            std::stringstream ss;
     91            ss << SOBGame->getInfoText();
     92            std::string s = ss.str();
     93            this->setCaption(s);
     94        }
     95       
    9096
    91 
    92             //     const std::string& Level = multi_cast<std::string>(this->SOBGame->getLevel());
    93             //     if (this->SOBGame->lives <= 0)
    94             //     {
    95             //         setPosition(Vector2(0.1, 0.65));
    96             //         this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!");
    97             //         setTextSize(0.05);
    98             //         this->SOBGame->bEndGame = true;
    99             //     }
    100             //     else if (this->SOBGame->bShowLevel)
    101             //     {
    102             //         setTextSize(0.1);
    103             //         setPosition(Vector2(0.3, 0.55));
    104             //         std::stringstream sstm;
    105             //         sstm << "Level " << Level;
    106             //         this->setCaption(sstm.str()); // + level
    107             //     }
    108             //     else
    109             //     {
    110             //         setTextSize(0.04);
    111             //         setPosition(Vector2(0.14, 0.055));
    112             //         this->setCaption(Level);
    113             //     }
    114             // ////////////
    115             //     const std::string& points = multi_cast<std::string>(this->SOBGame->getPoints());
    116             //     if (this->SOBGame->lives <= 0)
    117             //     {
    118             //         setTextSize(0.2);
    119             //         setPosition(Vector2(0.1, 0.25));
    120             //         this->setCaption("Final score:\n" + points);
    121             //         this->setColour(ColourValue(1, 0, 0, 1));
    122             //     }
    123             //     else
    124             //     {
    125             //         setTextSize(0.04);
    126             //         setPosition(Vector2(0.14, 0.1));
    127             //         this->setColour(ColourValue(1, 1, 1, 1));
    128             //         this->setCaption(points);
    129             //     }
    130            
    131             // /////////////
    132             //     int mult = this->SOBGame->getMultiplier();
    133             //     const std::string& Multiplier = "X " + multi_cast<std::string>(mult);
    134             //     this->setCaption(Multiplier);
    135             //     this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f)));
    136             //     this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f);
    137            
    138         }
    139     }
    140 
    141     void SOBHUDInfo::changedOwner()
    142     {
    143         SUPER(SOBHUDInfo, changedOwner);
    144 
    145         if (this->getOwner() && this->getOwner()->getGametype())
    146         {
    147             this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype());
    148         }
    149         else
    150         {
    151             this->SOBGame = nullptr;
    152         }
     97       
    15398    }
    15499}
     100
     101void SOBHUDInfo::changedOwner()
     102{
     103    SUPER(SOBHUDInfo, changedOwner);
     104
     105    if (this->getOwner() && this->getOwner()->getGametype())
     106    {
     107        this->SOBGame = orxonox_cast<SOB*>(this->getOwner()->getGametype());
     108    }
     109    else
     110    {
     111        this->SOBGame = nullptr;
     112    }
     113}
     114}
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.cc

    r11405 r11412  
    5555        speed_ = 0.0;
    5656        hasCollided_=false;
     57        goesRight_ = true;
     58        lastPos_ = getPosition();
     59        lastPos_.x -= 20;
     60        changeAllowed_ = true;
     61        changedOn_ = 0.0;
    5762       
    5863    }
     
    7176    bool SOBMushroom::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
    7277
    73 //orxout() << "Watshc bum baem" << endl;
     78
     79if (changeAllowed_ && otherObject->getMass() != -1) {
     80                goesRight_ = !goesRight_;
     81                changeAllowed_ = false;
     82}
     83
     84orxout() << "Watshc bum baem" << otherObject->getMass()<< endl;
    7485return true;
    7586    }
     
    90101        SUPER(SOBMushroom, tick, dt);
    91102
    92           Vector3 velocity = getVelocity();
     103        if (!changeAllowed_) {
     104            changedOn_+= dt;
     105            if (changedOn_> 200) {
     106                changeAllowed_ = true;
     107                changedOn_ = 0.0;
     108
     109        }
     110    }
     111       
     112
     113        int dir = 1;
     114        if (!goesRight_)
     115            dir = -1;
     116
     117        Vector3 velocity = getVelocity();
    93118        velocity.z -= gravityAcceleration_*dt;
    94         velocity.x = speed_;
     119        velocity.x = dir*speed_;
    95120        setVelocity(velocity);
    96121
    97122
    98123   
     124        lastPos_ = getPosition();
     125            }
     126
    99127
    100128}
    101 }
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBMushroom.h

    r11405 r11412  
    6565            float speed_;
    6666            WeakPtr<SOBFigure> figure_;
     67            bool goesRight_;
     68            Vector3 lastPos_;
     69            bool changeAllowed_;
     70            float changedOn_;
    6771           
    6872    };
  • code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBPrereqs.h

    r11405 r11412  
    8181    class SOBMushroom;
    8282    class SOBHUDInfo;
     83    class SOBGumba;
     84    class SOBFlagstone;
    8385    /*
    8486    class PongScore;*/
Note: See TracChangeset for help on using the changeset viewer.