nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
map.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_MAP_H_
2#define NANOMMO_CLIENT_MAP_H_
3
4#include <raylib.h>
5
6#include <array>
7#include <cstdint>
8#include <optional>
9#include <vector>
10
11#include "client/animator.h"
12#include "terrain/lands.h"
13#include "terrain/terrain.h"
14
15namespace nanommo {
16
17/// The land from above, north up, a pixel a metre: its ground in the land's
18/// colours, shaded by its slopes, its sea and its trees.
19Image DrawLand(const Terrain& terrain, int land);
20
21/// How the minimap's view is turned: north up, or with what's ahead of the
22/// camera up, as the player chooses.
24
25/// A land seen from above, north up: its ground in the land's colours,
26/// shaded by its slopes, its sea and its trees, drawn once into a texture as
27/// the land is built. The minimap, round, in the top right, shows what's
28/// around you, and the map, on M, the whole land, with whoever's near you on
29/// both.
30class LandMap {
31 public:
32 /// In metres from you to the minimap's rim, at each of its zooms.
33 static constexpr std::array<float, 3> kZooms = {25.0f, 45.0f, 80.0f};
34
35 LandMap() = default;
36 ~LandMap();
37
38 LandMap(const LandMap&) = delete;
39 LandMap& operator=(const LandMap&) = delete;
40
41 /// Draws the land into the texture, in place of the last one.
42 void Build(const Terrain& terrain, int land);
43
44 /// The minimap, with the monster you picked, by its id, and where you're
45 /// walking to, if you are, turned to the heading the camera looks along if
46 /// the player chose that. Scrolling over it, or its
47 /// buttons, zoom in and out. Returns true when its map button's clicked.
48 bool DrawMinimap(const std::vector<Figure>& figures, uint32_t target,
49 std::optional<Vector3> destination, float heading,
50 MinimapTurn turn);
51
52 /// How far down the screen the minimap reaches, in points, for what goes
53 /// under it.
54 float minimap_bottom() const { return bottom_; }
55
56 int zoom() const { return zoom_; }
57 void set_zoom(int zoom);
58
59 /// The map, in a window of its own, while open is true; its close button
60 /// sets it to false. Returns the place you clicked on, to walk to.
61 std::optional<Place> DrawMap(const std::vector<Figure>& figures,
62 uint32_t target,
63 std::optional<Vector3> destination,
64 bool* open) const;
65
66 private:
67 Texture2D texture_{};
68 float half_ = 0.0f;
69 int land_ = 0;
70 int zoom_ = 1;
71 float bottom_ = 0.0f;
72};
73
74} // namespace nanommo
75
76#endif // NANOMMO_CLIENT_MAP_H_
std::optional< Place > DrawMap(const std::vector< Figure > &figures, uint32_t target, std::optional< Vector3 > destination, bool *open) const
Definition map.cc:453
float minimap_bottom() const
Definition map.h:54
void set_zoom(int zoom)
Definition map.cc:338
LandMap(const LandMap &)=delete
void Build(const Terrain &terrain, int land)
Draws the land into the texture, in place of the last one.
Definition map.cc:324
LandMap()=default
static constexpr std::array< float, 3 > kZooms
In metres from you to the minimap's rim, at each of its zooms.
Definition map.h:33
bool DrawMinimap(const std::vector< Figure > &figures, uint32_t target, std::optional< Vector3 > destination, float heading, MinimapTurn turn)
Definition map.cc:342
LandMap & operator=(const LandMap &)=delete
int zoom() const
Definition map.h:56
Definition chat.cc:9
Image DrawLand(const Terrain &terrain, int land)
Definition map.cc:269
MinimapTurn
Definition map.h:23