ScummVM API documentation
vector2.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 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_VECTOR2_H
29 #define WINTERMUTE_VECTOR2_H
30 
31 namespace Wintermute {
32 
33 class Vector2 {
34 public:
35  Vector2();
36  Vector2(float x, float y);
37  ~Vector2();
38 
39  float length() const;
40 
41  inline Vector2 &operator= (const Vector2 &other) {
42  x = other.x;
43  y = other.y;
44 
45  return *this;
46  }
47 
48  inline Vector2 operator+ (const Vector2 &other) const {
49  return Vector2(x + other.x, y + other.y);
50  }
51 
52  inline Vector2 operator- (const Vector2 &other) const {
53  return Vector2(x - other.x, y - other.y);
54  }
55 
56  inline Vector2 operator* (const float scalar) const {
57  return Vector2(x * scalar, y * scalar);
58  }
59 
60  inline Vector2 &operator+= (const Vector2 &other) {
61  x += other.x;
62  y += other.y;
63 
64  return *this;
65  }
66 
67 
68  float x;
69  float y;
70 };
71 
72 } // End of namespace Wintermute
73 
74 #endif
Definition: vector2.h:33
Definition: achievements_tables.h:27