Zappy Server
C++ game server: world, rules, scheduler, network
Loading...
Searching...
No Matches
Orientation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ostream>
4
10enum class Orientation { N = 1, E = 2, S = 3, W = 4 };
11
13{
14 switch (o) {
15 case Orientation::N:
16 return Orientation::E;
17 case Orientation::E:
18 return Orientation::S;
19 case Orientation::S:
20 return Orientation::W;
21 case Orientation::W:
22 return Orientation::N;
23 }
24 return o;
25}
26
28{
29 switch (o) {
30 case Orientation::N:
31 return Orientation::W;
32 case Orientation::W:
33 return Orientation::S;
34 case Orientation::S:
35 return Orientation::E;
36 case Orientation::E:
37 return Orientation::N;
38 }
39 return o;
40}
41
42inline std::ostream& operator<<(std::ostream& os, Orientation orientation)
43{
44 switch (orientation) {
45 case Orientation::N:
46 return os << "North";
47 case Orientation::E:
48 return os << "East";
49 case Orientation::S:
50 return os << "South";
51 case Orientation::W:
52 return os << "West";
53 }
54 return os << "Unknown";
55}
Orientation turnRight(Orientation o)
Orientation
std::ostream & operator<<(std::ostream &os, Orientation orientation)
Orientation turnLeft(Orientation o)