Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9112


Ignore:
Timestamp:
Apr 21, 2012, 11:47:19 PM (12 years ago)
Author:
jo
Message:

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.

Location:
code/branches/newlevel2012
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/newlevel2012/data/levels/towerDefense.oxw

    r9109 r9112  
     1<!-- TODO: Update the level's image-->
    12<LevelInfo
    23 name = "Tower Defense"
    3  description = "A level with not much in it."
    4  tags = "test"
     4 description = "Defend your Spacestation from incoming waves."
     5 tags = "gametype"
    56 screenshot = "emptylevel.png"
    67/>
     
    1213?>
    1314
     15<?lua
     16  include("templates/spaceshipAssff.oxt")
     17  include("templates/spaceshipPirate.oxt")
     18?>
     19
     20<!--  Hallo erstmal.
     21Ich habe das Grundgerüst des Levels mal zum Laufen gebracht.
     22Bei mir hat es das Playfield_ME.mesh allerdings nicht angezeigt; deswegen habe ich mit dem crate.mesh als testobjekt gearbeitet.
     23Das Level macht genau das was ihr vermutlich erreichen wolltet. Wahrscheinlich wird die Funktionalität der "statischen Kamera" aber
     24bloß in einer abgewandelten Art umgesetzt: In Pong und Tetris sind die Kameras nicht an das Spielfeld, sondern an ein ControllableEntity,
     25das vom Spieler gesteuert wird gekoppelt.
     26-->
     27
    1428<!-- Specify the position of the camera -->
    1529<Template name=playfieldcameras defaults=0>
    16   <ControllableEntity>
     30  <Pawn>
    1731    <camerapositions>
    18       <CameraPosition position="0,30,0" pitch=-90 absolute=true />
     32      <CameraPosition position="-200,0,600" absolute=true />
    1933    </camerapositions>
    20   </ControllableEntity>
     34  </Pawn>
    2135</Template>
    2236
    2337<!-- Loads the playfield mesh -->
     38<!-- TODO: why don't you add Playfield_ME.mesh to the data repository ? : /orxonox/data_extern/models -->
     39
    2440<Template name=playfield>
    25   <ControllableEntity camerapositiontemplate=playfieldcameras>
     41  <Pawn camerapositiontemplate=playfieldcameras>
    2642    <attached>
    27       <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
     43      <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" /> <!-- crate.mesh -->
    2844    </attached>
    29   </ControllableEntity>
     45  </Pawn>
    3046</Template>
    3147
    32 <Level gametype = "Deathmatch">
    33   <templates>
    34     <Template link=lodtemplate_default />
    35   </templates>
    36  
    37   <?lua include("includes/notifications.oxi") ?>
    38 
    39   <Scene
    40    ambientlight = "0.5, 0.5, 0.5"
    41    skybox       = "Orxonox/skypanoramagen1"
    42   >
    43    
    44         <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" />
    45 
    46     <SpawnPoint spawnclass=SpaceShip pawndesign=playfield position="0, 10, 0" orientation="0, 0, 0" />
    47 <!--
    48     <MovableEntity rotationrate=5 rotationaxis="0,0,1">
    49       <attached>
    50                   <!-- template wird im centerpoint verwendet (glaub?) -->
    51 <!--
    52         <TowerDefenseCenterpoint
    53                         name=towerdefensecenter
    54                         dimension="200,120"
    55                         >
    56                        
    57                         <!--
    58                         hier fehlt noch was:
    59                         balltemplate=pongball
    60                         -->
    61 <!--                   
    62         </PongCenterpoint>
    63       </attached>
    64     </MovableEntity>
    65         -->
    66        
    67   </Scene>
    68 </Level>
    6948
    7049
    71 <!--
     50
     51
    7252<Level gametype = "TowerDefense">
    7353  <templates>
     
    8363
    8464    <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"/>
    85    
    86    
    87         <StaticEntity position="0,0,0" direction="0,0,0" collistionType=static mass=100000>
    88                 <attached>
    89                         <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
    90                 </attached>
    91         </StaticEntity>
     65    <!--SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
     66    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=Pawn pawndesign=playfield />
     67 
    9268
     69    <!--StaticEntity position="0,0,0" direction="0,0,0" collistionType=static mass=100000>
     70        <attached>
     71            <Model position="0,0,0" mesh="Playfield_ME.mesh" scale3D="10,10,10" />
     72        </attached>
     73    </StaticEntity-->
    9374
    9475  </Scene>
    9576</Level>
    9677
    97 -->
    98 
    99 
  • code/branches/newlevel2012/src/modules/towerdefense/CMakeLists.txt

    r9110 r9112  
    11SET_SOURCE_FILES(TOWERDEFENSE_SRC_FILES
     2  TowerDefense.cc
    23  TowerDefenseCenterpoint.cc
    3   TowerDefense.cc
    44)
    55
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc

    r9098 r9112  
    11/*
    2  * TowerDefense.cpp
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
    34 *
    4  *  Created on: Apr 20, 2012
    5  *      Author: mentzerf
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *
     24 *   Co-authors:
     25 *      ...
     26 *
     27 *NACHRICHT:
     28 * Ich habe die Klasse Deathmatch einfach per Copy&Paste&Rename als Vorlage für euren Deathmatch genommen.
     29 * Ein Deathmatch erbt vom Gametype. Der einzige Unterschied zum Gametype ist, dass hier ein bisschen
     30 * Textausgabe stattfindet. Sollte das Später nicht erwünscht sein, könnt ihr einfach die Gametype-Klasse
     31 * an die Stelle von Deathmatch setzten.
     32 *
     33 * Hier empfehle ich euch die gesamte Spielogik unter zu bringen. Viele Funktionen werden automatisch
     34 * bei gewissen Ereignissen aufgerufen bzw. lösen Ereignisse aus
     35 *
     36 *Z.B:
     37 * start() //wird aufgerufen, bevor das Spiel losgeht
     38 * end() //wenn man diese Funktion aufruft wird
     39 * pawnKilled() // wird aufgerufen, wenn ein Pawn stirbt (z.B: wenn )
     40 * playerScored() // kann man aufrufen um dem Spieler Punkte zu vergeben.
     41 *
     42 *
     43 *
     44 *TIPP: Eclipse hilft euch schnell auf bereits vorhanden Funktionen zuzugreifen:
     45 * einfach "this->" eingeben und kurz warten. Dann tauch eine Liste mit Vorschlägen auf. Wenn ihr jetzt weiter
     46 * tippt, werden die Vorschläge entsprechend gefiltert.
     47 *
     48 *
     49 *TIPP: schaut euch mal Tetris::createStone() an. Dort wird ein TetrisStone-Objekt (ControllableEntity) erzeugt,
     50 * ihm ein Template zugewiesen (welches vorher im Level definiert wurde und dem CenterPoint übergeben wurde)
     51 * Ähnlich könnt ihr vorgehen, um einen Turm zu erzeugen. (Zusätzlich braucht ein Turm noch einen Controller)
     52 * z.B: WaypointPatrolController. Wenn kein Team zugewiesen wurde bekämpft ein WaypointPatrolController alles,
     53 * was in seiner Reichweite liegt.
     54 *
    655 */
    756
    8 #include <towerdefense/TowerDefense.h>
     57#include "TowerDefense.h"
    958
    10 TowerDefense::TowerDefense() {
    11         // TODO Auto-generated constructor stub
     59namespace orxonox
     60{
     61    CreateUnloadableFactory(TowerDefense);
    1262
     63    TowerDefense::TowerDefense(BaseObject* creator) : Deathmatch(creator)
     64    {
     65        RegisterObject(TowerDefense);
     66
     67    }
     68
     69    void TowerDefense::start()
     70    {
     71        Deathmatch::start();
     72        orxout()<< "This is a way to display output on the terminal." <<endl;
     73        //Tipp: Fenster-Modus über die Grafikeinstellungen einstellen.
     74        //(dazu den Bulletpoint 'Fullscreen' entfernen, eine kleine Auflösung auswählen und auf 'Apply' klicken.)
     75    }
     76    /*
     77    void TowerDefense::end()
     78    {
     79        Deathmatch::end();
     80
     81        std::string message("The match has ended.");
     82        ChatManager::message(message);
     83    }
     84
     85    void TowerDefense::playerEntered(PlayerInfo* player)
     86    {
     87        Deathmatch::playerEntered(player);
     88
     89        const std::string& message = player->getName() + " entered the game";
     90        ChatManager::message(message);
     91    }
     92
     93    bool TowerDefense::playerLeft(PlayerInfo* player)
     94    {
     95        bool valid_player = Deathmatch::playerLeft(player);
     96
     97        if (valid_player)
     98        {
     99            const std::string& message = player->getName() + " left the game";
     100            ChatManager::message(message);
     101        }
     102
     103        return valid_player;
     104    }
     105
     106
     107    void TowerDefense::pawnKilled(Pawn* victim, Pawn* killer)
     108    {
     109        if (victim && victim->getPlayer())
     110        {
     111            std::string message;
     112            if (killer)
     113            {
     114                if (killer->getPlayer())
     115                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     116                else
     117                    message = victim->getPlayer()->getName() + " was killed";
     118            }
     119            else
     120                message = victim->getPlayer()->getName() + " died";
     121
     122            ChatManager::message(message);
     123        }
     124
     125        Deathmatch::pawnKilled(victim, killer);
     126    }
     127
     128    void TowerDefense::playerScored(PlayerInfo* player)
     129    {
     130        Gametype::playerScored(player);
     131
     132    }*/
    13133}
    14 
    15 TowerDefense::~TowerDefense() {
    16         // TODO Auto-generated destructor stub
    17 }
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h

    r9103 r9112  
    11/*
    2  * TowerDefense.h
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
    34 *
    4  *  Created on: Apr 20, 2012
    5  *      Author: mentzerf
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *
     24 *   Co-authors:
     25 *      ...
     26 *
    627 */
    728
    8 #ifndef TOWERDEFENSE_H_
    9 #define TOWERDEFENSE_H_
     29#ifndef _TowerDefense_H__
     30#define _TowerDefense_H__
    1031
    11 #include <Gametype.h>
     32#include "towerdefense/TowerDefensePrereqs.h"
     33#include "gametypes/Deathmatch.h"
    1234
    13 class TowerDefense: public orxonox::Deathmatch {
    14 public:
    15         TowerDefense();
    16         virtual ~TowerDefense();
    17 };
     35namespace orxonox
     36{
     37    class _OrxonoxExport TowerDefense : public Deathmatch
     38    {
     39        public:
     40            TowerDefense(BaseObject* creator);
     41            virtual ~TowerDefense() {}
    1842
    19 #endif /* TOWERDEFENSE_H_ */
     43            virtual void start(); //<! The function is called when the gametype starts
     44            /*virtual void end();
     45            virtual void playerEntered(PlayerInfo* player);
     46            virtual bool playerLeft(PlayerInfo* player);
     47
     48            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     49            virtual void playerScored(PlayerInfo* player);*/
     50    };
     51}
     52
     53#endif /* _TowerDefense_H__ */
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc

    r9110 r9112  
    5353        this->width_ = 10;
    5454        this->height_ = 11;
    55         this->stoneTemplate_ = "";
     55        this->towerTemplate_ = "";
    5656       
    5757        this->checkGametype();
     
    6868        XMLPortParam(TowerDefenseCenterpoint, "width", setWidth, getWidth, xmlelement, mode); // die Breite
    6969        XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, setWidth, xmlelement, mode); // die Grösse
    70         XMLPortParam(TowerDefenseCenterpoint, "stoneTemplate", setStoneTemplate, getStoneTemplate, xmlelement, mode);
     70        XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode);
    7171    }
    7272
     
    9191        if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
    9292        {
    93             TowerDefense* TowerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
    94             TowerDefenseGametype->setCenterpoint(this);
     93            //TowerDefense* TowerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
     94            //TowerDefenseGametype->setCenterpoint(this);
    9595        }
    9696    }
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h

    r9110 r9112  
    3636#define _TowerDefenseCenterpoint_H__
    3737
    38 #include "TowerDefense/TowerDefensePrereqs.h"
     38#include "towerdefense/TowerDefensePrereqs.h"
    3939
    4040#include <string>
     
    9292               
    9393            /**
    94 
    95                
     94            @brief Set the template for the towers.
     95            @param template The template name to be applied to each tower.
     96            */
     97            void setTowerTemplate(const std::string& templateName)
     98                { this->towerTemplate_ = templateName; }
    9699            /**
    97              * TODO; Replace stone with tower
    98             @brief Set the template for the stones.
    99             @param template The template name to be applied to each stone.
     100            @brief Get the template for the towers.
     101            @return Returns the template name to be applied to each tower.
    100102            */
    101             //void setStoneTemplate(const std::string& templateName)
    102             //    { this->stoneTemplate_ = templateName; }
    103             /**
    104             @brief Get the template for the stones.
    105             @return Returns the template name to be applied to each stone.
    106             */
    107             //const std::string& getStoneTemplate(void) const
    108             //    { return this->stoneTemplate_; }
     103            const std::string& getTowerTemplate(void) const
     104                { return this->towerTemplate_; }
    109105           
    110106
     
    114110            unsigned int width_;
    115111            unsigned int height_;
    116             //std::string stoneTemplate_;
     112            std::string towerTemplate_;
    117113
    118114    };
Note: See TracChangeset for help on using the changeset viewer.