[Orxonox-commit 6755] r11383 - in code/branches/SuperOrxoBros_FS17: data/levels src/modules/superorxobros
jkindle at orxonox.net
jkindle at orxonox.net
Thu Mar 30 15:52:24 CEST 2017
Author: jkindle
Date: 2017-03-30 15:52:23 +0200 (Thu, 30 Mar 2017)
New Revision: 11383
Modified:
code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
Log:
Added movement of camera.
Modified: code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw
===================================================================
--- code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw 2017-03-30 13:14:02 UTC (rev 11382)
+++ code/branches/SuperOrxoBros_FS17/data/levels/SOB.oxw 2017-03-30 13:52:23 UTC (rev 11383)
@@ -15,7 +15,7 @@
<Template name=sobfigurecameras defaults=0>
<SOBFigure>
<camerapositions>
- <CameraPosition position="0,-150,0" absolute=false mouselook=false drag=false lookat="0,0,0"/>
+ <CameraPosition position="0,-150,0" absolute=true mouselook=false drag=false lookat="0,0,0"/>
</camerapositions>
</SOBFigure>
</Template>
@@ -81,11 +81,11 @@
<StaticEntity position="0,-1,-10" collisionType="static">
<attached>
- <Model mesh="cube.mesh" scale3D="76,76,1" />
+ <Model mesh="cube.mesh" scale3D="110,76,1" />
</attached>
<collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="76,76,1" />
+ <BoxCollisionShape position="0,0,0" halfExtents="110,76,1" />
</collisionShapes>
</StaticEntity>
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-03-30 13:14:02 UTC (rev 11382)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.cc 2017-03-30 13:52:23 UTC (rev 11383)
@@ -92,7 +92,7 @@
// figure_->InitializeAnimation(center_->getContext()); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
- center_->attach(figure_); //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ center_->attach(figure_);
figure_->setPosition(0, 0, 0);
}
else // If no centerpoint was specified, an error is thrown and the level is exited.
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-03-30 13:14:02 UTC (rev 11382)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOB.h 2017-03-30 13:52:23 UTC (rev 11383)
@@ -65,7 +65,7 @@
protected:
- void cleanup(); //!< Cleans up the Gametype by destroying the ball and the bats.
+ void cleanup(); //!< Cleans up the Gametype
WeakPtr<SOBCenterpoint> center_;
WeakPtr<SOBFigure> figure_;
WeakPtr<Camera> camera;
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-03-30 13:14:02 UTC (rev 11382)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc 2017-03-30 13:52:23 UTC (rev 11383)
@@ -36,6 +36,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "graphics/Model.h"
+#include "graphics/Camera.h"
namespace orxonox
@@ -47,7 +48,7 @@
RegisterObject(SOBFigure);
// initialize variables
-
+
moveUpPressed_ = false;
moveDownPressed_ = false;
moveLeftPressed_ = false;
@@ -54,9 +55,10 @@
moveDownPressed_ = false;
firePressed_ = false;
timeSinceLastFire_ = 0.0;
-
+ lastSpeed_z = 0.0;
+
gravityAcceleration_ = 250.0;//8.0
-
+
dead_ = false;
setAngularFactor(0.0);
}
@@ -64,7 +66,7 @@
void SOBFigure::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(SOBFigure, XMLPort, xmlelement, mode);
-
+
}
void SOBFigure::tick(float dt)
@@ -73,70 +75,84 @@
if (hasLocalController())
{
- timeSinceLastFire_ += dt;
+ Vector3 velocity = getVelocity();
+ Vector3 position = getPosition();
- // Move up/down
- Vector3 velocity = getVelocity();
-
-
-
+ if (dead_) {
+ velocity.x = 0;
+ velocity.z = 0;
+ setVelocity(velocity);
+ return;
+ }
-
-
+ int maxvelocity_x = 100;
+ int speedAddedPerTick = 5;
+ int camMaxOffset = 25;
- // Move left/right
- if (dead_ == false)
- {
+ timeSinceLastFire_ += dt;
+ lastSpeed_z = velocity.z;
- if (firePressed_ && std::abs(velocity.z) < 0.1) {
- velocity.z = 200;
- } else {
- }
+ //If player hits space and does not move in z-dir
+ if (firePressed_ && std::abs(velocity.z) < 0.07 && std::abs(lastSpeed_z) < 0.07) {
+ velocity.z = 150;
+ }
-
-
- if (moveRightPressed_)
- velocity.x = 75;
- else if (moveLeftPressed_)
- velocity.x = -75;
- else
- velocity.x = 0;
+ //Left-right movement with acceleration
+ if (moveRightPressed_) {
+ if (std::abs(velocity.x) < maxvelocity_x) {
+ velocity.x += speedAddedPerTick;
}
- else
- {
- velocity.x = 0.0;
+ } else if (moveLeftPressed_) {
+ if (std::abs(velocity.x) < maxvelocity_x) {
+ velocity.x -= speedAddedPerTick;
}
- velocity.z -= gravityAcceleration_*dt;
+ } else {
+ velocity.x /= 1.1;
+ }
+
-
+ velocity.z -= gravityAcceleration_*dt;
+ setVelocity(velocity);
- setVelocity(velocity);
+ //Camera operation
+ Camera* cam = getCamera();
+ Vector3 campos = cam->getPosition();
-
+ if (campos.x + camMaxOffset < position.x) {
+ campos.x = position.x - camMaxOffset;
+ cam->setPosition(campos);
}
+ if (campos.x - camMaxOffset > position.x) {
+ campos.x = position.x + camMaxOffset;
+ cam->setPosition(campos);
+ }
+
+
+ }
+
// Move through the left and right screen boundaries
-
+
//setPosition(position);
// Reset key variables
- moveUpPressed_ = false;
- moveDownPressed_ = false;
- moveLeftPressed_ = false;
- moveRightPressed_ = false;
- moveDownPressed_ = false;
- firePressed_ = false;
-
- }
+ moveUpPressed_ = false;
+ moveDownPressed_ = false;
+ moveLeftPressed_ = false;
+ moveRightPressed_ = false;
+ moveDownPressed_ = false;
+ firePressed_ = false;
-
+}
-
+
+
+
/* void SOBFigure::CollisionWithEnemy(SOBEnemy* enemy)
{
if (rocketActive_ == nullptr && propellerActive_ == nullptr && shieldActive_ == nullptr)
@@ -145,45 +161,45 @@
}
}*/
-
-
- void SOBFigure::moveFrontBack(const Vector2& value)
+
+
+void SOBFigure::moveFrontBack(const Vector2& value)
+{
+ if (value.x > 0)
{
- if (value.x > 0)
- {
- moveUpPressed_ = true;
- moveDownPressed_ = false;
- }
- else
- {
- moveUpPressed_ = false;
- moveDownPressed_ = true;
- }
+ moveUpPressed_ = true;
+ moveDownPressed_ = false;
}
+ else
+ {
+ moveUpPressed_ = false;
+ moveDownPressed_ = true;
+ }
+}
- void SOBFigure::moveRightLeft(const Vector2& value)
+void SOBFigure::moveRightLeft(const Vector2& value)
+{
+ if (value.x > 0)
{
- if (value.x > 0)
- {
- moveLeftPressed_ = false;
- moveRightPressed_ = true;
- }
- else
- {
- moveLeftPressed_ = true;
- moveRightPressed_ = false;
- }
+ moveLeftPressed_ = false;
+ moveRightPressed_ = true;
}
+ else
+ {
+ moveLeftPressed_ = true;
+ moveRightPressed_ = false;
+ }
+}
-
-
- void SOBFigure::boost(bool boost)
- {
- firePressed_ = true;
- }
+
+
+void SOBFigure::boost(bool boost)
+{
+ firePressed_ = true;
}
+}
Modified: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-03-30 13:14:02 UTC (rev 11382)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.h 2017-03-30 13:52:23 UTC (rev 11383)
@@ -64,6 +64,7 @@
bool firePressed_;
float gravityAcceleration_;
float timeSinceLastFire_;
+ float lastSpeed_z;
More information about the Orxonox-commit
mailing list