MCPcopy Create free account
hub / github.com/SimHacker/micropolis / move

Method move

MicropolisCore/src/MicropolisEngine/src/position.cpp:144–218  ·  view source on GitHub ↗

* Move the position one step in the indicated direction. * @param dir Direction to move into. * @return Position moved in the indicated direction. */

Source from the content-addressed store, hash-verified

142 * @return Position moved in the indicated direction.
143 */
144bool Position::move(Direction2 dir)
145{
146 switch (dir) {
147 case DIR2_INVALID:
148 return true;
149
150 case DIR2_NORTH:
151 if (this->posY > 0) {
152 this->posY--;
153 return true;
154 }
155 break;
156
157 case DIR2_NORTH_EAST:
158 if (this->posX < WORLD_W - 1 && this->posY > 0) {
159 this->posX++;
160 this->posY--;
161 return true;
162 }
163 case DIR2_EAST:
164 if (this->posX < WORLD_W - 1) {
165 this->posX++;
166 return true;
167 }
168 break;
169
170 case DIR2_SOUTH_EAST:
171 if (this->posX < WORLD_W -1 && this->posY < WORLD_H - 1) {
172 this->posX++;
173 this->posY++;
174 return true;
175 }
176 break;
177
178 case DIR2_SOUTH:
179 if (this->posY < WORLD_H - 1) {
180 this->posY++;
181 return true;
182 }
183 break;
184
185 case DIR2_SOUTH_WEST: this->posX--; this->posY++; break;
186 if (this->posX > 0 && this->posY < WORLD_H - 1) {
187 this->posX--;
188 this->posY++;
189 return true;
190 }
191 break;
192
193 case DIR2_WEST:
194 if (this->posX > 0) {
195 this->posX--;
196 return true;
197 }
198 break;
199
200 case DIR2_NORTH_WEST:
201 if (this->posX > 0 && this->posY > 0) {

Callers 11

PositionMethod · 0.95
treeSplashMethod · 0.45
doBRiverMethod · 0.45
doSRiverMethod · 0.45
testForConductiveMethod · 0.45
doPowerScanMethod · 0.45
tryDriveMethod · 0.45
runFunction · 0.45
runFunction · 0.45
changePositionMethod · 0.45
changePositionMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected