Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9142


Ignore:
Timestamp:
Apr 29, 2012, 5:22:56 PM (12 years ago)
Author:
mentzerf
Message:

+ Tried to create waypoints programmatically, succeeded, BUT: the spaceship does not follow them!!

  • Changed WaypointController to log some debug info
Location:
code/branches/newlevel2012
Files:
4 edited

Legend:

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

    r9141 r9142  
    6565        <!-- Spawns the camera, attached to a crate -->
    6666        <SpawnPoint team=0 position="0,0,0" spawnclass=Pawn pawndesign=centerpointmark />
     67        <!--TeamSpawnPoint team=1 position="-7,7,4" direction="-1,0,0" roll=90 yaw=0 spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    6768       
    6869        <!--SpawnPoint team=1 position="0,0,10" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff  /-->
    6970        <!--SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff /-->
    7071       
    71         <!--SpaceShip position="-10,0,20" lookat="0,0,0">
     72        <!--SpaceShip position="-10,0,20" lookat="0,0,0" scale=0.3>
    7273      <templates>
    7374        <Template link=spaceshipassff />
     
    7677        <WaypointController accuracy=3>
    7778          <waypoints>
    78             <Model mesh="cube.mesh" scale=1 position="110,90,20" />
    79             <Model mesh="cube.mesh" scale=2 position="290,90,20" />
    80             <Model mesh="cube.mesh" scale=3 position="290,-90,20" />
    81             <Model mesh="cube.mesh" scale=4 position="110,-90,20" />
     79            <Model mesh="cube.mesh" scale=0.2 position="-8,-8,3" />
     80            <Model mesh="cube.mesh" scale=0.2 position="8,8,3" />
     81            <Model mesh="cube.mesh" scale=0.2 position="8,-8,3" />
     82            <Model mesh="cube.mesh" scale=0.2 position="-8,8,3" />
    8283          </waypoints>
    8384        </WaypointController>
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc

    r9139 r9142  
    6262#include "worldentities/pawns/Pawn.h"
    6363#include "worldentities/pawns/SpaceShip.h"
    64 
     64#include "controllers/WaypointController.h"
     65         
     66#include "graphics/Model.h"
     67#include "infos/PlayerInfo.h"
     68         
    6569#include "chat/ChatManager.h"
    6670
     
    7882                /* Temporary hack to allow the player to add towers */
    7983                this->dedicatedAddTower_ = createConsoleCommand( "addTower", createExecutor( createFunctor(&TowerDefense::addTower, this) ) );
    80                
     84       
     85                // Quick hack to test waypoints
     86                createConsoleCommand( "aw", createExecutor( createFunctor(&TowerDefense::addWaypointsAndFirstEnemy, this) ) );
    8187    }
    8288       
     
    149155        SUPER(TowerDefense, tick, dt);
    150156               
    151         static bool test = false;
    152         if (!test)
     157        static int test = 0;
     158        if (++test == 10)
    153159        {
    154                         orxout()<< "First tick." <<endl;
     160                        orxout()<< "10th tick." <<endl;
     161                        /*
     162                        for (std::set<SpawnPoint*>::iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); it++)
     163                        {
     164                                orxout() << "checking spawnpoint with name " << (*it)->getSpawnClass()->getName() << endl;
     165                        }
     166                        */
     167                       
     168                        //addWaypointsAndFirstEnemy();
     169                       
    155170        }
    156         test = true;
    157171    }
     172       
     173        // Function to test if we can add waypoints using code only. Doesn't work yet
     174       
     175        // THE PROBLEM: WaypointController's getControllableEntity() returns null, so it won't track. How do we get the controlableEntity to NOT BE NULL???
     176       
     177        void TowerDefense::addWaypointsAndFirstEnemy()
     178        {
     179                SpaceShip *newShip = new SpaceShip(this->center_);
     180                newShip->addTemplate("spaceshipassff");
     181               
     182                WaypointController *newController = new WaypointController(newShip);
     183                newController->setAccuracy(3);
     184               
     185                Model *wayPoint1 = new Model(newController);
     186                wayPoint1->setMeshSource("crate.mesh");
     187                wayPoint1->setPosition(7,-7,5);
     188                wayPoint1->setScale(0.2);
     189                       
     190                Model *wayPoint2 = new Model(newController);
     191                wayPoint2->setMeshSource("crate.mesh");
     192                wayPoint2->setPosition(7,7,5);
     193                wayPoint2->setScale(0.2);
     194                       
     195                newController->addWaypoint(wayPoint1);
     196                newController->addWaypoint(wayPoint2);
     197                       
     198                // The following line causes the game to crash
     199//              newController -> getPlayer() -> startControl(newShip);
     200                newShip->setController(newController);
     201                newShip->setPosition(-7,-7,5);
     202                newShip->setScale(0.1);
     203                newShip->addSpeed(1);
     204               
     205               
     206               
     207//              this->center_->attach(newShip);
     208        }
    158209       
    159210        /*
  • code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h

    r9141 r9142  
    5858                //virtual void playerScored(PlayerInfo* player);
    5959               
     60               
    6061                /*      Called by TowerDefenseCenterpoint upon game start
    6162                        The centerpoint is used to create towers
     
    7273//              WeakPtr<TowerDefenseCenterpoint> center_;
    7374                TowerDefenseCenterpoint *center_;
     75               
     76                void addWaypointsAndFirstEnemy();
    7477    };
    7578}
  • code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc

    r8891 r9142  
    6262    void WaypointController::tick(float dt)
    6363    {
    64         if (!this->isActive())
     64                if (!this->isActive())
    6565            return;
     66
     67                orxout() << "(" << this->waypoints_.size() << ") entity: " << this->getControllableEntity() << endl;
     68
    6669
    6770        if (this->waypoints_.size() == 0 || !this->getControllableEntity())
    6871            return;
    6972
     73                printf("3");
     74
    7075        if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_)
    7176            this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size();
     77
     78                printf("4");
    7279
    7380        this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition());
Note: See TracChangeset for help on using the changeset viewer.