- Timestamp:
- May 4, 2012, 2:51:44 PM (13 years ago)
- File:
-
- 1 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;
Note: See TracChangeset
for help on using the changeset viewer.