Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2019, 1:13:58 PM (6 years ago)
Author:
pomselj
Message:

BallProjectiles fly

Location:
code/branches/OrxoBlox_FS19/src/modules/weapons
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc

    r12368 r12371  
    3434#include "BallProjectile.h"
    3535#include "../OrxoBlox/OrxoBlox.h"
     36#include "../OrxoBlox/OrxoBloxStones.h"
    3637#include "gametypes/Gametype.h"
    3738
     
    5758        this->maxTextureIndex_ = 8;
    5859        this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
     60        this->fieldWidth_ = 46;
     61        this->fieldHeight_ =  49;
    5962        //this->orxoblox_ = this->getOrxoBlox();
    6063
     
    6467    void BallProjectile::registerVariables()
    6568    {
    66         registerVariable( this->fieldWidth_ );
    67         registerVariable( this->fieldHeight_ );
    6869        registerVariable(this->materialBase_);
    6970        registerVariable( this->speed_ );
     
    145146        orxout() << "wanna bounce..." << endl;
    146147        bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs);
    147         Bounce(otherObject, contactPoint, cs);
     148        if (result == true) {
     149            if (otherObject->isA(Class(OrxoBloxStones))) {
     150                Bounce(otherObject, contactPoint, cs);
     151            }
     152        }
    148153        orxout() << "BOUNCED!" << endl;
    149154
     
    175180        Vector3 acceleration = this->getAcceleration();
    176181
     182        velocity.y = 0;
     183        position.y = 0;
     184
    177185        // 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).
    178         if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     186        if (position.z > this->fieldHeight_ || position.z < -this->fieldHeight_)
    179187        {
    180188
    181189            velocity.z = -velocity.z;
    182190            // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
    183             if (position.z > this->fieldHeight_ / 2){
     191            if (position.z > this->fieldHeight_){
    184192                // Set the ball to be exactly at the boundary.
    185                 position.z = this-> fieldHeight_ / 2;
     193                position.z = this-> fieldHeight_;
    186194               
    187195                //orxoblox_->LevelUp();
     
    218226
    219227            }
    220             if (position.z < -this->fieldHeight_ / 2){
    221                 position.z = -this->fieldHeight_ / 2 ;
     228            if (position.z < -this->fieldHeight_){
     229                position.z = -this->fieldHeight_;
    222230               
    223231            }
     
    228236        //Ball hits the right or left wall and should bounce back.
    229237        // If the ball has crossed the left or right boundary of the playing field.
    230         if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     238        if (position.x > this->fieldWidth_ || position.x < -this->fieldWidth_)
    231239        {
    232240            //Ball hits the right Wall
    233             if (position.x > this->fieldWidth_ / 2)
     241            if (position.x > this->fieldWidth_)
    234242                {
    235243                    // Set the ball to be exactly at the boundary.
    236                     position.x = this->fieldWidth_ / 2;
     244                    position.x = this->fieldWidth_;
    237245                    // Invert its velocity in x-direction (i.e. it bounces off).
    238246                    velocity.x = -velocity.x;
     
    241249
    242250            //Ball hits the left wall
    243             else if (position.x < -this->fieldWidth_ / 2)
     251            else if (position.x < -this->fieldWidth_)
    244252                {
    245253                        // Set the ball to be exactly at the boundary.
    246                         position.x = -this->fieldWidth_ / 2;
     254                        position.x = -this->fieldWidth_;
    247255                        // Invert its velocity in x-direction (i.e. it bounces off).
    248256                        velocity.x = -velocity.x;
  • code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.cc

    r12281 r12371  
    3434#include "BallGun.h"
    3535
     36
    3637#include "core/CoreIncludes.h"
    3738#include "core/XMLPort.h"
     
    5960        this->reloadTime_ = 0.25f;
    6061        this->damage_ = 0.0f; //default 15
    61         this->speed_ = 750.0f;
    62         this->delay_ = 0.0f;
     62        this->speed_ = 50;
     63        this->delay_ = 100;
    6364        this->setMunitionName("BallMunition");
    6465        this->mesh_ = "laserbeam.mesh";
Note: See TracChangeset for help on using the changeset viewer.