[Orxonox-commit 5112] r9777 - in code/branches/invaders: data/levels data/levels/templates src/modules/invader
zifloria at orxonox.net
zifloria at orxonox.net
Mon Nov 11 16:01:44 CET 2013
Author: zifloria
Date: 2013-11-11 16:01:44 +0100 (Mon, 11 Nov 2013)
New Revision: 9777
Added:
code/branches/invaders/data/levels/templates/enemyInvader.oxt
code/branches/invaders/src/modules/invader/InvaderEnemy
Modified:
code/branches/invaders/data/levels/Invaders.oxw
code/branches/invaders/src/modules/invader/CMakeLists.txt
code/branches/invaders/src/modules/invader/Invader.cc
code/branches/invaders/src/modules/invader/Invader.h
code/branches/invaders/src/modules/invader/InvaderPrereqs.h
code/branches/invaders/src/modules/invader/InvaderShip.cc
code/branches/invaders/src/modules/invader/InvaderShip.h
Log:
enemies
Modified: code/branches/invaders/data/levels/Invaders.oxw
===================================================================
--- code/branches/invaders/data/levels/Invaders.oxw 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/data/levels/Invaders.oxw 2013-11-11 15:01:44 UTC (rev 9777)
@@ -15,6 +15,7 @@
include("templates/spaceshipAssff2.oxt")
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipInvader.oxt")
+ include("templates/enemyInvader.oxt")
?>
<Level gametype = Invader>
@@ -54,18 +55,17 @@
<InvaderCenterPoint name=invadercenter />
<?lua
- for i = 1, 250, 1
- do
- j = math.random()
+ for i = 1, 300, 1 do
+ j = math.random()
?>
<MovableEntity
- position = "<?lua print(math.random()* 15000 - 1000) ?>,-1000,<?lua print(math.random() * 12000 - 4000) ?>"
+ position = "<?lua print(math.random()* 30000 - 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
collisionType = dynamic
linearDamping = 0.8
angularDamping = 0
scale = "<?lua print(j * 150)?>"
- collisiondamage = 1
+ collisiondamage = 0
enablecollisiondamage = true
>
<attached>
Added: code/branches/invaders/data/levels/templates/enemyInvader.oxt
===================================================================
--- code/branches/invaders/data/levels/templates/enemyInvader.oxt (rev 0)
+++ code/branches/invaders/data/levels/templates/enemyInvader.oxt 2013-11-11 15:01:44 UTC (rev 9777)
@@ -0,0 +1,113 @@
+<Template name=enemyinvader>
+ <InvaderShip
+ hudtemplate = spaceshiphud
+ camerapositiontemplate = spaceshipescortcameras
+ spawnparticlesource = "Orxonox/fairytwirl"
+ spawnparticleduration = 3
+ explosionchunks = 4
+
+ health = 1
+ maxhealth = 1
+ initialhealth = 1
+
+ shieldhealth = 35
+ initialshieldhealth = 35
+ maxshieldhealth = 60
+ shieldabsorption = 0.9
+ reloadrate = 1
+ reloadwaittime = 1
+
+ primaryThrust = 150
+ auxilaryThrust = 30
+ rotationThrust = 50
+
+ lift = 1;
+ stallSpeed = 220;
+
+ boostPower = 20
+ boostPowerRate = 1
+ boostRate = 5
+ boostCooldownDuration = 10
+
+ shakeFrequency = 15
+ shakeAmplitude = 6
+
+ collisionType = "dynamic"
+ mass = 0.00001
+ linearDamping = 0
+ angularDamping = 0
+ >
+ <engines>
+ <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
+ <MultiStateEngine position="-7.6, 0, 0" template=spaceshipescortengine />
+ </engines>
+ <attached>
+ <Model position="0,0,0" yaw=90 pitch=0 roll=0 scale=8 mesh="escortShip.mesh" />
+ <Model position="0,0,0" yaw=180 pitch=90 roll=0 scale=8 mesh="escortWeapon.mesh" />
+<!--Model mesh="cube.mesh" mass=10 position="0,0,3" scale3D="10,4,8" />
+<Model mesh="cube.mesh" mass=10 position="12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="-12.6,-2,3" scale3D="2.8,2.8,11" />
+<Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
+ </attached>
+ <collisionShapes>
+ <BoxCollisionShape position="0 ,0 , 3" halfExtents="10, 4,8" />
+ <BoxCollisionShape position="12.6 ,-2, 3" halfExtents="2.8,2.8,11"/>
+ <BoxCollisionShape position="-12.6,-2, 3" halfExtents="2.8,2.8,11"/>
+ <BoxCollisionShape position="0, 0,-12" halfExtents="4 , 4 ,7" />
+ </collisionShapes>
+<?lua
+ include("../includes/invaderWeapon.oxi")
+?>
+ </InvaderShip>
+</Template>
+
+<Template name=spaceshipescortcameras defaults=0>
+ <InvaderShip>
+ <camerapositions>
+<!-- <CameraPosition position="0,15, 60" drag=true mouselook=true />
+ <CameraPosition position="0,20, 90" drag=true mouselook=true />
+ <CameraPosition position="0,30,120" drag=true mouselook=true /> -->
+ <CameraPosition position="0,300,-100" direction="0, -1, 0" drag=false mouselook=true />
+ </camerapositions>
+ </InvaderShip>
+</Template>
+
+<Template name=spaceshipescortengine baseclass=MultiStateEngine>
+ <MultiStateEngine
+ boostfactor = 2.2
+
+ speedfront = 200
+ speedback = 70
+ speedleftright = 70
+ speedupdown = 70
+
+ defEngineSndNormal = "sounds/Engine_low.ogg"
+ defEngineSndBoost = "sounds/Engine_high.ogg"
+
+ accelerationfront = 700
+ accelerationbrake = 700
+ accelerationback = 125
+ accelerationleftright = 125
+ accelerationupdown = 125
+ >
+ <EffectContainer condition="idle">
+ <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/>
+ </EffectContainer>
+ <EffectContainer condition="not idle">
+ <FadingBillboard mainstate=activity active=false scale=0.09 position="12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ <FadingBillboard mainstate=activity active=false scale=0.09 position="-12, -2, 13" colour="0.2, 1.0, 0.65, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
+ </EffectContainer>
+ <EffectContainer condition="normal or brake">
+
+ </EffectContainer>
+ <EffectContainer condition="normal or boost">
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.2, 1.0, 0.65, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ </EffectContainer>
+ <EffectContainer condition="boost">
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position=" 12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <Backlight mainstate=activity active=false scale=0.33 name=bltest position="-12, 0, 10" colour="0.6, 0.8, 0.75, 0.7" width=25 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ </EffectContainer>
+
+ </MultiStateEngine>
+</Template>
Modified: code/branches/invaders/src/modules/invader/CMakeLists.txt
===================================================================
--- code/branches/invaders/src/modules/invader/CMakeLists.txt 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/CMakeLists.txt 2013-11-11 15:01:44 UTC (rev 9777)
@@ -3,6 +3,7 @@
Invader.cc
InvaderCenterPoint.cc
InvaderShip.cc
+ InvaderEnemy.cc
InvaderWeapon.cc
END_BUILD_UNIT
)
Modified: code/branches/invaders/src/modules/invader/Invader.cc
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.cc 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/Invader.cc 2013-11-11 15:01:44 UTC (rev 9777)
@@ -41,12 +41,14 @@
#include "gamestates/GSLevel.h"
#include "chat/ChatManager.h"
-#include "InvaderShip.h"
// ! HACK
#include "infos/PlayerInfo.h"
#include "InvaderCenterPoint.h"
+#include "InvaderShip.h"
+#include "core/command/ConsoleCommand.h"
+
namespace orxonox
{
RegisterUnloadableClass(Invader);
@@ -54,15 +56,34 @@
Invader::Invader(Context* context) : Deathmatch(context)
{
RegisterObject(Invader);
+ this->center_ = 0;
- this->center_ = 0;
+ this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
//this->context = context;
+
+ enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
}
Invader::~Invader()
{
}
+ void Invader::spawnEnemy()
+ {
+ if (player == NULL)
+ {
+ for (ObjectList<InvaderShip>::iterator it = ObjectList<InvaderShip>::begin(); it != ObjectList<InvaderShip>::end(); ++it)
+ player = *it;
+ }
+ if (player == NULL)
+ return;
+
+ Pawn* newPawn = new Pawn(this->center_->getContext());
+ newPawn->addTemplate("enemyinvader");
+
+ newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0));
+ }
+
// inject custom player controller
/** void Invader::spawnPlayer(PlayerInfo* player)
{
Modified: code/branches/invaders/src/modules/invader/Invader.h
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.h 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/Invader.h 2013-11-11 15:01:44 UTC (rev 9777)
@@ -41,6 +41,8 @@
#include "InvaderCenterPoint.h"
+#include "tools/Timer.h"
+
namespace orxonox
{
@@ -55,10 +57,17 @@
//virtual void spawnPlayer(PlayerInfo* player); //!< Spawns the input player.
+ void spawnEnemy();
+
void setCenterpoint(InvaderCenterPoint* center)
{ this->center_ = center; }
private:
WeakPtr<InvaderCenterPoint> center_;
+ InvaderShip * player;
+
+ ConsoleCommand* console_addEnemy;
+
+ Timer enemySpawnTimer;
//Context* context;
};
}
Added: code/branches/invaders/src/modules/invader/InvaderEnemy
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy 2013-11-11 15:01:44 UTC (rev 9777)
@@ -0,0 +1,65 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Florian Zinggeler
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file InvaderEnemy.h
+ @brief Declaration of the InvaderEnemy class.
+*/
+
+#ifndef _InvaderEnemy_H__
+#define _InvaderEnemy_H__
+
+#include "invader/InvaderPrereqs.h"
+
+#include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+ class _InvaderExport InvaderEnemy : public SpaceShip
+ {
+ public:
+ InvaderEnemy(Context* context); //!< Constructor. Registers and initializes the object.
+ virtual ~InvaderEnemy() {}
+
+ virtual void tick(float dt);
+
+ private:
+ Camera* camera;
+ bool isFireing;
+ float speed, damping;
+ float lastTimeFront, lastTimeLeft;
+ struct Velocity
+ {
+ float x;
+ float y;
+ } velocity, desiredVelocity;
+
+ };
+}
+
+#endif /* _InvaderEnemy_H__ */
Modified: code/branches/invaders/src/modules/invader/InvaderPrereqs.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderPrereqs.h 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/InvaderPrereqs.h 2013-11-11 15:01:44 UTC (rev 9777)
@@ -70,6 +70,7 @@
class Invader;
class InvaderCenterPoint;
class InvaderShip;
+ class InvaderEnemy;
class InvaderWeapon;
}
Modified: code/branches/invaders/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-11 15:01:44 UTC (rev 9777)
@@ -51,7 +51,6 @@
speed = 500;
isFireing = false;
damping = 10;
-
}
void InvaderShip::tick(float dt)
@@ -74,13 +73,26 @@
if (isFireing)
ControllableEntity::fire(0);
+ if (getPosition().x > 30000)
+ {
+ //level++
+ setPosition(getPosition() - Vector3(30000, 0, 0));
+ }
+ // if ((int(getPosition().x) % 1000) < 5)
+ // {
+ // for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
+ // it->spawnEnemy();
+ // }
+
// camera->setOrientation(Vector3::UNIT_X, Degree(0));
SUPER(InvaderShip, tick, dt);
}
+
+
void InvaderShip::moveFrontBack(const Vector2& value)
{
// orxout(internal_error) << "move backfront" << value.x << value.y << endl;
Modified: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-11 14:55:34 UTC (rev 9776)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-11 15:01:44 UTC (rev 9777)
@@ -58,6 +58,8 @@
virtual void rotateYaw(const Vector2& value){};
virtual void rotatePitch(const Vector2& value){};
virtual void rotateRoll(const Vector2& value){};
+
+ // *InvaderShip getShip(){return this;}
private:
Camera* camera;
bool isFireing;
More information about the Orxonox-commit
mailing list