[Orxonox-commit 5163] r9828 - in code/branches/invaders: data/levels data/levels/templates data/overlays src/modules/invader
zifloria at orxonox.net
zifloria at orxonox.net
Mon Nov 25 17:35:30 CET 2013
Author: zifloria
Date: 2013-11-25 17:35:30 +0100 (Mon, 25 Nov 2013)
New Revision: 9828
Added:
code/branches/invaders/data/overlays/InvaderHUD.oxo
code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
code/branches/invaders/src/modules/invader/InvaderHUDinfo.h
Modified:
code/branches/invaders/data/levels/Invaders.oxw
code/branches/invaders/data/levels/templates/enemyInvader.oxt
code/branches/invaders/data/levels/templates/spaceshipInvader.oxt
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/InvaderEnemy.cc
code/branches/invaders/src/modules/invader/InvaderEnemy.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:
HUD + take damage
Modified: code/branches/invaders/data/levels/Invaders.oxw
===================================================================
--- code/branches/invaders/data/levels/Invaders.oxw 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/data/levels/Invaders.oxw 2013-11-25 16:35:30 UTC (rev 9828)
@@ -4,10 +4,9 @@
tags = "test"
screenshot = "emptylevel.png"
/>
-
+<!-- include("HUDTemplates3.oxo") -->
<?lua
include("stats.oxo")
- include("HUDTemplates3.oxo")
include("templates/lodInformation.oxt")
?>
@@ -16,6 +15,7 @@
include("templates/spaceshipPirate.oxt")
include("templates/spaceshipInvader.oxt")
include("templates/enemyInvader.oxt")
+ include("overlays/InvaderHUD.oxo")
?>
<Level gametype = Invader>
@@ -60,7 +60,7 @@
?>
<MovableEntity
- position = "<?lua print(math.random()* 30000 - 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
+ position = "<?lua print(math.random()* 40000 + 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
collisionType = dynamic
linearDamping = 0.8
angularDamping = 0
Modified: code/branches/invaders/data/levels/templates/enemyInvader.oxt
===================================================================
--- code/branches/invaders/data/levels/templates/enemyInvader.oxt 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/data/levels/templates/enemyInvader.oxt 2013-11-25 16:35:30 UTC (rev 9828)
@@ -33,7 +33,7 @@
shakeAmplitude = 6
collisionType = "dynamic"
- mass = 5
+ mass = 0.00001
linearDamping = 0
angularDamping = 0
Modified: code/branches/invaders/data/levels/templates/spaceshipInvader.oxt
===================================================================
--- code/branches/invaders/data/levels/templates/spaceshipInvader.oxt 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/data/levels/templates/spaceshipInvader.oxt 2013-11-25 16:35:30 UTC (rev 9828)
@@ -33,9 +33,12 @@
shakeAmplitude = 6
collisionType = "dynamic"
- mass = 80
+ mass = 4200000
linearDamping = 0.7
angularDamping = 0.9999999
+
+ collisiondamage = 100
+ enablecollisiondamage = true
>
<engines>
<MultiStateEngine position=" 7.6, 0, 6" template=spaceshipescortengine />
Added: code/branches/invaders/data/overlays/InvaderHUD.oxo
===================================================================
--- code/branches/invaders/data/overlays/InvaderHUD.oxo (rev 0)
+++ code/branches/invaders/data/overlays/InvaderHUD.oxo 2013-11-25 16:35:30 UTC (rev 9828)
@@ -0,0 +1,97 @@
+<Template name="InvaderHUD">
+ <OverlayGroup name="InvaderHUD" scale = "1, 1">
+ <InvaderHUDinfo
+ position = "0.14, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ showlives = true
+ showlevel = false
+ showpoints = false
+ />
+ <OverlayText
+ position = "0.02, 0.02"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Lives: "
+ />
+
+ <OverlayText
+ position = "0.02, 0.055"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Players: "
+ />
+
+ <InvaderHUDinfo
+ position = "0.14, 0.055"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ showlives = false
+ showlevel = true
+ showpoints = false
+ />
+
+ <OverlayText
+ position = "0.02, 0.1"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+ caption = "Points: "
+ />
+
+ <InvaderHUDinfo
+ position = "0.14, 0.1"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ showlives = false
+ showlevel = false
+ showpoints = true
+ />
+ </OverlayGroup>
+</Template>
+
+
+<Template name="spaceshiphud">
+ <OverlayGroup name = "spaceshiphud" scale = "1, 1">
+ <HUDHealthBar
+ name = "HealthBar1"
+ background = "Orxonox/HealthBarBackground"
+ size = "0.35, 0.0875"
+ position = "0.0 , 0.9 "
+ pickpoint = "0, 1"
+ bartexture = "healthbar_bar.png"
+ textfont = "VeraMono"
+ textusebarcolour = true
+ textsize = 0.039
+ textoffset = "0.315, 0.05"
+ textpickpoint = "0, 0"
+ textalign = "right"
+ correctaspect = false
+ textcorrectaspect = false
+ >
+ <BarColour position = 0.0 colour = "0.7,0.2,0.2" />
+ <BarColour position = 0.5 colour = "0.7,0.7,0.2" />
+ <BarColour position = 1.0 colour = "0.2,0.7,0.2" />
+ </HUDHealthBar>
+ </OverlayGroup>
+</Template>
\ No newline at end of file
Modified: code/branches/invaders/src/modules/invader/CMakeLists.txt
===================================================================
--- code/branches/invaders/src/modules/invader/CMakeLists.txt 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/CMakeLists.txt 2013-11-25 16:35:30 UTC (rev 9828)
@@ -5,6 +5,7 @@
InvaderShip.cc
InvaderEnemy.cc
InvaderWeapon.cc
+ InvaderHUDinfo.cc
END_BUILD_UNIT
)
Modified: code/branches/invaders/src/modules/invader/Invader.cc
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.cc 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/Invader.cc 2013-11-25 16:35:30 UTC (rev 9828)
@@ -61,6 +61,7 @@
this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
//this->context = context;
+ this->setHUDTemplate("InvaderHUD");
enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
}
@@ -82,7 +83,7 @@
InvaderEnemy* newPawn = new InvaderEnemy(this->center_->getContext());
newPawn->addTemplate("enemyinvader");
- newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0));
+ newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0)); // BUG:
}
// inject custom player controller
Modified: code/branches/invaders/src/modules/invader/Invader.h
===================================================================
--- code/branches/invaders/src/modules/invader/Invader.h 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/Invader.h 2013-11-25 16:35:30 UTC (rev 9828)
@@ -61,14 +61,20 @@
void setCenterpoint(InvaderCenterPoint* center)
{ this->center_ = center; }
+
+ int getLives(){return this->lives;}
+ int getLevel(){return this->level;}
+ int getPoints(){return this->point;}
private:
WeakPtr<InvaderCenterPoint> center_;
- InvaderShip * player;
+ WeakPtr<InvaderShip> player;
ConsoleCommand* console_addEnemy;
-
Timer enemySpawnTimer;
//Context* context;
+ int lives;
+ int level;
+ int point;
};
}
Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.cc 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.cc 2013-11-25 16:35:30 UTC (rev 9828)
@@ -42,10 +42,19 @@
InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
{
RegisterObject(InvaderEnemy);
+ enableCollisionCallback();
}
void InvaderEnemy::tick(float dt)
{
SUPER(InvaderEnemy, tick, dt);
}
+
+ inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ orxout() << "sadsadasfasf" << endl;
+ removeHealth(2000);
+ setVelocity(Vector3(0,0,1000));
+ return false;
+ }
}
\ No newline at end of file
Modified: code/branches/invaders/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderEnemy.h 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/InvaderEnemy.h 2013-11-25 16:35:30 UTC (rev 9828)
@@ -47,6 +47,7 @@
// virtual ~InvaderEnemy() {}
virtual void tick(float dt);
+ virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
private:
Camera* camera;
Added: code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderHUDinfo.cc 2013-11-25 16:35:30 UTC (rev 9828)
@@ -0,0 +1,98 @@
+/*
+ * 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
+ *
+ */
+
+#include "InvaderHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+// #include "Invader.h"
+
+namespace orxonox
+{
+ RegisterClass(InvaderHUDinfo);
+
+ InvaderHUDinfo::InvaderHUDinfo(Context* context) : OverlayText(context)
+ {
+ RegisterObject(InvaderHUDinfo);
+
+ this->InvaderGame = 0;
+ this->bShowLives_ = false;
+ this->bShowLevel_ = false;
+ this->bShowPoints_ = false;
+ }
+
+ InvaderHUDinfo::~InvaderHUDinfo()
+ {
+ }
+
+ void InvaderHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(InvaderHUDinfo, XMLPort, xmlelement, mode);
+
+ XMLPortParam(InvaderHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false);
+ XMLPortParam(InvaderHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false);
+ XMLPortParam(InvaderHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false);
+ }
+
+ void InvaderHUDinfo::tick(float dt)
+ {
+ SUPER(InvaderHUDinfo, tick, dt);
+
+ if (this->InvaderGame)
+ {
+ if (this->bShowLives_)
+ {
+ const std::string& lives = multi_cast<std::string>(this->InvaderGame->getLives());
+ this->setCaption(lives);
+ }
+ else if(this->bShowLevel_)
+ {
+ const std::string& Level = multi_cast<std::string>(this->InvaderGame->getLevel());
+ this->setCaption(Level);
+ }
+ else if(this->bShowPoints_)
+ {
+ const std::string& points = multi_cast<std::string>(this->InvaderGame->getPoints());
+ this->setCaption(points);
+ }
+ }
+ }
+
+ void InvaderHUDinfo::changedOwner()
+ {
+ SUPER(InvaderHUDinfo, changedOwner);
+
+ if (this->getOwner() && this->getOwner()->getGametype())
+ {
+ this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
+ }
+ else
+ {
+ this->InvaderGame = 0;
+ }
+ }
+}
Added: code/branches/invaders/src/modules/invader/InvaderHUDinfo.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderHUDinfo.h (rev 0)
+++ code/branches/invaders/src/modules/invader/InvaderHUDinfo.h 2013-11-25 16:35:30 UTC (rev 9828)
@@ -0,0 +1,69 @@
+/*
+ * 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
+ *
+ */
+
+#ifndef _InvaderHUDinfo_H__
+#define _InvaderHUDinfo_H__
+
+#include "overlays/OverlaysPrereqs.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+
+namespace orxonox
+{
+ class _OverlaysExport InvaderHUDinfo : public OverlayText, public Tickable
+ {
+ public:
+ InvaderHUDinfo(Context* context);
+ virtual ~InvaderHUDinfo();
+
+ virtual void tick(float dt);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedOwner();
+
+ inline void setShowLives(bool value)
+ { this->bShowLives_ = value; }
+ inline bool getShowLives() const
+ { return this->bShowLives_; }
+
+ inline void setShowLevel(bool value)
+ { this->bShowLevel_ = value; }
+ inline bool getShowLevel() const
+ { return this->bShowLevel_; }
+
+ inline void setShowPoints(bool value)
+ { this->bShowPoints_ = value; }
+ inline bool getShowPoints() const
+ { return this->bShowPoints_; }
+
+ private:
+ Invader* InvaderGame;
+ bool bShowLives_;
+ bool bShowLevel_;
+ bool bShowPoints_;
+ };
+}
+#endif /* _InvaderHUDinfo_H__ */
Modified: code/branches/invaders/src/modules/invader/InvaderPrereqs.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderPrereqs.h 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/InvaderPrereqs.h 2013-11-25 16:35:30 UTC (rev 9828)
@@ -72,6 +72,7 @@
class InvaderShip;
class InvaderEnemy;
class InvaderWeapon;
+ class InvaderHUDinfo;
}
#endif /* _InvaderPrereqs_H__ */
Modified: code/branches/invaders/src/modules/invader/InvaderShip.cc
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/InvaderShip.cc 2013-11-25 16:35:30 UTC (rev 9828)
@@ -69,10 +69,13 @@
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;
+ if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
+ velocity.x = 0;
// this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x));
pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
}
@@ -92,31 +95,22 @@
// 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.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)
- // {
- // 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)
setPosition(pos);
setOrientation(Vector3::UNIT_Y, Degree(270));
// Level up!
- if (pos.x > 30000)
+ if (pos.x > 42000)
{
updateLevel();
- setPosition(Vector3(0, 0, 0)); // pos - Vector3(30000, 0, 0)
+ setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
}
SUPER(InvaderShip, tick, dt);
@@ -143,4 +137,23 @@
{
isFireing = bBoost;
}
+ inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
+ {
+ // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
+
+ WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+ if (enemy != NULL && lastEnemy != enemy)
+ {
+ lastEnemy = enemy;
+ orxout() << "Enemy!!!! " << endl;
+ removeHealth(20);
+ if (getHealth() <= 0)
+ {
+ orxout() << "DIED!!!! " << endl;
+ }
+ return false;
+ }
+ return false;
+ // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
+ }
}
Modified: code/branches/invaders/src/modules/invader/InvaderShip.h
===================================================================
--- code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-25 16:27:23 UTC (rev 9827)
+++ code/branches/invaders/src/modules/invader/InvaderShip.h 2013-11-25 16:35:30 UTC (rev 9828)
@@ -62,6 +62,7 @@
virtual void updateLevel();
// *InvaderShip getShip(){return this;}
+ virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
private:
Camera* camera;
bool isFireing;
@@ -73,6 +74,8 @@
float y;
} velocity, desiredVelocity;
+ WeakPtr<InvaderEnemy> lastEnemy;
+
};
}
More information about the Orxonox-commit
mailing list