MCPcopy Create free account
hub / github.com/davemoore22/sorcery / _move_forward

Method _move_forward

src/engine/engine.cpp:362–521  ·  view source on GitHub ↗

Remember Y is reversed

Source from the content-addressed store, hash-verified

360 _ctx.ui->modal_remove->show = false;
361 _ctx.ui->modal_drop->show = false;
362 _ctx.ui->modal_use->show = false;
363 _ctx.ui->modal_invoke->show = false;
364 _ctx.ui->modal_trade->show = false;
365 _ctx.ui->modal_give->show = false;
366 _ctx.ui->modal_elevator_top->show = false;
367 _ctx.ui->modal_elevator_bottom->show = false;
368 }
369}
370
371// Remember Y is reversed
372auto Sorcery::Engine::_move_forward() -> bool {
373
374 auto at_loc{_ctx.game->state->get_player_pos()};
375 auto x_d{at_loc.x};
376 auto y_d{at_loc.y};
377
378 switch (_ctx.game->state->get_player_facing()) {
379 using enum Enums::Map::Direction;
380 case NORTH:
381 ++y_d;
382 break;
383 case SOUTH:
384 --y_d;
385 break;
386 case EAST:
387 ++x_d;
388 break;
389 case WEST:
390 --x_d;
391 break;
392 default:
393 break;
394 }
395
396 if (x_d < 0)
397 x_d = MAP_SIZE - 1;
398 else if (x_d > MAP_SIZE - 1)
399 x_d = 0;
400 if (y_d < 0)
401 y_d = MAP_SIZE - 1;
402 else if (y_d > MAP_SIZE - 1)
403 y_d = 0;
404
405 const auto next_loc{Coordinate{x_d, y_d}};
406 auto this_tile{_ctx.game->state->level->at(at_loc)};
407 const auto &next_tile{_ctx.game->state->level->at(next_loc)};
408
409 if (const auto next_wall{_ctx.game->state->get_player_facing()};
410 this_tile.walkable(next_wall)) {
411
412 _ctx.game->state->set_player_prev_depth(_ctx.game->state->get_depth());
413 _ctx.game->state->set_depth(_ctx.game->state->get_depth());
414 _ctx.game->state->set_player_pos(next_loc);
415 _ctx.controller->set_can_undo(true);
416
417 // Check for Darkness
418 using enum Enums::Tile::Properties;
419 if (!_tile_explored(_ctx.game->state->get_player_pos()))

Callers

nothing calls this directly

Calls 15

unenumFunction · 0.85
get_player_posMethod · 0.80
get_player_facingMethod · 0.80
walkableMethod · 0.80
set_player_prev_depthMethod · 0.80
get_depthMethod · 0.80
set_depthMethod · 0.80
set_player_posMethod · 0.80
set_can_undoMethod · 0.80
isMethod · 0.80
get_litMethod · 0.80
set_litMethod · 0.80

Tested by

no test coverage detected