[Orxonox-commit 7776] r12368 - in code/branches/OrxoBlox_FS19: data/levels data/levels/includes src/modules/OrxoBlox src/modules/weapons/projectiles
pomselj at orxonox.net
pomselj at orxonox.net
Thu May 16 11:11:39 CEST 2019
Author: pomselj
Date: 2019-05-16 11:11:39 +0200 (Thu, 16 May 2019)
New Revision: 12368
Modified:
code/branches/OrxoBlox_FS19/data/levels/includes/OrxoBloxWeapon.oxi
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
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h
Log:
We can shoot
Modified: code/branches/OrxoBlox_FS19/data/levels/includes/OrxoBloxWeapon.oxi
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/includes/OrxoBloxWeapon.oxi 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/data/levels/includes/OrxoBloxWeapon.oxi 2019-05-16 09:11:39 UTC (rev 12368)
@@ -13,10 +13,10 @@
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
</links>
<Weapon>
- <Asteroids2DWeapon mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" projectileMesh="laserbeam.mesh" />
+ <BallGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 0.1, 1.6,-2" projectileMesh="laserbeam.mesh" />
</Weapon>
<Weapon>
- <Asteroids2DWeapon mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" projectileMesh="laserbeam.mesh" />
+ <BallGun mode=0 munitionpershot=0 delay=0 damage=9.3 material="Flares/point_lensflare" muzzleoffset=" 1.6, 1.3, -2.0" projectileMesh="laserbeam.mesh" />
</Weapon>
</WeaponPack>
<WeaponPack>
@@ -26,5 +26,5 @@
</WeaponPack>
</weaponpacks>
<munition>
- <LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
+ <BallMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=0.5/>
</munition>
Modified: code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/data/levels/orxoblox.oxw 2019-05-16 09:11:39 UTC (rev 12368)
@@ -41,6 +41,9 @@
<Light type=point diffuse="1.0, 1.0, 0.5" specular="1.0, 1.0, 0.5" attenuation="1200, 1.0, 0.0035, 0.00005" />
<ParticleSpawner name=hiteffect position="0,0,0" source="Orxonox/sparks2" lifetime=0.01 autostart=0 mainstate=spawn />
</attached>
+ <collisionShapes>
+ <SphereCollisionShape radius="2" />
+ </collisionShapes>
<eventlisteners>
<EventTarget target=hiteffect />
</eventlisteners>
@@ -55,6 +58,9 @@
<Model position="0,0,0" mesh="CuboidBody.mesh" scale=4.5 />
<Model position="0,0,0" mesh="cube_orange.mesh" scale=4.3 />
</attached>
+ <collisionShapes>
+ <BoxCollisionShape halfExtents="4.5, 4.5, 4.5" />
+ </collisionShapes>
</OrxoBloxStones>
</Template>
@@ -62,6 +68,9 @@
<Template name=OrxoBloxwall>
<OrxoBloxWall>
+ <collisionShapes>
+ <BoxCollisionShape halfExtents="4.5, 4.5, 4.5" />
+ </collisionShapes>
</OrxoBloxWall>
</Template>
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBlox.cc 2019-05-16 09:11:39 UTC (rev 12368)
@@ -105,7 +105,7 @@
this->ball_ = nullptr;
}
- if (this->futureWall_)
+ if (this->futureWall_ != nullptr)
{
this->futureWall_->destroy();
this->futureWall_ = nullptr;
@@ -112,11 +112,13 @@
}
for (OrxoBloxWall* wall : this->activeWalls_)
+ if (wall != nullptr)
wall->destroy();
this->activeWalls_.clear();
for (OrxoBloxStones* stone : this->stones_)
+ if(stone != nullptr)
stone->destroy();
this->stones_.clear();
@@ -284,7 +286,7 @@
if (this->ball_ != nullptr && this->center_ != nullptr)
this->ball_->setSpeed(this->center_->getBallSpeed());
}
-
+
OrxoBloxStones* OrxoBlox::CheckForCollision(OrxoBloxBall* Ball) {
//orxout() << "Checking for Collision" << endl;
@@ -313,4 +315,27 @@
this->player_ = player;
}
+/*
+ bool OrxoBlox::Intersect(int XpositionBall, int XPositionBlock, int YPositionBall, int YPositionBlock, int radiusBall, int sizeBlock) {
+ distanceX = XpositionBall - XPositionBlock;
+ distanceY = YPositionBall - YPositionBlock;
+ if (distanceX < 0) {
+ distanceX = -distanceX;
+ }
+ if (distanceY < 0) {
+ distanceY = -distanceY;
+ }
+ if((distanceX <= radiusBall + sizeBlock) || (distanceY <= radiusBall + sizeBlock)) {
+ return true;
+ }
+ else {
+ top = YPositionBall + radiusBall;
+ right = XpositionBall + radiusBall;
+ bottom = YPositionBall - radiusBall;
+ left = XpositionBall - radiusBall;
+
+ if((top >= YPositionBlock - size) && (top <= YPositionBlock + size) && (left <= XPositionBlock + size) && (left >= XPositionBlock - size))
+ }
+ }
+ */
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.cc 2019-05-16 09:11:39 UTC (rev 12368)
@@ -67,7 +67,7 @@
this->relMercyOffset_ = 0.05f;
this->orxoblox_ = this->getOrxoBlox();
- this->radius_ = 1.5;
+ this->radius_ = 3;
this->registerVariables();
@@ -136,15 +136,15 @@
Vector3 acceleration = this->getAcceleration();
// 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).
- if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
+ if (position.z > this->fieldHeight_ / 2 || position.z - radius_ < -this->fieldHeight_ / 2)
{
defBoundarySound_->play(); //play boundary sound
// Its velocity in z-direction is inverted (i.e. it bounces off).
velocity.z = -velocity.z;
- // And its position is set as to not overstep the boundary it has just crossed.
+ // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
if (position.z > this->fieldHeight_ / 2){
// Set the ball to be exactly at the boundary.
- position.z = this-> fieldHeight_ / 2;
+ position.z = this-> fieldHeight_ / 2 - radius_;
orxoblox_->LevelUp();
@@ -179,8 +179,8 @@
}
- if (position.z < -this->fieldHeight_ / 2){
- position.z = -this->fieldHeight_ / 2;
+ if (position.z - radius_ < -this->fieldHeight_ / 2){
+ position.z = -this->fieldHeight_ / 2 + radius_;
}
@@ -189,13 +189,13 @@
//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)
+ if (position.x + radius_ > this->fieldWidth_ / 2 || position.x - radius_ < -this->fieldWidth_ / 2)
{
//Ball hits the right Wall
- if (position.x > this->fieldWidth_ / 2)
+ if (position.x + radius_ > this->fieldWidth_ / 2)
{
// Set the ball to be exactly at the boundary.
- position.x = this->fieldWidth_ / 2;
+ position.x = this->fieldWidth_ / 2 - radius_;
// Invert its velocity in x-direction (i.e. it bounces off).
velocity.x = -velocity.x;
this->fireEvent();
@@ -202,10 +202,10 @@
}
//Ball hits the left wall
- else if (position.x < -this->fieldWidth_ / 2)
+ else if (position.x - radius_ < -this->fieldWidth_ / 2)
{
// Set the ball to be exactly at the boundary.
- position.x = -this->fieldWidth_ / 2;
+ position.x = -this->fieldWidth_ / 2 + radius_;
// Invert its velocity in x-direction (i.e. it bounces off).
velocity.x = -velocity.x;
this->fireEvent();
@@ -219,7 +219,7 @@
this->setVelocity(velocity);
if (position != this->getPosition())
this->setPosition(position);
- this->Collides((this->orxoblox_->CheckForCollision(this)));
+ //this->Collides((this->orxoblox_->CheckForCollision(this)));
}
@@ -288,7 +288,7 @@
}
- void OrxoBloxBall::Bounce(OrxoBloxStones* Stone) {
+ void OrxoBloxBall::Bounce(WorldEntity* Stone) {
Vector3 velocity = this->getVelocity();
Vector3 positionStone = Stone->getPosition();
@@ -336,12 +336,20 @@
orxout() << "About to Bounce >D" << endl;
Bounce(Stone);
//if(otherObject->getHealth() <= 0) {
- Stone->destroy();
+ //Stone->destroy();
//}
//otherObject->reduceHealth();
}
+ bool OrxoBloxBall::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
+ {
+ orxout() << "detected collision" << endl;
+ Bounce(otherObject);
+
+ return true;
+ }
+
OrxoBlox* OrxoBloxBall::getOrxoBlox()
{
if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxBall.h 2019-05-16 09:11:39 UTC (rev 12368)
@@ -110,8 +110,9 @@
- void Bounce(OrxoBloxStones* otherObject);
+ void Bounce(WorldEntity* Stone);
void Collides(OrxoBloxStones* otherObject);
+ bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint) override;
static const float MAX_REL_Z_VELOCITY;
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc 2019-05-16 09:11:39 UTC (rev 12368)
@@ -32,7 +32,10 @@
*/
#include "BallProjectile.h"
+#include "../OrxoBlox/OrxoBlox.h"
+#include "gametypes/Gametype.h"
+
#include <OgreParticleEmitter.h>
#include "core/CoreIncludes.h"
#include "tools/ParticleInterface.h"
@@ -53,6 +56,7 @@
this->setMass(0.1f);
this->maxTextureIndex_ = 8;
this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
+ //this->orxoblox_ = this->getOrxoBlox();
//setEffect("Orxonox/sparks2");
}
@@ -134,9 +138,6 @@
//}
}
-
-
-
bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
{
@@ -150,15 +151,25 @@
}
+ /*
+ OrxoBlox* BallProjectile::getOrxoBlox()
+ {
+ if (this->getGametype() != nullptr && this->getGametype()->isA(Class(OrxoBlox)))
+ {
+ OrxoBlox* orxobloxGametype = orxonox_cast<OrxoBlox*>(this->getGametype());
+ return orxobloxGametype;
+ }
+ else orxout()<<"There is no Gametype for OrxoBlox! ask Anna"<< endl;
+ return nullptr;
+ }
+ */
-
-
void BallProjectile::tick(float dt)
{
SUPER(BallProjectile, tick, dt);
- // Get the current position, velocity and acceleration of the ball.
+ // Get the current position, velocity and acceleration of the ball.
Vector3 position = this->getPosition();
Vector3 velocity = this->getVelocity();
Vector3 acceleration = this->getAcceleration();
@@ -166,14 +177,51 @@
// 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).
if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2)
{
- // Its velocity in z-direction is inverted (i.e. it bounces off).
+
velocity.z = -velocity.z;
- // And its position is set as to not overstep the boundary it has just crossed.
- if (position.z > this->fieldHeight_ / 2)
- position.z = this->fieldHeight_ / 2;
- if (position.z < -this->fieldHeight_ / 2)
- position.z = -this->fieldHeight_ / 2;
+ // And its position is set as to not overstep the boundary it has just crossed. Remember z axis is reverted!!!
+ if (position.z > this->fieldHeight_ / 2){
+ // Set the ball to be exactly at the boundary.
+ position.z = this-> fieldHeight_ / 2;
+
+ //orxoblox_->LevelUp();
+
+ //this->setSpeed(0); // doesn't work here, why??;
+ //Stopping ball
+ orxout() << "Ball stopped" << endl;
+ velocity.x = 0;
+ velocity.y = 0;
+ velocity.z = 0;
+
+ //ChatManager::message("Waiting for your input");
+ //Input new speed here:
+ //ChatManager::message("Setting new speed");
+
+ //%%%%%%%%%%%%
+ //MAUSPOSITION
+ //%%%%%%%%%%%%
+ //Reads current mouse position
+ //TODO: read Mouse position on click!
+ //int mousex = InputManager::getInstance().getMousePosition().first;
+ //int mousey = InputManager::getInstance().getMousePosition().second;
+ //ChatManager::message("Read mouse position");
+ //orxout() << "Mouseposition" << endl;
+ //orxout() << mousex << endl;
+ //ChatManager::message(mousex);
+ //ChatManager::message("mousey");
+ //ChatManager::message(mousey);
+ //Set new speed here!!
+ velocity.x = rnd(-100,100);
+ velocity.z = rnd(-50,-100);
+
+
+ }
+ if (position.z < -this->fieldHeight_ / 2){
+ position.z = -this->fieldHeight_ / 2 ;
+
+ }
+
this->fireEvent();
}
@@ -209,11 +257,12 @@
this->setVelocity(velocity);
if (position != this->getPosition())
this->setPosition(position);
+ //this->Collides((this->orxoblox_->CheckForCollision(this)));
+
}
-
void BallProjectile::setSpeed(float speed)
{
if (speed != this->speed_) // If the speed changes
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h 2019-05-16 09:00:57 UTC (rev 12367)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h 2019-05-16 09:11:39 UTC (rev 12368)
@@ -36,7 +36,10 @@
#include "weapons/WeaponsPrereqs.h"
#include "weapons/projectiles/BillboardProjectile.h"
+#include "../OrxoBlox/OrxoBlox.h"
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
namespace orxonox
{
@@ -64,6 +67,7 @@
void registerVariables();
void changeTexture();
+ //OrxoBlox* getOrxoBlox();
float speed_; //!< The speed (in x-direction) of the ball.
float fieldWidth_; //!< The width of the playing field.
@@ -71,6 +75,7 @@
unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
unsigned int maxTextureIndex_; //!< The maximal index.
std::string materialBase_; //!< The base name of the material.
+ //OrxoBlox* orxoblox_;
};
}
More information about the Orxonox-commit
mailing list