[Orxonox-commit 5128] r9793 - in code/branches/invaders: data/levels/templates src/modules/invader

zifloria at orxonox.net zifloria at orxonox.net
Mon Nov 18 19:54:33 CET 2013


Author: zifloria
Date: 2013-11-18 19:54:32 +0100 (Mon, 18 Nov 2013)
New Revision: 9793

Added:
   code/branches/invaders/src/modules/invader/InvaderEnemy.cc
   code/branches/invaders/src/modules/invader/InvaderEnemy.h
Modified:
   code/branches/invaders/data/levels/templates/enemyInvader.oxt
   code/branches/invaders/src/modules/invader/Invader.cc
   code/branches/invaders/src/modules/invader/InvaderShip.cc
   code/branches/invaders/src/modules/invader/InvaderShip.h
Log:
movement code update

Modified: code/branches/invaders/data/levels/templates/enemyInvader.oxt
===================================================================
--- code/branches/invaders/data/levels/templates/enemyInvader.oxt	2013-11-18 15:22:09 UTC (rev 9792)
+++ code/branches/invaders/data/levels/templates/enemyInvader.oxt	2013-11-18 18:54:32 UTC (rev 9793)
@@ -1,5 +1,5 @@
 <Template name=enemyinvader>
-  <InvaderShip
+  <InvaderEnemy
    hudtemplate            = spaceshiphud
    camerapositiontemplate = spaceshipescortcameras
    spawnparticlesource    = "Orxonox/fairytwirl"
@@ -33,9 +33,12 @@
    shakeAmplitude = 6
 
    collisionType     = "dynamic"
-   mass              = 0.00001
+   mass              = 5
    linearDamping     = 0
    angularDamping    = 0
+
+    collisiondamage = 100
+    enablecollisiondamage = true
   >
     <engines>
       <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
@@ -58,19 +61,19 @@
 <?lua
   include("../includes/invaderWeapon.oxi")
 ?>
-  </InvaderShip>
+  </InvaderEnemy>
 </Template>
 
-<Template name=spaceshipescortcameras defaults=0>
-  <InvaderShip>
+<!-- <Template name=spaceshipescortcameras defaults=0>
+  <InvaderEnemy>
     <camerapositions>
-<!--       <CameraPosition position="0,15, 60" drag=true mouselook=true />
+      <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,30,120" drag=true mouselook=true />
       <CameraPosition position="0,300,-100" direction="0, -1, 0" drag=false mouselook=true />
     </camerapositions>
-  </InvaderShip>
-</Template>
+  </InvaderEnemy>
+</Template> -->
 
 <Template name=spaceshipescortengine baseclass=MultiStateEngine>
   <MultiStateEngine

Modified: code/branches/invaders/src/modules/invader/Invader.cc
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.cc	2013-11-18 15:22:09 UTC (rev 9792)
+++ code/branches/invaders/src/modules/invader/Invader.cc	2013-11-18 18:54:32 UTC (rev 9793)
@@ -46,6 +46,7 @@
 
 #include "InvaderCenterPoint.h"
 #include "InvaderShip.h"
+#include "InvaderEnemy.h"
 
 #include "core/command/ConsoleCommand.h"
 
@@ -78,7 +79,7 @@
         if (player == NULL)
             return;
 
-        Pawn* newPawn = new Pawn(this->center_->getContext());
+        InvaderEnemy* newPawn = new InvaderEnemy(this->center_->getContext());
         newPawn->addTemplate("enemyinvader");
 
         newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0));

Added: code/branches/invaders/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.cc	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.cc	2013-11-18 18:54:32 UTC (rev 9793)
@@ -0,0 +1,51 @@
+/*
+ *   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.
+*/
+
+#include "invader/InvaderPrereqs.h"
+#include "InvaderEnemy.h"
+// #include "worldentities/pawns/SpaceShip.h"
+
+namespace orxonox
+{
+    RegisterClass(InvaderEnemy);
+
+    InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
+    {
+        RegisterObject(InvaderEnemy);
+    }
+
+    void InvaderEnemy::tick(float dt)
+    {
+        SUPER(InvaderEnemy, tick, dt);
+    }
+}
\ No newline at end of file

