Conquer Chess
Chess and Starcraft combined
Loading...
Searching...
No Matches
game_rect.h
Go to the documentation of this file.
1#ifndef GAME_RECT_H
2#define GAME_RECT_H
3
4#include "game_coordinate.h"
5
6#include <iosfwd>
7
12{
13public:
14 explicit game_rect(
15 const game_coordinate& top_left = game_coordinate(),
16 const game_coordinate& bottom_right = game_coordinate()
17 );
18
19 const auto& get_tl() const noexcept { return m_top_left; }
20 const auto& get_br() const noexcept { return m_bottom_right; }
21
22private:
23 game_coordinate m_top_left;
24 game_coordinate m_bottom_right;
25};
26
27game_coordinate get_center(const game_rect& r) noexcept;
28int get_height(const game_rect& r) noexcept;
29int get_width(const game_rect& r) noexcept;
30
32bool is_in(const game_coordinate& pos, const game_rect& r) noexcept;
33
35void test_game_rect();
36
37bool operator==(const game_rect& lhs, const game_rect& rhs) noexcept;
38
39std::ostream& operator<<(std::ostream& os, const game_rect& r) noexcept;
40
41#endif // GAME_RECT_H
An exact coordinate anywhere on the board.
Definition game_coordinate.h:32
A rectangle of game coordinates.
Definition game_rect.h:12
const auto & get_tl() const noexcept
Definition game_rect.h:19
const auto & get_br() const noexcept
Definition game_rect.h:20
std::ostream & operator<<(std::ostream &os, const game_rect &r) noexcept
Definition game_rect.cpp:112
bool operator==(const game_rect &lhs, const game_rect &rhs) noexcept
Definition game_rect.cpp:105
int get_height(const game_rect &r) noexcept
Definition game_rect.cpp:24
int get_width(const game_rect &r) noexcept
Definition game_rect.cpp:28
void test_game_rect()
Test this class and its free functions.
Definition game_rect.cpp:42
game_coordinate get_center(const game_rect &r) noexcept
Definition game_rect.cpp:16
bool is_in(const game_coordinate &pos, const game_rect &r) noexcept
Is the coordinat in the rectangle?
Definition game_rect.cpp:33