[Orxonox-commit 7768] r12360 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox

pomselj at orxonox.net pomselj at orxonox.net
Thu May 9 15:32:40 CEST 2019


Author: pomselj
Date: 2019-05-09 15:32:40 +0200 (Thu, 09 May 2019)
New Revision: 12360

Modified:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
Log:
bounces moore smoothly

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-05-09 13:32:40 UTC (rev 12360)
@@ -241,6 +241,22 @@
 
             this->stones_.push_back(this->futureWall_->getStone(i));
         }
+
+        for(OrxoBloxWall* wall : this->activeWalls_) {
+            if(wall->isEmpty()) {
+                wall->destroy();
+            }
+            int NumberOfStones = 0;
+            for(int i = 0; i < 10; i++) {
+                if(wall->getStone(i) == nullptr) {
+                    continue;
+                }
+                else {
+                    NumberOfStones++;
+                }
+
+            }
+        }
         //new location of ship
         //new amount of balls
         //create balls
@@ -282,9 +298,9 @@
             }
             orxout() << "Checking a stone" << endl;
             const Vector3& StonePosition = someStone->getPosition(); //!< Saves the position of the currentStone
-            int size = someStone->getSize();
-            if((BallPosition.x >= StonePosition.x - size && BallPosition.x <= StonePosition.x + size) && 
-                (BallPosition.z >= StonePosition.z - size && BallPosition.z <= StonePosition.z + size)) {
+            int size = someStone->getSize()/2;
+            if((BallPosition.x - Ball->getRadius() >= StonePosition.x - size && BallPosition.x + Ball->getRadius() <= StonePosition.x + size) && 
+                (BallPosition.z - Ball->getRadius() >= StonePosition.z - size && BallPosition.z + Ball->getRadius() <= StonePosition.z + size)) {
                 orxout() << "FOUND ONE" << endl;
                 return someStone;
             }

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-05-09 13:32:40 UTC (rev 12360)
@@ -66,6 +66,7 @@
         this->bDeleteBats_ = false;
         this->relMercyOffset_ = 0.05f;
         this->orxoblox_ = this->getOrxoBlox();
+        this->radius_ = 1.5;
 
         this->registerVariables();
 
@@ -301,10 +302,6 @@
         Vector3 positionStone = Stone->getPosition();
         Vector3 myPosition = this->getPosition();
         orxout() << "About to Bounce >D" << endl;
-        //if (positionOtherObject.y < 0) {
-            //this.destroy()
-        //}S
-        //else {
         
             int distance_X = myPosition.x - positionStone.x;
             int distance_Z = myPosition.z - positionStone.z;
@@ -321,18 +318,20 @@
 
             if (distance_X < distance_Z) {
                 velocity.z = -velocity.z;
-                orxout() << "z" << endl;
+                orxout() << "z" << endl;  
             }
-            if (distance_Z < distance_X) {
+            else if (distance_Z < distance_X) {
                 velocity.x = -velocity.x;
-                orxout() << "x" << endl;
+                orxout() << "x" << endl;       
             }
             else {
                 velocity.x = -velocity.x;
                 velocity.z = -velocity.z;
                 orxout() << "both" << endl;
-            }
+            }                                  
+
             this->setVelocity(velocity);
+            this->setPosition(myPosition);
     }
 
 
@@ -345,7 +344,8 @@
         orxout() << "About to Bounce >D" << endl;
         Bounce(Stone);
         //if(otherObject->getHealth() <= 0) {
-            Stone->destroy();
+        Stone->destroy();
+
         //}
         //otherObject->reduceHealth();
     }
@@ -361,5 +361,9 @@
         return nullptr;
     }
 
+    float OrxoBloxBall::getRadius() {
+        return this->radius_;
+    }
 
+
 }

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h	2019-05-09 13:32:40 UTC (rev 12360)
@@ -133,13 +133,14 @@
             const std::string& getDefBatSound();
             void setDefBoundarySound(const std::string& engineSound);
             const std::string& getDefBoundarySound();
+            float getRadius();
 
-            unsigned int getHealth();
 
         private:
             void registerVariables();
 
             OrxoBlox* getOrxoBlox();
+            float radius_;
             float fieldWidth_; //!< The width of the playing field.
             float fieldHeight_; //!< The height of the playing field.
             float speed_; //!< The speed (in x-direction) of the ball.

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.cc	2019-05-09 13:32:40 UTC (rev 12360)
@@ -28,4 +28,8 @@
     void OrxoBloxStones::reduceHealth() {
         this->health_ -= 1;
     }
+
+    float OrxoBloxStones::getSize() {
+        return this->size_;
+    }
 }
\ No newline at end of file

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxStones.h	2019-05-09 13:32:40 UTC (rev 12360)
@@ -66,6 +66,8 @@
             unsigned int getHealth();
 
             void reduceHealth();
+
+            float getSize();
                 
         private:
             float size_; //!< The dimensions a stone has in the game world.

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.cc	2019-05-09 13:32:40 UTC (rev 12360)
@@ -97,4 +97,22 @@
     int OrxoBloxWall::getNumberOfStones() {
         return num_Stones_;
     }
+
+    void OrxoBloxWall::setNumberOfStones(int number) {
+        this->num_Stones_ = number;
+    }
+
+    bool OrxoBloxWall::isEmpty() {
+        if (num_Stones_ == 0) {
+            return true;
+        }
+        return false;
+    }
+
+    void OrxoBloxWall::reduceNumberOfStones() {
+        if(num_Stones_ == 0) {
+            orxout() << "Wanted to reduce number of stones, but there were none" << endl;
+        }
+        this->num_Stones_ -= 1;
+    }
 }
\ No newline at end of file

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h	2019-05-09 13:29:29 UTC (rev 12359)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxWall.h	2019-05-09 13:32:40 UTC (rev 12360)
@@ -42,6 +42,9 @@
             void setGame(OrxoBlox* orxoblox)
                 { assert(orxoblox); orxoblox_ = orxoblox; }
             int getNumberOfStones();
+            bool isEmpty();
+            void reduceNumberOfStones();
+            void setNumberOfStones(int number);
         private:
             void createWall(void);
             OrxoBlox* getOrxoBlox();



More information about the Orxonox-commit mailing list