[Orxonox-commit 4441] r9112 - in code/branches/newlevel2012: data/levels src/modules/towerdefense
jo at orxonox.net
jo at orxonox.net
Sat Apr 21 23:47:19 CEST 2012
Author: jo
Date: 2012-04-21 23:47:19 +0200 (Sat, 21 Apr 2012)
New Revision: 9112
Modified:
code/branches/newlevel2012/data/levels/towerDefense.oxw
code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h
Log:
Created minimal working version for the TowerDefence module. The code compiles and the level runs. Unfortunately an 'Playfield_ME.mesh' cannot be loaded on my machine.
Modified: code/branches/newlevel2012/data/levels/towerDefense.oxw
===================================================================
--- code/branches/newlevel2012/data/levels/towerDefense.oxw 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/data/levels/towerDefense.oxw 2012-04-21 21:47:19 UTC (rev 9112)
@@ -1,7 +1,8 @@
+<!-- TODO: Update the level's image-->
<LevelInfo
name = "Tower Defense"
- description = "A level with not much in it."
- tags = "test"
+ description = "Defend your Spacestation from incoming waves."
+ tags = "gametype"
screenshot = "emptylevel.png"
/>
@@ -11,64 +12,43 @@
include("templates/lodInformation.oxt")
?>
+<?lua
+ include("templates/spaceshipAssff.oxt")
+ include("templates/spaceshipPirate.oxt")
+?>
+
+<!-- Hallo erstmal.
+Ich habe das Grundgerüst des Levels mal zum Laufen gebracht.
+Bei mir hat es das Playfield_ME.mesh allerdings nicht angezeigt; deswegen habe ich mit dem crate.mesh als testobjekt gearbeitet.
+Das Level macht genau das was ihr vermutlich erreichen wolltet. Wahrscheinlich wird die Funktionalität der "statischen Kamera" aber
+bloß in einer abgewandelten Art umgesetzt: In Pong und Tetris sind die Kameras nicht an das Spielfeld, sondern an ein ControllableEntity,
+das vom Spieler gesteuert wird gekoppelt.
+-->
+
<!-- Specify the position of the camera -->
<Template name=playfieldcameras defaults=0>
- <ControllableEntity>
+ <Pawn>
<camerapositions>
- <CameraPosition position="0,30,0" pitch=-90 absolute=true />
+ <CameraPosition position="-200,0,600" absolute=true />
</camerapositions>
- </ControllableEntity>
+ </Pawn>
</Template>
<!-- Loads the playfield mesh -->
+<!-- TODO: why don't you add Playfield_ME.mesh to the data repository ? : /orxonox/data_extern/models -->
+
<Template name=playfield>
- <ControllableEntity camerapositiontemplate=playfieldcameras>
+ <Pawn camerapositiontemplate=playfieldcameras>
<attached>
- <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
+ <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" /> <!-- crate.mesh -->
</attached>
- </ControllableEntity>
+ </Pawn>
</Template>
-<Level gametype = "Deathmatch">
- <templates>
- <Template link=lodtemplate_default />
- </templates>
-
- <?lua include("includes/notifications.oxi") ?>
- <Scene
- ambientlight = "0.5, 0.5, 0.5"
- skybox = "Orxonox/skypanoramagen1"
- >
-
- <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" />
- <SpawnPoint spawnclass=SpaceShip pawndesign=playfield position="0, 10, 0" orientation="0, 0, 0" />
-<!--
- <MovableEntity rotationrate=5 rotationaxis="0,0,1">
- <attached>
- <!-- template wird im centerpoint verwendet (glaub?) -->
-<!--
- <TowerDefenseCenterpoint
- name=towerdefensecenter
- dimension="200,120"
- >
-
- <!--
- hier fehlt noch was:
- balltemplate=pongball
- -->
-<!--
- </PongCenterpoint>
- </attached>
- </MovableEntity>
- -->
-
- </Scene>
-</Level>
-<!--
<Level gametype = "TowerDefense">
<templates>
<Template link=lodtemplate_default />
@@ -82,18 +62,16 @@
>
<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"/>
-
-
- <StaticEntity position="0,0,0" direction="0,0,0" collistionType=static mass=100000>
- <attached>
- <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
- </attached>
- </StaticEntity>
+ <!--SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
+ <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=Pawn pawndesign=playfield />
+
+ <!--StaticEntity position="0,0,0" direction="0,0,0" collistionType=static mass=100000>
+ <attached>
+ <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
+ </attached>
+ </StaticEntity-->
</Scene>
</Level>
--->
-
-
Modified: code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt 2012-04-21 21:47:19 UTC (rev 9112)
@@ -1,6 +1,6 @@
SET_SOURCE_FILES(TOWERDEFENSE_SRC_FILES
+ TowerDefense.cc
TowerDefenseCenterpoint.cc
- TowerDefense.cc
)
ORXONOX_ADD_LIBRARY(TowerDefense
Modified: code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc 2012-04-21 21:47:19 UTC (rev 9112)
@@ -1,17 +1,133 @@
/*
- * TowerDefense.cpp
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
*
- * Created on: Apr 20, 2012
- * Author: mentzerf
+ *
+ * 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:
+ *
+ * Co-authors:
+ * ...
+ *
+ *NACHRICHT:
+ * Ich habe die Klasse Deathmatch einfach per Copy&Paste&Rename als Vorlage für euren Deathmatch genommen.
+ * Ein Deathmatch erbt vom Gametype. Der einzige Unterschied zum Gametype ist, dass hier ein bisschen
+ * Textausgabe stattfindet. Sollte das Später nicht erwünscht sein, könnt ihr einfach die Gametype-Klasse
+ * an die Stelle von Deathmatch setzten.
+ *
+ * Hier empfehle ich euch die gesamte Spielogik unter zu bringen. Viele Funktionen werden automatisch
+ * bei gewissen Ereignissen aufgerufen bzw. lösen Ereignisse aus
+ *
+ *Z.B:
+ * start() //wird aufgerufen, bevor das Spiel losgeht
+ * end() //wenn man diese Funktion aufruft wird
+ * pawnKilled() // wird aufgerufen, wenn ein Pawn stirbt (z.B: wenn )
+ * playerScored() // kann man aufrufen um dem Spieler Punkte zu vergeben.
+ *
+ *
+ *
+ *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen:
+ * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter
+ * tippt, werden die Vorschläge entsprechend gefiltert.
+ *
+ *
+ *TIPP: schaut euch mal Tetris::createStone() an. Dort wird ein TetrisStone-Objekt (ControllableEntity) erzeugt,
+ * ihm ein Template zugewiesen (welches vorher im Level definiert wurde und dem CenterPoint übergeben wurde)
+ * Ähnlich könnt ihr vorgehen, um einen Turm zu erzeugen. (Zusätzlich braucht ein Turm noch einen Controller)
+ * z.B: WaypointPatrolController. Wenn kein Team zugewiesen wurde bekämpft ein WaypointPatrolController alles,
+ * was in seiner Reichweite liegt.
+ *
*/
-#include <towerdefense/TowerDefense.h>
+#include "TowerDefense.h"
-TowerDefense::TowerDefense() {
- // TODO Auto-generated constructor stub
+namespace orxonox
+{
+ CreateUnloadableFactory(TowerDefense);
-}
+ TowerDefense::TowerDefense(BaseObject* creator) : Deathmatch(creator)
+ {
+ RegisterObject(TowerDefense);
-TowerDefense::~TowerDefense() {
- // TODO Auto-generated destructor stub
+ }
+
+ void TowerDefense::start()
+ {
+ Deathmatch::start();
+ orxout()<< "This is a way to display output on the terminal." <<endl;
+ //Tipp: Fenster-Modus über die Grafikeinstellungen einstellen.
+ //(dazu den Bulletpoint 'Fullscreen' entfernen, eine kleine Auflösung auswählen und auf 'Apply' klicken.)
+ }
+ /*
+ void TowerDefense::end()
+ {
+ Deathmatch::end();
+
+ std::string message("The match has ended.");
+ ChatManager::message(message);
+ }
+
+ void TowerDefense::playerEntered(PlayerInfo* player)
+ {
+ Deathmatch::playerEntered(player);
+
+ const std::string& message = player->getName() + " entered the game";
+ ChatManager::message(message);
+ }
+
+ bool TowerDefense::playerLeft(PlayerInfo* player)
+ {
+ bool valid_player = Deathmatch::playerLeft(player);
+
+ if (valid_player)
+ {
+ const std::string& message = player->getName() + " left the game";
+ ChatManager::message(message);
+ }
+
+ return valid_player;
+ }
+
+
+ void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)
+ {
+ if (victim && victim->getPlayer())
+ {
+ std::string message;
+ if (killer)
+ {
+ if (killer->getPlayer())
+ message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
+ else
+ message = victim->getPlayer()->getName() + " was killed";
+ }
+ else
+ message = victim->getPlayer()->getName() + " died";
+
+ ChatManager::message(message);
+ }
+
+ Deathmatch::pawnKilled(victim, killer);
+ }
+
+ void TowerDefense::playerScored(PlayerInfo* player)
+ {
+ Gametype::playerScored(player);
+
+ }*/
}
Modified: code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h 2012-04-21 21:47:19 UTC (rev 9112)
@@ -1,19 +1,53 @@
/*
- * TowerDefense.h
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
*
- * Created on: Apr 20, 2012
- * Author: mentzerf
+ *
+ * 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:
+ *
+ * Co-authors:
+ * ...
+ *
*/
-#ifndef TOWERDEFENSE_H_
-#define TOWERDEFENSE_H_
+#ifndef _TowerDefense_H__
+#define _TowerDefense_H__
-#include <Gametype.h>
+#include "towerdefense/TowerDefensePrereqs.h"
+#include "gametypes/Deathmatch.h"
-class TowerDefense: public orxonox::Deathmatch {
-public:
- TowerDefense();
- virtual ~TowerDefense();
-};
+namespace orxonox
+{
+ class _OrxonoxExport TowerDefense : public Deathmatch
+ {
+ public:
+ TowerDefense(BaseObject* creator);
+ virtual ~TowerDefense() {}
-#endif /* TOWERDEFENSE_H_ */
+ virtual void start(); //<! The function is called when the gametype starts
+ /*virtual void end();
+ virtual void playerEntered(PlayerInfo* player);
+ virtual bool playerLeft(PlayerInfo* player);
+
+ virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
+ virtual void playerScored(PlayerInfo* player);*/
+ };
+}
+
+#endif /* _TowerDefense_H__ */
Modified: code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc 2012-04-21 21:47:19 UTC (rev 9112)
@@ -52,7 +52,7 @@
this->width_ = 10;
this->height_ = 11;
- this->stoneTemplate_ = "";
+ this->towerTemplate_ = "";
this->checkGametype();
}
@@ -67,7 +67,7 @@
XMLPortParam(TowerDefenseCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
- XMLPortParam(TowerDefenseCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
+ XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);
}
/**
@@ -90,8 +90,8 @@
{
if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
{
- TowerDefense* TowerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
- TowerDefenseGametype->setCenterpoint(this);
+ //TowerDefense* TowerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
+ //TowerDefenseGametype->setCenterpoint(this);
}
}
}
Modified: code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h 2012-04-20 14:47:47 UTC (rev 9111)
+++ code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h 2012-04-21 21:47:19 UTC (rev 9112)
@@ -35,7 +35,7 @@
#ifndef _TowerDefenseCenterpoint_H__
#define _TowerDefenseCenterpoint_H__
-#include "TowerDefense/TowerDefensePrereqs.h"
+#include "towerdefense/TowerDefensePrereqs.h"
#include <string>
@@ -91,21 +91,17 @@
{ return this->height_; }
/**
-
-
- /**
- * TODO; Replace stone with tower
- @brief Set the template for the stones.
- @param template The template name to be applied to each stone.
+ @brief Set the template for the towers.
+ @param template The template name to be applied to each tower.
*/
- //void setStoneTemplate(const std::string& templateName)
- // { this->stoneTemplate_ = templateName; }
+ void setTowerTemplate(const std::string& templateName)
+ { this->towerTemplate_ = templateName; }
/**
- @brief Get the template for the stones.
- @return Returns the template name to be applied to each stone.
+ @brief Get the template for the towers.
+ @return Returns the template name to be applied to each tower.
*/
- //const std::string& getStoneTemplate(void) const
- // { return this->stoneTemplate_; }
+ const std::string& getTowerTemplate(void) const
+ { return this->towerTemplate_; }
private:
@@ -113,7 +109,7 @@
unsigned int width_;
unsigned int height_;
- //std::string stoneTemplate_;
+ std::string towerTemplate_;
};
}
More information about the Orxonox-commit
mailing list