Added: code/branches/invaders/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.h	                        (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.h	2013-11-18 18:54:32 UTC (rev 9793)
@@ -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 Pawn
+    {
+        public:
+            InvaderEnemy(Context* context);
+            // 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/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc	2013-11-18 15:22:09 UTC (rev 9792)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc	2013-11-18 18:54:32 UTC (rev 9793)
@@ -55,58 +55,89 @@
 
     void InvaderShip::tick(float dt)
     {
-        // if (camera == NULL)
-        //     camera = this->getCamera();
-        // if (camera != NULL)
-        //     camera->setPosition(Vector3(0, 0, 0) + this->getWorldPosition());
+        Vector3 pos = getPosition();
 
-        if (this->hasLocalController())
-        {
-            this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); //
-            //this->setVelocity(this->getOrientation() * Vector3(1, 0, 0));
-        }
+        //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;
+            if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
+                posforeward += dist_y;
+            else
+                velocity.y = 0;
+            // this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x));
+            pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
+        }
+
         if (isFireing)
             ControllableEntity::fire(0);
 
-        if (getPosition().x > 30000)
+        // Camera
+        Camera* camera = this->getCamera();
+        if (camera != NULL)
         {
-            //level++
-            setPosition(getPosition() - Vector3(30000, 0, 0));
+            camera->setPosition(Vector3(-pos.z, -posforeward, 0));
+            camera->setOrientation(Vector3::UNIT_Z, Degree(90));
+            // orxout() << "asbhajskjasjahg" << pos << endl;
         }
 
-        // if ((int(getPosition().x) % 1000) < 5)
+
+
+        // bring back on track!
+        if (pos.z > 42*2.5)
+            pos.z = 42*2.5;
+        else if (pos.z < -42*3)
+            pos.z = -42*3;
+        if(pos.y != 0)
+            pos.y = 0;
+        // if (camera != NULL)
         // {
-        //     for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it)
-        //         it->spawnEnemy();
+        //     float x = camera->getWorldPosition().x;
+        //     if (pos.x > x + 20)
+        //         pos.x = x + 20;
+        //     else if (pos.x < x - 20)
+        //         pos.x = x - 20;
         // }
+        // if (abs(posforeward) < 20)
+            
 
-        // camera->setOrientation(Vector3::UNIT_X, Degree(0));
+        setPosition(pos);
+        setOrientation(Vector3::UNIT_Y, Degree(270));
 
+        // Level up!
+        if (pos.x > 30000)
+        {
+            updateLevel();
+            setPosition(Vector3(0, 0, 0)); // pos - Vector3(30000, 0, 0)
+        }
 
         SUPER(InvaderShip, tick, dt);
     }
 
+    void InvaderShip::updateLevel()
+    {
+        lastTime = 0;
+        //level++
+    }
 
-
     void InvaderShip::moveFrontBack(const Vector2& value)
     {
-        // orxout(internal_error) << "move backfront" << value.x << value.y << endl;
-        //velocity.y = value.y * speed * 10;
-        lastTimeFront = 0;
-        desiredVelocity.y = value.y * speed * 10;
+        lastTimeLeft = 0;
+        desiredVelocity.x = -value.x * speed;
     }
 
     void InvaderShip::moveRightLeft(const Vector2& value)
     {
-        // orxout(internal_error) << "right left front" << value.x << value.y << endl;
-        lastTimeLeft = 0;
-        desiredVelocity.x = value.x * speed;
-        // velocity.x = value.x * speed;
+        lastTimeFront = 0;
+        desiredVelocity.y = value.y * speed * 42;
     }
     void InvaderShip::boost(bool bBoost)
     {

Modified: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h	2013-11-18 15:22:09 UTC (rev 9792)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h	2013-11-18 18:54:32 UTC (rev 9793)
@@ -59,12 +59,14 @@
             virtual void rotatePitch(const Vector2& value){};
             virtual void rotateRoll(const Vector2& value){};
 
+            virtual void updateLevel();
+
             // *InvaderShip getShip(){return this;}
         private:
             Camera* camera;
             bool isFireing;
-            float speed, damping;
-            float lastTimeFront, lastTimeLeft;
+            float speed, damping, posforeward;
+            float lastTimeFront, lastTimeLeft, lastTime;
             struct Velocity
             {
                 float x;




More information about the Orxonox-commit mailing list