The Battle for Wesnoth  1.17.0-dev
point.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
18 #include "sdl/point.hpp"
19 
20 #include <iostream>
21 
22 point::operator SDL_Point() const
23 {
24  return {x, y};
25 }
26 
28 {
29  x += point.x;
30  y += point.y;
31  return *this;
32 }
33 
35 {
36  x -= point.x;
37  y -= point.y;
38  return *this;
39 }
40 
41 std::ostream& operator<<(std::ostream& stream, const point& point)
42 {
43  stream << point.x << ',' << point.y;
44  return stream;
45 }
point & operator+=(const point &point)
Definition: point.cpp:27
std::ostream & operator<<(std::ostream &stream, const point &point)
Definition: point.cpp:41
int x
x coordinate.
Definition: point.hpp:45
point & operator-=(const point &point)
Definition: point.cpp:34
Holds a 2D point.
Definition: point.hpp:24
int y
y coordinate.
Definition: point.hpp:48