[Orxonox-commit 7701] r12294 - in code/branches/OrxoBlox_FS19: data/levels src/modules/OrxoBlox

jeromela at orxonox.net jeromela at orxonox.net
Thu Apr 11 14:22:32 CEST 2019


Author: jeromela
Date: 2019-04-11 14:22:31 +0200 (Thu, 11 Apr 2019)
New Revision: 12294

Modified:
   code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
Log:
Spielfeldbegrenzungen umgesetzt

Modified: code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw	2019-04-11 12:14:30 UTC (rev 12293)
+++ code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw	2019-04-11 12:22:31 UTC (rev 12294)
@@ -76,7 +76,7 @@
 
     <MovableEntity rotationrate=5 rotationaxis="0,0,1">
       <attached>
-        <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="100,120" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25>
+        <OrxoBloxCenterpoint name=OrxoBloxcenter dimension="120,100" balltemplate=OrxoBloxball battemplate=OrxoBloxbat ballspeed=200 ballaccfactor=1.0 batspeed=130 batlength=0.25>
           <attached>
             <!-- Balken die das Spielfeld begrenzen. -->
             <Model position="0,0,-50" mesh="cube.mesh" scale3D="60,1,1" />

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-04-11 12:14:30 UTC (rev 12293)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc	2019-04-11 12:22:31 UTC (rev 12294)
@@ -140,7 +140,7 @@
 
             // Attach the ball to the centerpoint and set the parameters as specified in the centerpoint, the ball is attached to.
             this->center_->attach(this->ball_);
-            this->ball_->setPosition(0, 0, 0);
+            this->ball_->setPosition(0,0,50);
             this->ball_->setFieldDimension(this->center_->getFieldDimension());
             this->ball_->setSpeed(0);
             this->ball_->setAccelerationFactor(this->center_->getBallAccelerationFactor());

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-04-11 12:14:30 UTC (rev 12293)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc	2019-04-11 12:22:31 UTC (rev 12294)
@@ -156,87 +156,30 @@
 
             this->fireEvent();
         }
-
-        // If the ball has crossed the left or right boundary of the playing field (i.e. a player has just scored, if the bat isn't there to parry).
+        
+        //Ball hits the right or left wall and should bounce back.
+        // If the ball has crossed the left or right boundary of the playing field.
         if (position.x > this->fieldWidth_ / 2 || position.x < -this->fieldWidth_ / 2)
         {
-            float distance = 0;
-
-            if (this->bat_ != nullptr) // If there are bats.
-            {
-                // If the right boundary has been crossed.
-                if (position.x > this->fieldWidth_ / 2 && this->bat_[1] != nullptr)
+            //Ball hits the right Wall
+            if (position.x > this->fieldWidth_ / 2)
                 {
-                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
-                    distance = (position.z - this->bat_[1]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
-                    
-
-                    if (fabs(distance) <= 1) // If the bat is there to parry.
-                    {
-                        defBatSound_->play(); //play bat sound
-                        // Set the ball to be exactly at the boundary.
-                        position.x = this->fieldWidth_ / 2;
-                        // Invert its velocity in x-direction (i.e. it bounces off).
-                        velocity.x = -velocity.x;
-                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
-                        velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_;
-                        acceleration = this->bat_[1]->getVelocity() * this->accelerationFactor_ * -1;
-
-                        this->fireEvent();
+                    // Set the ball to be exactly at the boundary.
+                    position.x = this->fieldWidth_ / 2;
+                    // Invert its velocity in x-direction (i.e. it bounces off).
+                    velocity.x = -velocity.x;
+                    this->fireEvent();
                     }
 
-                    // If the left player scores.
-                    else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
-                    {
-                        ChatManager::message("You suck!!");
-                        defScoreSound_->play();//play score sound
-                        if (this->getGametype() && this->bat_[0])
-                        {
-                            ChatManager::message("You suck!!");
-
-
-                            this->getGametype()->playerScored(this->bat_[0]->getPlayer());
-                            return;
-                        }
-                    }
-
-
-
-
-
-                }
-                // If the left boundary has been crossed.
-                else if (position.x < -this->fieldWidth_ / 2 && this->bat_[0] != nullptr)
+            //Ball hits the left wall
+            else if (position.x < -this->fieldWidth_ / 2)
                 {
-                    // Calculate the distance (in z-direction) between the ball and the center of the bat, weighted by half of the effective length of the bat (with additional 10%)
-                    distance = (position.z - this->bat_[0]->getPosition().z) / (this->fieldHeight_ * (this->batlength_ * 1.10f) / 2);
-                    if (fabs(distance) <= 1) // If the bat is there to parry.
-                    {
-                        defBatSound_->play(); //play bat sound
                         // Set the ball to be exactly at the boundary.
                         position.x = -this->fieldWidth_ / 2;
                         // Invert its velocity in x-direction (i.e. it bounces off).
                         velocity.x = -velocity.x;
-                        // Adjust the velocity in the z-direction, depending on where the ball hit the bat.
-                        velocity.z = distance * distance * sgn(distance) * OrxoBloxBall::MAX_REL_Z_VELOCITY * this->speed_;
-                        acceleration = this->bat_[0]->getVelocity() * this->accelerationFactor_ * -1;
-
                         this->fireEvent();
                     }
-                    // If the right player scores.
-                    else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_))
-                    {
-                        defScoreSound_->play();//play score sound
-                        if (this->getGametype() && this->bat_[1])
-                        {
-                            ChatManager::message("You suck!!");
-
-                            this->getGametype()->playerScored(this->bat_[1]->getPlayer());
-                            return;
-                        }
-                    }
-                }
-            }
         }
 
         // Set the position, velocity and acceleration of the ball, if they have changed.



More information about the Orxonox-commit mailing list