[Orxonox-commit 7702] r12295 - code/branches/OrxoBlox_FS19/src/modules/OrxoBlox

pomselj at orxonox.net pomselj at orxonox.net
Thu Apr 11 15:25:01 CEST 2019


Author: pomselj
Date: 2019-04-11 15:25:01 +0200 (Thu, 11 Apr 2019)
New Revision: 12295

Added:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h
Modified:
   code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
Log:
OrxoBloxCanon implemented, can shoot like Asteroid 2D Weapon

Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-11 12:22:31 UTC (rev 12294)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/CMakeLists.txt	2019-04-11 13:25:01 UTC (rev 12295)
@@ -7,6 +7,7 @@
   OrxoBloxBot.cc
   OrxoBloxCenterpoint.cc
   OrxoBloxStones.cc
+  OrxoBloxCanon.cc
 END_BUILD_UNIT
 )
 

Added: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc	                        (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.cc	2019-04-11 13:25:01 UTC (rev 12295)
@@ -0,0 +1,94 @@
+/*
+ *   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:
+ *      Viviane Yang
+ *   Co-authors:
+ *      --
+ *
+ */
+
+/**
+    @file OrxoBloxCanon.h
+    @brief Implementation of the OrxoBloxCanon class.
+*/
+
+#include "OrxoBloxCanon.h"
+
+#include "core/CoreIncludes.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+
+#include "weapons/projectiles/BallProjectile.h"
+#include "weapons/MuzzleFlash.h"
+
+namespace orxonox
+{
+    RegisterClass(OrxoBloxCanon);
+
+    OrxoBloxCanon::OrxoBloxCanon(Context* context) : HsW01(context)
+    {
+        RegisterObject(OrxoBloxCanon);
+
+
+    }
+
+    OrxoBloxCanon::~OrxoBloxCanon()
+    {
+
+    }
+
+    void OrxoBloxCanon::shot()
+    {
+        assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+
+        // Create the projectile.
+        Projectile* projectile = new BallProjectile(this->getContext());
+        Model* model = new Model(projectile->getContext());
+        model->setMeshSource(mesh_);
+        model->setCastShadows(false);
+        projectile->attach(model);
+        model->setScale(5);
+
+        //get position and orientation of the ship to know in which direction the projectile needs to fire off
+        Pawn* player = this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn();
+
+        projectile->setOrientation(player->getOrientation());
+        projectile->setPosition(player->getPosition());
+
+        //Velocity & position of the projectile must be y = 0 since the game takes place in the x-z plane
+        Vector3 muzzle2D = player->getOrientation()* WorldEntity::FRONT ;
+        muzzle2D.y = 0; 
+        projectile->setVelocity(muzzle2D * this->speed_);
+
+        projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+        projectile->setDamage(this->getDamage());
+        projectile->setShieldDamage(this->getShieldDamage());
+        projectile->setHealthDamage(this->getHealthDamage());
+
+        // Display the muzzle flash.
+        this->HsW01::muzzleflash();
+    }
+    
+}

Added: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h	                        (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/OrxoBloxCanon.h	2019-04-11 13:25:01 UTC (rev 12295)
@@ -0,0 +1,57 @@
+/*
+ *   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:
+ *      Viviane Yang
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxoBloxCanon.h
+    @brief Definition of the OrxoBloxCanon class.
+*/
+
+#ifndef _OrxoBloxCanon_H__
+#define _OrxoBloxCanon_H__
+
+#include "asteroids2D/Asteroids2DPrereqs.h"
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/weaponmodes/HsW01.h"
+#include "weapons/projectiles/BallProjectile.h"
+
+namespace orxonox
+{
+    class _OrxoBloxExport OrxoBloxCanon : public HsW01
+    {
+        public:
+            OrxoBloxCanon(Context* context);
+            virtual ~OrxoBloxCanon();
+
+        protected:
+            virtual void shot() override; //2D movement
+            WeakPtr<BallProjectile> projectile;
+    };
+}
+
+#endif /* _OrxoBloxCanon_H__ */



More information about the Orxonox-commit mailing list