Changeset 9160
- Timestamp:
- May 4, 2012, 4:12:47 PM (13 years ago)
- Location:
- code/branches/newlevel2012/src/modules/towerdefense
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.cc
r9154 r9160 150 150 } 151 151 152 bool TowerDefense::hasTower(int x, int y) 153 { 154 for(std::vector<coordinate>::iterator it = addedTowersCoordinates_.begin(); it != addedTowersCoordinates_.end(); ++it) 155 { 156 coordinate currentCoordinates = (coordinate) (*it); 157 if (currentCoordinates.x == x && currentCoordinates.y == y) 158 return true; 159 } 160 161 return false; 162 } 152 163 153 164 void TowerDefense::addTower(int x, int y) 154 165 { 166 if (this->hasTower(x,y)) 167 { 168 orxout() << "tower exists!!" << endl; 169 return; 170 } 171 172 coordinate newTowerCooridnates; 173 newTowerCooridnates.x = x; newTowerCooridnates.y = y; 174 addedTowersCoordinates_.push_back(newTowerCooridnates); 175 155 176 unsigned int width = this->center_->getWidth(); 156 177 unsigned int height = this->center_->getHeight(); … … 158 179 159 180 orxout() << "tile scale = " << tileScale << endl; 181 182 160 183 161 184 if (x > 15 || y > 15 || x < 0 || y < 0) … … 173 196 this->center_->attach(newTower); 174 197 175 newTower->setPosition((x-8) * tileScale, (y-8) * tileScale, 0);198 newTower->setPosition((x-8) * tileScale, (y-8) * tileScale, 100); 176 199 newTower->setGame(this); 200 177 201 //TODO: Save the Tower in a Vector. I would suggest std::vector< std::vector<Tower*> > towers_ as a protected member variable; 178 202 -
code/branches/newlevel2012/src/modules/towerdefense/TowerDefense.h
r9143 r9160 78 78 // WeakPtr<TowerDefenseCenterpoint> center_; 79 79 TowerDefenseCenterpoint *center_; 80 81 82 bool hasTower(int x, int y); 83 84 typedef struct { 85 int x; 86 int y; 87 } coordinate; 88 89 90 91 std::vector<coordinate> addedTowersCoordinates_; 92 std::vector<Tower*> towers_; 80 93 81 94 void addWaypointsAndFirstEnemy();
Note: See TracChangeset
for help on using the changeset viewer.