ScummVM API documentation
fpoint.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_FPOINT_H
23 #define TITANIC_FPOINT_H
24 
25 #include "common/rect.h"
26 
27 namespace Titanic {
28 
32 class FPoint {
33 public:
34  float _x, _y;
35 public:
36  FPoint() : _x(0), _y(0) {}
37  FPoint(float x, float y) : _x(x), _y(y) {}
38  FPoint(const Common::Point &pt) : _x(pt.x), _y(pt.y) {}
39 
40  bool operator==(const FPoint &p) const { return _x == p._x && _y == p._y; }
41  bool operator!=(const FPoint &p) const { return _x != p._x || _y != p._y; }
42  FPoint operator+(const FPoint &delta) const { return FPoint(_x + delta._x, _y + delta._y); }
43  FPoint operator-(const FPoint &delta) const { return FPoint(_x - delta._x, _y - delta._y); }
44 
45  void operator+=(const FPoint &delta) {
46  _x += delta._x;
47  _y += delta._y;
48  }
49 
50  void operator-=(const FPoint &delta) {
51  _x -= delta._x;
52  _y -= delta._y;
53  }
54 
59  float normalize();
60 };
61 
62 } // End of namespace Titanic
63 
64 #endif /* TITANIC_FPOINT_H */
Definition: rect.h:45
Definition: arm.h:30
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: fpoint.h:32