Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

We can shoot

Location:
code/branches/OrxoBlox_FS19/src/modules
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc

    r12367 r12368  
    106106        }
    107107
    108         if (this->futureWall_)
     108        if (this->futureWall_ != nullptr)
    109109            {
    110110            this->futureWall_->destroy();
     
    113113
    114114        for (OrxoBloxWall* wall : this->activeWalls_)
     115            if (wall != nullptr)
    115116            wall->destroy();
    116117        this->activeWalls_.clear();
     
    118119
    119120        for (OrxoBloxStones* stone : this->stones_)
     121            if(stone != nullptr)
    120122            stone->destroy();
    121123        this->stones_.clear();
     
    285287            this->ball_->setSpeed(this->center_->getBallSpeed());
    286288    }
    287 
     289     
    288290    OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
    289291
     
    314316    }
    315317   
     318/*
     319    bool OrxoBlox::Intersect(int XpositionBall, int XPositionBlock, int YPositionBall, int YPositionBlock, int radiusBall, int sizeBlock) {
     320        distanceX = XpositionBall - XPositionBlock;
     321        distanceY = YPositionBall - YPositionBlock;
     322        if (distanceX < 0) {
     323            distanceX = -distanceX;
     324        }
     325        if (distanceY < 0) {
     326            distanceY = -distanceY;
     327        }
     328        if((distanceX <= radiusBall + sizeBlock) || (distanceY <= radiusBall + sizeBlock)) {
     329            return true;
     330        }
     331        else {
     332            top = YPositionBall + radiusBall;
     333            right = XpositionBall + radiusBall;
     334            bottom = YPositionBall - radiusBall;
     335            left = XpositionBall - radiusBall;
     336
     337            if((top >= YPositionBlock - size) && (top <= YPositionBlock + size) && (left <= XPositionBlock + size) && (left >= XPositionBlock - size))
     338        }
     339    }
     340  */ 
    316341}
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc

    r12366 r12368  
    6868        this->relMercyOffset_ = 0.05f;
    6969        this->orxoblox_ = this->getOrxoBlox();
    70         this->radius_ = 1.5;
     70        this->radius_ = 3;
    7171
    7272        this->registerVariables();
     
    137137
    138138        // 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).
    139         if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
     139        if (position.z > this->fieldHeight_ / 2 || position.z - radius_ < -this->fieldHeight_ / 2)
    140140        {
    141141            defBoundarySound_->play(); //play boundary sound
    142142            // Its velocity in z-direction is inverted (i.e. it bounces off).
    143143            velocity.z = -velocity.z;
    144             // And its position is set as to not overstep the boundary it has just crossed.
     144            // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
    145145            if (position.z > this->fieldHeight_ / 2){
    146146                // Set the ball to be exactly at the boundary.
    147                 position.z = this-> fieldHeight_ / 2;
     147                position.z = this-> fieldHeight_ / 2 - radius_;
    148148               
    149149                orxoblox_->LevelUp();
     
    180180
    181181            }
    182             if (position.z < -this->fieldHeight_ / 2){
    183                 position.z = -this->fieldHeight_ / 2;
     182            if (position.z - radius_ < -this->fieldHeight_ / 2){
     183                position.z = -this->fieldHeight_ / 2 + radius_;
    184184               
    185185            }
     
    190190        //Ball hits the right or left wall and should bounce back.
    191191        // If the ball has crossed the left or right boundary of the playing field.
    192         if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
     192        if (position.x + radius_ > this->fieldWidth_ / 2 || position.x - radius_ < -this->fieldWidth_ / 2)
    193193        {
    194194            //Ball hits the right Wall
    195             if (position.x > this->fieldWidth_ / 2)
     195            if (position.x + radius_ > this->fieldWidth_ / 2)
    196196                {
    197197                    // Set the ball to be exactly at the boundary.
    198                     position.x = this->fieldWidth_ / 2;
     198                    position.x = this->fieldWidth_ / 2 - radius_;
    199199                    // Invert its velocity in x-direction (i.e. it bounces off).
    200200                    velocity.x = -velocity.x;
     
    203203
    204204            //Ball hits the left wall
    205             else if (position.x < -this->fieldWidth_ / 2)
     205            else if (position.x - radius_ < -this->fieldWidth_ / 2)
    206206                {
    207207                        // Set the ball to be exactly at the boundary.
    208                         position.x = -this->fieldWidth_ / 2;
     208                        position.x = -this->fieldWidth_ / 2 + radius_;
    209209                        // Invert its velocity in x-direction (i.e. it bounces off).
    210210                        velocity.x = -velocity.x;
     
    220220        if (position != this->getPosition())
    221221            this->setPosition(position);
    222         this->Collides((this->orxoblox_->CheckForCollision(this)));
     222        //this->Collides((this->orxoblox_->CheckForCollision(this)));
    223223
    224224 
     
    289289
    290290
    291     void OrxoBloxBall::Bounce(OrxoBloxStones* Stone) {
     291    void OrxoBloxBall::Bounce(WorldEntity* Stone) {
    292292
    293293        Vector3 velocity = this->getVelocity();
     
    337337        Bounce(Stone);
    338338        //if(otherObject->getHealth() <= 0) {
    339         Stone->destroy();
     339        //Stone->destroy();
    340340
    341341        //}
    342342        //otherObject->reduceHealth();
     343    }
     344
     345    bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     346    {
     347        orxout() << "detected collision" << endl;
     348        Bounce(otherObject);
     349
     350        return true;
    343351    }
    344352
  • code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h

    r12366 r12368  
    111111       
    112112
    113             void Bounce(OrxoBloxStones* otherObject);
     113            void Bounce(WorldEntity* Stone);
    114114            void Collides(OrxoBloxStones* otherObject);
     115            bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
    115116
    116117            static const float MAX_REL_Z_VELOCITY;
  • 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
  • code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h

    r12310 r12368  
    3737#include "weapons/WeaponsPrereqs.h"
    3838#include "weapons/projectiles/BillboardProjectile.h"
     39#include "../OrxoBlox/OrxoBlox.h"
     40
     41#include "OrxoBlox/OrxoBloxPrereqs.h"
    3942
    4043namespace orxonox
     
    6568            void registerVariables();
    6669            void changeTexture();
     70            //OrxoBlox* getOrxoBlox();
    6771           
    6872            float speed_; //!< The speed (in x-direction) of the ball.
     
    7276            unsigned int maxTextureIndex_; //!< The maximal index.
    7377            std::string materialBase_; //!< The base name of the material.
     78            //OrxoBlox* orxoblox_;
    7479    };
    7580}
Note: See TracChangeset for help on using the changeset viewer.