Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool GameField::isPathOpen(const Vec2Tile & from, const Vec2Tile & to) const
- {
- int l, dx, dy;
- int xr = abs(to.x - from.x);
- int yr = abs(to.y - from.y);
- if (xr > yr)
- {
- l = xr;
- }
- else
- {
- l = yr;
- }
- int px = (from.x << 12) + (1 << 11);
- int py = (from.y << 12) + (1 << 11);
- int ex = (to.x << 12) + (1 << 11);
- int ey = (to.y << 12) + (1 << 11);
- if (l != 0)
- {
- dx = (ex - px) / l;
- dy = (ey - py) / l;
- }
- else
- {
- dx = 0;
- dy = 0;
- }
- for (int i = 0; i <= l; i++)
- {
- if (!getTileAt(Vec2Tile(px >> 12, py >> 12)).isOpen())
- return false;
- px += dx;
- py += dy;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement