Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        /*
Note: See TracChangeset for help on using the changeset viewer.