[Orxonox-commit 5369] r10032 - in code/branches/pickupsFS14: data/levels src/modules/jump
fvultier at orxonox.net
fvultier at orxonox.net
Fri Apr 11 12:07:05 CEST 2014
Author: fvultier
Date: 2014-04-11 12:07:05 +0200 (Fri, 11 Apr 2014)
New Revision: 10032
Modified:
code/branches/pickupsFS14/data/levels/Jump.oxw
code/branches/pickupsFS14/src/modules/jump/Jump.cc
code/branches/pickupsFS14/src/modules/jump/Jump.h
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc
code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h
code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h
code/branches/pickupsFS14/src/modules/jump/JumpShip.cc
code/branches/pickupsFS14/src/modules/jump/JumpShip.h
Log:
Neue Platformen werden zur Laufzeit hinzugefugt, wenn sich die Ansicht nach oben verschiebt. Eigene Modelle importieren funktioniert.
Modified: code/branches/pickupsFS14/data/levels/Jump.oxw
===================================================================
--- code/branches/pickupsFS14/data/levels/Jump.oxw 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/data/levels/Jump.oxw 2014-04-11 10:07:05 UTC (rev 10032)
@@ -55,8 +55,19 @@
</Planet>
+ <MovableEntity
+ position="0, 0, 500"
+ scale="5"
+ collisionType="dynamic"
+ mass="10000000"
+ >
+ <attached>
+ <Model mesh="Platform01.mesh" />
+ </attached>
+ </MovableEntity>
+
<!-- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> -->
<Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
@@ -64,9 +75,7 @@
<SpawnPoint team=0 position="0,0,0" lookat="0,0,-1" spawnclass=JumpShip pawndesign=spaceshipjump />
-
-
<JumpCenterPoint name=jumpcenter />
@@ -98,4 +107,4 @@
</Scene>
-</Level>
\ No newline at end of file
+</Level>
Modified: code/branches/pickupsFS14/src/modules/jump/Jump.cc
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/Jump.cc 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/Jump.cc 2014-04-11 10:07:05 UTC (rev 10032)
@@ -59,27 +59,18 @@
Jump::Jump(Context* context) : Deathmatch(context)
{
RegisterObject(Jump);
+ platformList.clear();
+ yScreenPosition = 0;
+ screenShiftSinceLastUpdate = 0;
+
//this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
//this->center_ = 0;
- // init();
//this->setHUDTemplate("JumpHUD");
- }
- void Jump::init()
- {
- /*bEndGame = false;
- lives = 3;
- level = 1;
- point = 0;
- bShowLevel = false;
- multiplier = 1;
- b_combo = false;*/
- // spawn enemy every 3.5 seconds
- //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Jump::spawnEnemy, this)));
- //comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Jump::comboControll, this)));
}
+
/*void Jump::levelUp()
{
level++;
@@ -103,16 +94,54 @@
{
if (player == NULL)
{
- ObjectList<JumpShip>::iterator it;
- it = ObjectList<JumpShip>::begin();
- /*for (ObjectList<JumpShip>::iterator it = ObjectList<JumpShip>::begin(); it != ObjectList<JumpShip>::end(); ++it)
+ for (ObjectList<JumpShip>::iterator it = ObjectList<JumpShip>::begin(); it != ObjectList<JumpShip>::end(); ++it)
{
player = *it;
- }*/
+ }
}
return player;
}
+ void Jump::tick(float dt)
+ {
+
+
+ if (getPlayer() != NULL)
+ {
+ Vector3 shipPosition = getPlayer()->getPosition();
+
+ // Bildschirmposition kann nur nach oben verschoben werden
+ if (shipPosition.y > yScreenPosition)
+ {
+ screenShiftSinceLastUpdate += shipPosition.y - yScreenPosition;
+
+ yScreenPosition = shipPosition.y;
+ }
+
+ // Kameraposition nachfuehren
+ if (camera == NULL)
+ {
+ camera = getPlayer()->getCamera();
+ }
+ if (camera != NULL)
+ {
+ camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100));
+ //camera->setOrientation(Vector3::UNIT_Z, Degree(180));
+ }
+
+ if (screenShiftSinceLastUpdate > 200.0)
+ {
+ screenShiftSinceLastUpdate -= 200.0;
+ orxout() << "new section added" << endl;
+ addPlatform(shipPosition.x, shipPosition.y + 300.0);
+ }
+
+ }
+
+ SUPER(Jump, tick, dt);
+ }
+
+
/*void Jump::spawnEnemy()
{
if (getPlayer() == NULL)
@@ -157,9 +186,13 @@
b_combo = false;
}*/
- /*void Jump::start()
+
+ void Jump::start()
{
- init();
+ // Call start for the parent class.
+ Deathmatch::start();
+
+ /*
// Set variable to temporarily force the player to spawn.
this->bForceSpawn_ = true;
@@ -169,10 +202,13 @@
GSLevel::startMainMenu();
return;
}
- // Call start for the parent class.
- Deathmatch::start();
- }*/
+ */
+ //addPlatform(0,0);
+
+ }
+
+
/*void Jump::addPoints(int numPoints)
{
if (!bEndGame)
@@ -190,4 +226,12 @@
// Instead startMainMenu, this won't crash.
GSLevel::startMainMenu();
}*/
+
+ void Jump::addPlatform(float xPosition, float yPosition)
+ {
+ JumpPlatform* newPlatform = new JumpPlatform(center_->getContext());
+ newPlatform->setPosition(Vector3(xPosition, yPosition, 0));
+ platformList.push_front(newPlatform);
+ }
+
}
Modified: code/branches/pickupsFS14/src/modules/jump/Jump.h
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/Jump.h 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/Jump.h 2014-04-11 10:07:05 UTC (rev 10032)
@@ -40,7 +40,9 @@
#include "JumpCenterPoint.h"
#include "tools/Timer.h"
#include "JumpPlatform.h"
+#include <list>
+
namespace orxonox
{
@@ -48,15 +50,18 @@
{
public:
Jump(Context* context);
-
- //virtual void start();
+ virtual void start();
//virtual void end();
//virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
+ virtual void tick(float dt);
+
//void spawnEnemy();
void setCenterpoint(JumpCenterPoint* center){ this->center_ = center; }
+ virtual void addPlatform(float x, float y);
+
/*int getLives(){return this->lives;}
int getLevel(){return this->level;}
int getPoints(){return this->point;}
@@ -67,7 +72,6 @@
void addPoints(int numPoints);
// checks if multiplier should be reset.
void comboControll();*/
- void init();
//int lives;
//int multiplier;
//bool bEndGame;
@@ -77,6 +81,7 @@
WeakPtr<JumpShip> getPlayer();
WeakPtr<JumpCenterPoint> center_;
WeakPtr<JumpShip> player;
+ WeakPtr<Camera> camera;
/*Timer enemySpawnTimer;
Timer comboTimer;
@@ -85,6 +90,9 @@
int level;
int point;
bool b_combo;*/
+ std::list<JumpPlatform*> platformList;
+ float yScreenPosition;
+ float screenShiftSinceLastUpdate;
};
}
Modified: code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc 2014-04-11 10:07:05 UTC (rev 10032)
@@ -50,19 +50,25 @@
model = new Model(getContext());
model->setSyncMode(0);
- model->setMeshSource("drone.mesh");
+ model->setMeshSource("Platform01.mesh");
- movableEntity = new MovableEntity(getContext());
- movableEntity->attach(model);
+ attach(model);
+ setScale(5);
+ setPosition(Vector3(0,0,0));
+ setVelocity(Vector3(0,0,0));
- movableEntity->setScale(100);
- //movableEntity->setPosition(Vector3(0,0,0));
- //movableEntity->setVelocity(Vector3(0,0,1));
+ }
+ void JumpPlatform::tick(float dt)
+ {
+ //setAngularVelocity(getAngularVelocity() + Vector3(0.05,0,0));
+ /*Vector3 movement(0,0,0);
+ Vector3 shipPosition = getPosition();*/
- }
+ SUPER(JumpPlatform, tick, dt);
+ }
}
Modified: code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h 2014-04-11 10:07:05 UTC (rev 10032)
@@ -44,12 +44,10 @@
{
public:
JumpPlatform(Context* context);
+ virtual void tick(float dt);
-
private:
Model* model;
- MovableEntity* movableEntity;
-
};
}
Modified: code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h 2014-04-11 10:07:05 UTC (rev 10032)
@@ -70,6 +70,7 @@
class Jump;
class JumpCenterPoint;
class JumpShip;
+ class JumpPlatform;
class JumpEnemy;
class JumpEnemyShooter;
class JumpWeapon;
Modified: code/branches/pickupsFS14/src/modules/jump/JumpShip.cc
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/JumpShip.cc 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/JumpShip.cc 2014-04-11 10:07:05 UTC (rev 10032)
@@ -52,74 +52,16 @@
rightPressed = false;
upPressed = false;
downPressed = false;
-
- yScreenPosition = 0;
yVelocity = 0;
}
void JumpShip::tick(float dt)
{
+
+
Vector3 movement(0,0,0);
Vector3 shipPosition = getPosition();
- /*
- //Movement calculation
- lastTimeFront += dt * damping;
- lastTimeLeft += dt * damping;
- lastTime += dt;
-
- velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
- velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
-
- //Execute movement
- if (this->hasLocalController())
- {
- float dist_y = velocity.y * dt;
- float dist_x = velocity.x * dt;
- if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
- posforeward += dist_y;
- else
- {
- velocity.y = 0;
- // restart if game ended
- if (getGame())
- if (getGame()->bEndGame)
- {
- getGame()->start();
- return;
- }
- }
- if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
- velocity.x = 0;
- pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
-
- }
-
- // shoot!
- if (isFireing)
- ControllableEntity::fire(0);
- */
- // Camera
-
-
-
-
- /*
- // bring back on track!
- if(pos.y != 0)
- pos.y = 0;
-
- setPosition(pos);
- setOrientation(Vector3::UNIT_Y, Degree(270));
-
- // Level up!
- if (pos.x > 42000)
- {
- updateLevel();
- setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
- }
- */
-
// Berechne Bewegung anhand der Eingabe
if (leftPressed == true)
{
@@ -140,11 +82,6 @@
}
else if (downPressed == true)
{
- platform = new JumpPlatform(getContext());
- platform->setPosition(Vector3(0, 0, 0));
- platform->setVelocity(Vector3(0, 0, 0));
- platform->setScale(100);
-
movement -= Vector3(0, 0, 0);
downPressed = false;
}
@@ -161,25 +98,7 @@
setPosition(shipPosition);
- // Bildschirmposition kann nur nach oben verschoben werden
- if (shipPosition.y > yScreenPosition)
- {
- yScreenPosition = shipPosition.y;
- }
-
- // Kameraposition nachfuehren
- if (camera == NULL)
- {
- camera = getCamera();
- }
- if (camera != NULL)
- {
-
- camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100));
- //camera->setOrientation(Vector3::UNIT_Z, Degree(180));
- }
-
- SUPER(JumpShip, tick, dt);
+ SUPER(JumpShip, tick, dt);
}
/*
void JumpShip::updateLevel()
Modified: code/branches/pickupsFS14/src/modules/jump/JumpShip.h
===================================================================
--- code/branches/pickupsFS14/src/modules/jump/JumpShip.h 2014-04-10 14:06:03 UTC (rev 10031)
+++ code/branches/pickupsFS14/src/modules/jump/JumpShip.h 2014-04-11 10:07:05 UTC (rev 10032)
@@ -72,7 +72,6 @@
private:
WeakPtr<Jump> getGame();
WeakPtr<Jump> game;
- WeakPtr<Camera> camera;
const float xVelocity = 150.0f;
const float xBoundary = 200.0f;
@@ -99,12 +98,9 @@
bool upPressed;
bool downPressed;
- float yScreenPosition;
float yVelocity;
const float yAcceleration = 10.0f;
const float ySpeedAfterJump = 300.0f;
-
- JumpPlatform* platform;
};
}
More information about the Orxonox-commit
mailing list