コード例 #1
0
bool SquareObject::contains(const coord::phys3 &other) const {
	coord::tile other_tile = other.to_tile3().to_tile();

	for (coord::tile check_pos : tile_list(this->pos)) {
		if (check_pos == other_tile) {
			return true;
		}
	}
	return false;
}
コード例 #2
0
tile_range building_center(coord::phys3 west, coord::tile_delta size) {
	tile_range result;
	result.start = west.to_tile3().to_tile();
	result.end   = result.start + size;

	// TODO temporary hacky solution until openage::coord has been properly fixed.
	coord::phys2 draw_pos = result.start.to_phys2();

	draw_pos.ne += ((size.ne - 1) * coord::settings::phys_per_tile) / 2;
	draw_pos.se += ((size.se - 1) * coord::settings::phys_per_tile) / 2;

	result.draw  = draw_pos.to_phys3();
	return result;
}
コード例 #3
0
ファイル: path.cpp プロジェクト: Dotile/openage
Node::Node(const coord::phys3 &pos, node_pt prev)
	:
	position(pos),
	tile_position(pos.to_tile3().to_tile()),
	dir_ne{0.0f},
	dir_se{0.0f},
	visited{false},
	was_best{false},
	factor{1.0f},
	path_predecessor{prev},
	heap_node(nullptr) {

	if (prev) {
		cost_t dx = this->position.ne - prev->position.ne;
		cost_t dy = this->position.se - prev->position.se;
		cost_t hyp = std::hypot(dx, dy);
		this->dir_ne = dx / hyp;
		this->dir_se = dy / hyp;
		cost_t similarity = this->dir_ne * prev->dir_ne + this->dir_se * prev->dir_se;
		this->factor += (1 - similarity);
	}
}