Gamedev Framework (gf)  0.19.0
A C++17 framework for 2D games
Orthogonal.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2021 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_ORTHOGONAL_H
22 #define GF_ORTHOGONAL_H
23 
24 #include <functional>
25 
26 #include "CoreApi.h"
27 #include "Polyline.h"
28 #include "Rect.h"
29 #include "Vector.h"
30 
31 namespace gf {
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 inline namespace v1 {
34 #endif
35 
40  class GF_CORE_API OrthogonalHelper {
41  public:
42  RectF computeBounds(Vector2i layerSize, Vector2f tileSize) const;
43 
44  RectI computeVisibleArea(const RectF& local, Vector2f tileSize) const;
45 
46  RectF computeCellBounds(Vector2i coords, Vector2f tileSize) const;
47 
48  Vector2i computeCoordinates(Vector2f position, Vector2f tileSize) const;
49 
50  Polyline computePolyline(Vector2i coords, Vector2f tileSize) const;
51 
52  void forEachNeighbor(Vector2i coords, Vector2i layerSize, std::function<void(Vector2i)> func) const;
53  };
54 
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 }
57 #endif
58 }
59 
60 #endif // GF_ORTHOGONAL_H
A helper for computing coordinates in an orthogonal map.
Definition: Orthogonal.h:40
A polyline.
Definition: Polyline.h:46
The namespace for gf classes.
Definition: Action.h:35