Changeset 9154 for code/branches/newlevel2012/src
- Timestamp:
- May 4, 2012, 2:51:44 PM (13 years ago)
- Location:
- code/branches/newlevel2012/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
r9148 r9154 153 153 void TowerDefense::addTower(int x, int y) 154 154 { 155 if (x > 15 || y > 15 || x < 0 || y < 0)//Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet) 155 unsigned int width = this->center_->getWidth(); 156 unsigned int height = this->center_->getHeight(); 157 int tileScale = (int) this->center_->getTileScale(); 158 159 orxout() << "tile scale = " << tileScale << endl; 160 161 if (x > 15 || y > 15 || x < 0 || y < 0) 156 162 { 163 //Hard coded: TODO: let this depend on the centerpoint's height, width and fieldsize (fieldsize doesn't exist yet) 157 164 orxout() << "Can not add Tower: x and y should be between 0 and 15" << endl; 158 165 return; 159 166 } 160 167 161 orxout() << "Will add tower at (" << x << "," << y<< ")" << endl;168 orxout() << "Will add tower at (" << (x-8) * tileScale << "," << (y-8) * tileScale << ")" << endl; 162 169 163 170 Tower* newTower = new Tower(this->center_); … … 166 173 this->center_->attach(newTower); 167 174 168 newTower->setPosition( x-8,y-8,0);175 newTower->setPosition((x-8) * tileScale, (y-8) * tileScale, 0); 169 176 newTower->setGame(this); 170 177 //TODO: Save the Tower in a Vector. I would suggest std::vector< std::vector<Tower*> > towers_ as a protected member variable; -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.cc
r9143 r9154 67 67 68 68 XMLPortParam(TowerDefenseCenterpoint, "width", setWidth, getWidth, xmlelement, mode); 69 XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, setWidth, xmlelement, mode); 69 XMLPortParam(TowerDefenseCenterpoint, "height", setHeight, getHeight, xmlelement, mode); 70 XMLPortParam(TowerDefenseCenterpoint, "tileScale", setTileScale, getTileScale, xmlelement, mode); 70 71 XMLPortParam(TowerDefenseCenterpoint, "towerTemplate", setTowerTemplate, getTowerTemplate, xmlelement, mode); 72 71 73 //TODO: add XMLPortObject(TowerDefenseCenterpoint, WorldEntity, "waypoints", addWaypoint, getWaypoint, xmlelement, mode); 72 74 // This was copied and shightly modified from WaypointController.cc ; there are no getters and setters and no membervariable yet -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefenseCenterpoint.h
r9141 r9154 69 69 unsigned int getHeight(void) const 70 70 { return this->height_; } 71 72 /** 73 @brief How to convert to world coordinates, e.g. that 0,15 is not at -8,-8 but at -80,-80 (if scale would be 10) 74 */ 75 void setTileScale(unsigned int tileScale) 76 { this->tileScale_ = tileScale; } 77 78 unsigned int getTileScale(void) const 79 { return this->tileScale_; } 71 80 72 81 /** … … 85 94 unsigned int width_; 86 95 unsigned int height_; 96 unsigned int tileScale_; 97 87 98 std::string towerTemplate_; 88 99 }; -
code/branches/newlevel2012/src/orxonox/controllers/WaypointController.cc
r9144 r9154 65 65 return; 66 66 67 orxout() << "(" << this->waypoints_.size() << ") entity: " << this->getControllableEntity() << endl;67 // orxout() << "(" << this->waypoints_.size() << ") entity: " << this->getControllableEntity() << endl; 68 68 69 69 if (this->waypoints_.size() == 0 || !this->getControllableEntity()) 70 70 return; 71 71 72 printf("3");72 // printf("3"); 73 73 74 74 if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_) 75 75 this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size(); 76 76 77 printf("4");77 // printf("4"); 78 78 79 79 this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition());
Note: See TracChangeset
for help on using the changeset viewer.