Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 16, 2019, 11:11:39 AM (5 years ago)
Author:
pomselj
Message:

We can shoot

File:
1 edited

Legend:

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

    r12310 r12368  
    3333
    3434#include "BallProjectile.h"
     35#include "../OrxoBlox/OrxoBlox.h"
     36#include "gametypes/Gametype.h"
     37
    3538
    3639#include <OgreParticleEmitter.h>
     
    5457        this->maxTextureIndex_ = 8;
    5558        this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
     59        //this->orxoblox_ = this->getOrxoBlox();
    5660
    5761        //setEffect("Orxonox/sparks2");
     
    135139    }
    136140
    137 
    138 
    139 
    140141   
    141142    bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
     
    151152
    152153
    153 
    154 
     154    /*
     155    OrxoBlox* BallProjectile::getOrxoBlox()
     156    {
     157        if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
     158        {
     159            OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
     160            return orxobloxGametype;
     161        }
     162        else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
     163        return nullptr;
     164    }
     165    */
    155166
    156167
     
    159170        SUPER(BallProjectile, tick, dt);
    160171
    161         // Get the current position, velocity and acceleration of the ball.
     172               // Get the current position, velocity and acceleration of the ball.
    162173        Vector3 position = this->getPosition();
    163174        Vector3 velocity = this->getVelocity();
     
    167178        if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
    168179        {
    169             // Its velocity in z-direction is inverted (i.e. it bounces off).
     180
    170181            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;
     182            // 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){
     184                // Set the ball to be exactly at the boundary.
     185                position.z = this-> fieldHeight_ / 2;
     186               
     187                //orxoblox_->LevelUp();
     188
     189
     190                //this->setSpeed(0); // doesn't work here, why??;
     191                //Stopping ball
     192                orxout() << "Ball stopped" << endl;
     193                velocity.x = 0;
     194                velocity.y = 0;
     195                velocity.z = 0;
     196
     197                //ChatManager::message("Waiting for your input");
     198                //Input new speed here:
     199                //ChatManager::message("Setting new speed");
     200               
     201                //%%%%%%%%%%%%
     202                //MAUSPOSITION
     203                //%%%%%%%%%%%%
     204                //Reads current mouse position
     205                //TODO: read Mouse position on click!
     206                //int mousex = InputManager::getInstance().getMousePosition().first;
     207                //int mousey = InputManager::getInstance().getMousePosition().second;
     208                //ChatManager::message("Read mouse position");
     209                //orxout() << "Mouseposition" << endl;
     210                //orxout() << mousex << endl;
     211                //ChatManager::message(mousex);
     212                //ChatManager::message("mousey");
     213                //ChatManager::message(mousey);
     214                //Set new speed here!!
     215                velocity.x = rnd(-100,100);
     216                velocity.z = rnd(-50,-100);
     217               
     218
     219            }
     220            if (position.z < -this->fieldHeight_ / 2){
     221                position.z = -this->fieldHeight_ / 2 ;
     222               
     223            }
    176224
    177225            this->fireEvent();
     
    210258        if (position != this->getPosition())
    211259            this->setPosition(position);
    212     }
    213 
     260        //this->Collides((this->orxoblox_->CheckForCollision(this)));
     261
     262    }
    214263
    215264
Note: See TracChangeset for help on using the changeset viewer.