Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 12310


Ignore:
Timestamp:
Apr 18, 2019, 4:04:33 PM (6 years ago)
Author:
pomselj
Message:

oxw file cleaned up

Location:
code/branches/OrxoBlox_FS19
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw

    r12307 r12310  
    2424</Template>
    2525
    26 <Template name=OrxoBloxbat>
    27   <OrxoBloxBat camerapositiontemplate=OrxoBloxbatcameras>
    28     <attached>
    29       <Model position="60,0,-50" mesh="cube.mesh" scale3D="2,2,14" />
    30       <!--Model roll=180 mesh="OrxoBloxbat.mesh" scale=0.045 /-->
    31     </attached>
    32   </OrxoBloxBat>
    33 </Template>
    34 
    3526<Template name=OrxoBloxball>
    3627  <OrxoBloxBall
     
    5344
    5445
    55 <Template name=OrxoBloxStonescameras defaults=0>
    56   <OrxoBloxStones>
    57     <camerapositions>
    58       <CameraPosition position="55,75,200" absolute=true />
    59     </camerapositions>
    60   </OrxoBloxStones>
    61 </Template>
    62 
    63 <Template name=OrxoBloxstone>
    64   <OrxoBloxStones camerapositiontemplate=OrxoBloxStonescameras >
    65     <attached>
    66       <Model position="0,0,0" mesh="CuboidBody.mesh" scale=4.5 />
    67       <Model position="0,0,0" mesh="cube_orange.mesh" scale=4.3 />
    68     </attached>
    69   </OrxoBloxStones>
    70 </Template>
    71 
    72 <Template name=OrxoBloxWallcameras defaults=0>
    73   <OrxoBloxWall>
    74     <camerapositions>
    75       <CameraPosition position="55,75,200" absolute=true />
    76       <!--CameraPosition position="0,50,160" drag=true mouselook=true />
    77       <CameraPosition position="0,50,0" pitch=-90 drag=true mouselook=true /-->
    78     </camerapositions>
    79   </OrxoBloxWall>
    80 </Template>
    81 
    82 <Template name=OrxoBloxwall>
    83   <OrxoBloxWall camerapositiontemplate=OrxoBloxWallcameras>
    84   </OrxoBloxWall>
    85 </Template>
    86 
    87 
    8846
    8947<Level
     
    10462   skybox       = "Orxonox/skyBoxBasic"
    10563  >
    106     <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" />
     64    <!-- <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"/> -->
     65    <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" />
     66    <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass= Asteroids2DShip />
    10767
    108     <SpawnPoint position="991.729, -110.11, 435.404" orientation="0.534038, 0.563456, 0.212168, 0.593553" />
     68    <!--<Model mesh="axes.mesh" scale=10 position="0,0,0" /> -->
     69
    10970
    11071    <MovableEntity rotationrate=5 rotationaxis="0,0,1">
    11172      <attached>
    112         <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25 StoneTemplate=OrxoBloxstone WallTemplate=OrxoBloxwall>
     73        <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball ballspeed=200 ballaccfactor=1.0>
    11374          <attached>
    11475            <!-- Balken die das Spielfeld begrenzen. -->
     
    11677            <Model position="60,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
    11778            <Model position="-60,0,0" mesh="cube.mesh" scale3D="1,1,50"/>
    118 
    119             <ParticleSpawner name=scoreeffect_right position="120,0, 45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    120             <ParticleSpawner name=scoreeffect_right position="120,0, 30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
    121             <ParticleSpawner name=scoreeffect_right position="120,0, 15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    122             <ParticleSpawner name=scoreeffect_right position="120,0,  0" source="Orxonox/BigExplosion1part2" lifetime=0.1 autostart=0 />
    123             <ParticleSpawner name=scoreeffect_right position="120,0,-15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    124             <ParticleSpawner name=scoreeffect_right position="120,0,-30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
    125             <ParticleSpawner name=scoreeffect_right position="120,0,-45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    126 
    127             <ParticleSpawner name=scoreeffect_left position="-120,0, 45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    128             <ParticleSpawner name=scoreeffect_left position="-120,0, 30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
    129             <ParticleSpawner name=scoreeffect_left position="-120,0, 15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    130             <ParticleSpawner name=scoreeffect_left position="-120,0,  0" source="Orxonox/BigExplosion1part2" lifetime=0.1 autostart=0 />
    131             <ParticleSpawner name=scoreeffect_left position="-120,0,-15" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    132             <ParticleSpawner name=scoreeffect_left position="-120,0,-30" source="Orxonox/BigExplosion1part2" lifetime=3.0 autostart=0 />
    133             <ParticleSpawner name=scoreeffect_left position="-120,0,-45" source="Orxonox/sparks2" lifetime=0.1 autostart=0 />
    134 
    135 <!-- TODO: Create a OrxoBlox Score Sound and include it here.
    136 This WorldSound works, but doesn't make sense, since it is played together with ambient/moodDependedDirectory/Ganymede.ogg -->
    137             <!--WorldSound name="scoreSound" position="0,0,0" source="sounds/OrxoBloxScore_cut.ogg" >
    138               <events>
    139                 <play>
    140                   <EventListener event=OrxoBloxcenter />
    141                 </play>
    142               </events>
    143             </WorldSound-->
    144 
    145             <?lua
    146               for i = 1, 15, 1 do
    147             ?>
    148               <ParticleSpawner name=scoreeffect_center position="<?lua print(math.random() * 200 - 100) ?>,0,<?lua print(math.random() * 120 - 60) ?>" source="Orxonox/sparks2" lifetime=0.02 autostart=0 startdelay=<?lua print(math.random() * 0.7) ?> />
    149             <?lua end ?>
    150 
    15179          </attached>
    15280        </OrxoBloxCenterpoint>
    15381      </attached>
    154     </MovableEntity>
    155 
    156     <EventDispatcher>
    157       <targets>
    158         <EventTarget target=scoreeffect_right />
    159         <EventTarget target=scoreeffect_center />
    160       </targets>
    161       <events>
    162         <spawn>
    163           <EventFilter>
    164             <names>
    165               <EventName name=right />
    166             </names>
    167             <EventListener event=OrxoBloxcenter />
    168           </EventFilter>
    169         </spawn>
    170       </events>
    171     </EventDispatcher>
    172     <EventDispatcher>
    173       <targets>
    174         <EventTarget target=scoreeffect_left />
    175         <EventTarget target=scoreeffect_center />
    176       </targets>
    177       <events>
    178         <spawn>
    179           <EventFilter>
    180             <names>
    181               <EventName name=left />
    182             </names>
    183             <EventListener event=OrxoBloxcenter />
    184           </EventFilter>
    185         </spawn>
    186       </events>
    187     </EventDispatcher>
    188 
    189     <?lua
    190       dofile("includes/CuboidSpaceStation.lua")
    191     ?>
    192 
    193     <StaticEntity pitch=15>
    194       <attached>
    195         <MovableEntity rotationrate="-4.15786" rotationaxis="0,0,1">
    196           <attached>
    197             <StaticEntity position="-2500,0,0" yaw=90 pitch=90>
    198               <attached>
    199                 <?lua
    200                   createSpaceStationPar(0,2,1,2,1,4,1,50)
    201                 ?>
    202               </attached>
    203             </StaticEntity>
    204           </attached>
    205         </MovableEntity>
    206       </attached>
    207     </StaticEntity>
    208 
    209     <StaticEntity position="0,1200,-200" yaw=50 pitch=60 roll=45>
    210       <attached>
    211         <Model scale=10 mesh="Carrier.mesh" />
    212         <Model position="0,30,20" scale=10 mesh="pirate.mesh" roll="180" />
    213         <Model position="-80,-30,20" scale=10 mesh="pirate.mesh" roll="180" />
    214       </attached>
    215     </StaticEntity>
    216 
    217     <StaticEntity pitch=70>
    218       <attached>
    219         <MovableEntity rotationaxis="0,0,1" rotationrate=8.5974>
    220           <attached>
    221             <StaticEntity yaw=-90 pitch=0 roll=90 position="800,0,0">
    222               <attached>
    223                 <Model position="0,0,0" scale=10 mesh="satellite.mesh" />
    224                 <MovableEntity position="-4,0,20" velocity="0,0,0" rotationaxis="0,0,1" rotationrate=50>
    225                   <attached>
    226                     <Model position="0,0,0" scale=10 mesh="satellitedish.mesh"/>
    227                   </attached>
    228                 </MovableEntity>
    229                 <ParticleEmitter pitch=-135 roll=30 position="-14, 3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
    230                 <ParticleEmitter pitch=135 roll=30 position="-14, 3.5,-9" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
    231                 <ParticleEmitter pitch=-45 roll=30 position="-14,-3.5,-2.5" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
    232                 <ParticleEmitter pitch=45 roll=30 position="-14,-3.5,-9" source="Orxonox/thruster3" lifetime=2.0 loop=1 startdelay=3.0 />
    233               </attached>
    234             </StaticEntity>
    235           </attached>
    236         </MovableEntity>
    237       </attached>
    238     </StaticEntity>
    239 
    240     <?lua
    241       for i = 1, 10, 1 do
    242     ?>
    243       <MovableEntity position="<?lua print(math.random() * 600 - 300)?>, <?lua print(math.random() * 600 - 300) ?>, <?lua print(math.random() * 100 + 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    244         <attached>
    245           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    246         </attached>
    247       </MovableEntity>
    248       <MovableEntity position="<?lua print(math.random() * 600 - 300)?>, <?lua print(math.random() * 600 - 300) ?>, <?lua print(math.random() * -100 - 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    249         <attached>
    250           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    251         </attached>
    252       </MovableEntity>
    253 
    254       <MovableEntity position="<?lua print(math.random() * 600 - 300)?>, <?lua print(math.random() * 100 + 300) ?>, <?lua print(math.random() * 600 - 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    255         <attached>
    256           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    257         </attached>
    258       </MovableEntity>
    259       <MovableEntity position="<?lua print(math.random() * 600 - 300)?>, <?lua print(math.random() * -100 - 300) ?>, <?lua print(math.random() * 600 - 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    260         <attached>
    261           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    262         </attached>
    263       </MovableEntity>
    264 
    265       <MovableEntity position="<?lua print(math.random() * 100 + 300)?>, <?lua print(math.random() * 600 - 300) ?>, <?lua print(math.random() * 600 - 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    266         <attached>
    267           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    268         </attached>
    269       </MovableEntity>
    270       <MovableEntity position="<?lua print(math.random() * -100 - 300)?>, <?lua print(math.random() * 600 - 300) ?>, <?lua print(math.random() * 600 - 300) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    271         <attached>
    272           <Model scale="<?lua print(math.random() * 10 + 5) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false />
    273         </attached>
    274       </MovableEntity>
    275     <?lua end ?>
    276    
     82    </MovableEntity>   
    27783  </Scene>
    27884</Level>
  • code/branches/OrxoBlox_FS19/data/levels/towerDefense.oxw

    r12281 r12310  
    106106        </links>
    107107        <Weapon>         
    108           <BallGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=200 shielddamage=4 />
     108          <BallGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=0 shielddamage=4 />
    109109        </Weapon>
    110110      </WeaponPack>
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12308 r12310  
    4949#include "OrxoBloxCenterpoint.h"
    5050#include "OrxoBloxBall.h"
    51 // #include "OrxoBloxBat.h"//Remove??
    5251#include "OrxoBloxBot.h"//Remove??
    5352#include "OrxoBloxStones.h"
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12308 r12310  
    3333
    3434#include "OrxoBloxBall.h"
     35#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    3536
    3637#include "core/CoreIncludes.h"
     
    260261        return BLANKSTRING;
    261262    }
     263
     264
     265    void OrxoBloxBall::Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) {
     266
     267        Vector3 velocity = this->getVelocity();
     268        Vector3 myPosition = otherObject->getPosition();
     269        btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
     270        orxout() << "About to Bounce >D" << endl;
     271        //if (positionOtherObject.y < 0) {
     272            //this.destroy()
     273        //}S
     274        //else {
     275       
     276            int distance_X = positionOtherObject.getX() - myPosition.x;
     277            int distance_Z = positionOtherObject.getZ() - myPosition.z;
     278
     279            if (distance_X < 0)
     280                distance_X = -distance_X;
     281   
     282
     283            if (distance_Z < 0)
     284                distance_Z = -distance_Z;
     285
     286            orxout() << distance_X << endl;
     287            orxout() << distance_Z << endl;
     288
     289            if (distance_X < distance_Z) {
     290                velocity.z = -velocity.z;
     291                orxout() << "z" << endl;
     292            }
     293            if (distance_Z < distance_X) {
     294                velocity.x = -velocity.x;
     295                orxout() << "x" << endl;
     296            }
     297            else {
     298                velocity.x = -velocity.x;
     299                velocity.z = -velocity.z;
     300                orxout() << "both" << endl;
     301            }
     302            this->setVelocity(velocity);
     303        //}
     304    }
     305
     306
     307    bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     308    {
     309        orxout() << "About to Bounce >D" << endl;
     310        bool result = MovableEntity::collidesAgainst(otherObject, ownCollisionShape, contactPoint);
     311        Bounce(otherObject, ownCollisionShape, contactPoint);
     312        return result;
     313    }
     314
     315
    262316}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h

    r12308 r12310  
    4141
    4242#include "worldentities/MovableEntity.h"
     43#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
    4344
    4445
     
    132133            void setDefBoundarySound(const std::string& engineSound);
    133134            const std::string& getDefBoundarySound();
     135            void Bounce(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint);
     136            virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    134137
    135138        private:
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc

    r12291 r12310  
    4040#include "core/command/Executor.h"
    4141#include "util/Convert.h"
     42#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
     43#include <bullet/LinearMath/btVector3.h>
    4244
    4345namespace orxonox
     
    5860    void BallProjectile::registerVariables()
    5961    {
     62        registerVariable( this->fieldWidth_ );
     63        registerVariable( this->fieldHeight_ );
    6064        registerVariable(this->materialBase_);
     65        registerVariable( this->speed_ );
    6166    }
    6267
     
    8792    }
    8893
     94
     95
    8996    void BallProjectile::Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) {
    9097
    9198        Vector3 velocity = this->getVelocity();
    92         Vector3 positionOtherObject = otherObject->getPosition();
    93         Vector3 contactPosition = this->getPosition();
     99        Vector3 myPosition = otherObject->getPosition();
     100        btVector3 positionOtherObject = contactPoint.getPositionWorldOnA();
    94101        orxout() << "About to Bounce >D" << endl;
    95102        //if (positionOtherObject.y < 0) {
     
    98105        //else {
    99106       
    100             int distance_X = positionOtherObject.x - contactPosition.x;
    101             int distance_Y = positionOtherObject.y - contactPosition.y;
     107            int distance_X = positionOtherObject.getX() - myPosition.x;
     108            int distance_Z = positionOtherObject.getZ() - myPosition.z;
    102109
    103110            if (distance_X < 0)
    104                 distance_Y = -distance_Y;
     111                distance_X = -distance_X;
    105112   
    106113
    107             if (distance_Y < 0)
    108                 distance_X = -distance_X;
    109 
    110             if (distance_X < distance_Y)
    111                 velocity.y = -velocity.y;
    112             if (distance_Y < distance_X)
     114            if (distance_Z < 0)
     115                distance_Z = -distance_Z;
     116
     117            orxout() << distance_X << endl;
     118            orxout() << distance_Z << endl;
     119
     120            if (distance_X < distance_Z) {
     121                velocity.z = -velocity.z;
     122                orxout() << "z" << endl;
     123            }
     124            if (distance_Z < distance_X) {
    113125                velocity.x = -velocity.x;
     126                orxout() << "x" << endl;
     127            }
    114128            else {
    115129                velocity.x = -velocity.x;
    116                 velocity.y = -velocity.y;
     130                velocity.z = -velocity.z;
     131                orxout() << "both" << endl;
    117132            }
     133            this->setVelocity(velocity);
    118134        //}
    119135    }
    120136
    121 /**
    122     @brief
    123         The function called when a projectile hits another thing.
    124         Calls the hit-function, starts the shield recharge countdown, displays visual hit effects defined in Pawn.
    125         Needs to be called in the collidesAgainst() function by every Class directly inheriting from BasicProjectile.
    126     @param otherObject
    127         A pointer to the object the Projectile has collided against.
    128     @param contactPoint
    129         A btManifoldPoint indicating the point of contact/impact.
    130     @param cs
    131         The btCollisionShape of the other object
    132     @return
    133         Returns true if the collision resulted in a successful hit.
    134     @see Pawn.h
    135     */
     137
     138
     139
    136140   
    137141    bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
     
    145149        return result;
    146150    }
     151
     152
     153
     154
     155
     156
     157    void BallProjectile::tick(float dt)
     158    {
     159        SUPER(BallProjectile, tick, dt);
     160
     161        // Get the current position, velocity and acceleration of the ball.
     162        Vector3 position = this->getPosition();
     163        Vector3 velocity = this->getVelocity();
     164        Vector3 acceleration = this->getAcceleration();
     165
     166        // If the ball has gone over the top or bottom boundary of the playing field (i.e. the ball has hit the top or bottom delimiters).
     167        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     168        {
     169            // Its velocity in z-direction is inverted (i.e. it bounces off).
     170            velocity.z = -velocity.z;
     171            // And its position is set as to not overstep the boundary it has just crossed.
     172            if (position.z > this->fieldHeight_ / 2)
     173                position.z = this->fieldHeight_ / 2;
     174            if (position.z < -this->fieldHeight_ / 2)
     175                position.z = -this->fieldHeight_ / 2;
     176
     177            this->fireEvent();
     178        }
     179       
     180        //Ball hits the right or left wall and should bounce back.
     181        // If the ball has crossed the left or right boundary of the playing field.
     182        if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     183        {
     184            //Ball hits the right Wall
     185            if (position.x > this->fieldWidth_ / 2)
     186                {
     187                    // Set the ball to be exactly at the boundary.
     188                    position.x = this->fieldWidth_ / 2;
     189                    // Invert its velocity in x-direction (i.e. it bounces off).
     190                    velocity.x = -velocity.x;
     191                    this->fireEvent();
     192                    }
     193
     194            //Ball hits the left wall
     195            else if (position.x < -this->fieldWidth_ / 2)
     196                {
     197                        // Set the ball to be exactly at the boundary.
     198                        position.x = -this->fieldWidth_ / 2;
     199                        // Invert its velocity in x-direction (i.e. it bounces off).
     200                        velocity.x = -velocity.x;
     201                        this->fireEvent();
     202                    }
     203        }
     204
     205        // Set the position, velocity and acceleration of the ball, if they have changed.
     206        if (acceleration != this->getAcceleration())
     207            this->setAcceleration(acceleration);
     208        if (velocity != this->getVelocity())
     209            this->setVelocity(velocity);
     210        if (position != this->getPosition())
     211            this->setPosition(position);
     212    }
     213
     214
     215
     216
     217    void BallProjectile::setSpeed(float speed)
     218    {
     219        if (speed != this->speed_) // If the speed changes
     220        {
     221            this->speed_ = speed;
     222
     223            // Set the speed in the direction of the balls current velocity.
     224            Vector3 velocity = this->getVelocity();
     225            if (velocity.x != 0)
     226                velocity.x = sgn(velocity.x) * this->speed_;
     227            else // If the balls current velocity is zero, the speed is set in a random direction.
     228                velocity.x = this->speed_ * sgn(rnd(-1,1));
     229
     230            this->setVelocity(velocity);
     231        }
     232    }
     233
     234
    147235}
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h

    r12281 r12310  
    5454            void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
    5555            virtual void setMaterial(const std::string& material) override;
     56            virtual void tick(float dt) override;
     57            void setSpeed(float speed);
     58
    5659
    5760        protected:
     
    6366            void changeTexture();
    6467           
     68            float speed_; //!< The speed (in x-direction) of the ball.
     69            float fieldWidth_; //!< The width of the playing field.
     70            float fieldHeight_; //!< The height of the playing field.
    6571            unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
    6672            unsigned int maxTextureIndex_; //!< The maximal index.
Note: See TracChangeset for help on using the changeset viewer.