Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11573


Ignore:
Timestamp:
Nov 20, 2017, 3:11:07 PM (6 years ago)
Author:
zarron
Message:

fireing Fireballs enabled

Location:
code/branches/SOBv2_HS17
Files:
5 edited

Legend:

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

    r11569 r11573  
    6464        </Template>
    6565
    66 
    67 
     66                                        <!--Test Fireball-->
     67
     68
     69        <Template name=fireball>
     70                <SOBFireball collisionType="dynamic" speed=80>
     71                        <attached>
     72                                <Model mesh="planets/sol.mesh" position="0,0,0" scale=3 pitch=90/>
     73                               
     74                        </attached>
     75                        <collisionShapes>
     76                                <SphereCollisionShape position="0,0,0" halfExtents="5,5,5" />                   
     77                        </collisionShapes>
     78                </SOBFireball>
     79        </Template>
    6880
    6981
     
    99111                        </MovableEntity>
    100112
    101                                         <!--Test Fireball-->
    102 
    103 
    104 
    105                                         <SOBFireball collisionType="dynamic" speed=80 position = "10,0,40">
    106                                                 <attached>
    107                                                         <Model mesh="planets/sol.mesh" position="0,0,0" scale=3 pitch=90/>
    108                                                        
    109                                                 </attached>
    110                                                 <collisionShapes>
    111                                                         <SphereCollisionShape position="0,0,0" halfExtents="5,5,5" />                   
    112                                                 </collisionShapes>
    113                                         </SOBFireball>
    114113
    115114
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.cc

    r11567 r11573  
    4545#include "SOBFlagstone.h"
    4646#include "SOBCastlestone.h"
     47#include "SOBFireball.h"
    4748#include <BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    4849
     
    8384        reachedLvlEndState_ = 0;
    8485
     86        //Properties of fireing Fireballs, NOTE! fireballs are fired with the moveUP Key, not with the fire key
     87        fireallowed_=true;
     88        firecooldown_=0;
     89
    8590       
    8691        setAngularFactor(0.0); //Means player doesn't turn on collision, so he doesn't fall over while walking over the ground
     
    110115            SOBGame->addMushroom(); // Tell the gametype to increase points
    111116            mush->hasCollided_ = true; // needed because of destroyLater takes some time and player should receive points only once
    112 
    113117
    114118            // now, change the clothes of the Figure to red
     
    180184}
    181185
     186//Function to spawn the Fireball
     187void SOBFigure::spawnFireball() {
     188        SOBCenterpoint* center_ = ((SOB*)getGametype())->center_;
     189
     190         SOBFireball* ball = new SOBFireball(center_->getContext());
     191         Vector3 spawnpos = this->getWorldPosition();
     192         spawnpos.z += 0;
     193
     194        if (ball != nullptr && center_ != nullptr)
     195        {
     196            ball->addTemplate("fireball");
     197            ball->setPosition(spawnpos);
     198           
     199        }
     200     }
     201
    182202//For those of you who don't have an idea: the tick function is called about 50 times/sec
    183203void SOBFigure::tick(float dt)
     
    295315        }
    296316
     317        //If moveUp pressed, fire a fireball
     318        if(moveUpPressed_ && gotPowerUp_ && fireallowed_)
     319        {
     320            spawnFireball();
     321            fireallowed_=false;
     322            firecooldown_=0;
     323        }
     324
     325        //Increase the firecooldown
     326        if(firecooldown_>0.5)
     327        {
     328            fireallowed_=true;
     329        }
     330        if(!fireallowed_)
     331        {
     332            firecooldown_+=dt;
     333        }
    297334
    298335        //Again another EndOfLevel behavior
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFigure.h

    r11538 r11573  
    4747            virtual  bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    4848            void changeClothes(std::string& name);
     49            void spawnFireball();
    4950
    5051            bool dead_;
     
    5556
    5657            //Soooo many declarations
     58            bool fireallowed_;
    5759            bool gotPowerUp_;
    5860            bool moveUpPressed_;
     
    6466            float timeSinceLastFire_;
    6567            float lastSpeed_z;
     68            float firecooldown_;
    6669            SOBCenterpoint* sobcenterpoint;
    6770            float pitch_;
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.cc

    r11569 r11573  
    6767        collDisX_ = 0;
    6868        collDisZ_ = 0;
    69         hitCounter_ = 0;
    7069
    7170      orxout() << "fireball existed" << endl;
     
    121120        }
    122121
    123         hitCounter_++;
    124 
    125122       
    126123        return true;
  • code/branches/SOBv2_HS17/src/modules/superorxobros/SOBFireball.h

    r11570 r11573  
    6464            bool hasCollided_;
    6565        protected:
    66             int hitCounter_; //counts how many times the floor was hit, ball gets deleted if has hit the floor 3 times
    6766            float gravityAcceleration_;
    6867            float speed_;
Note: See TracChangeset for help on using the changeset viewer.