eliminated global scroll_x and scroll_y variables
[supertux.git] / src / vector.h
1 #ifndef __VECTOR_HPP__
2 #define __VECTOR_HPP__
3
4 class Vector
5 {
6 public:
7   Vector(float nx, float ny)
8     : x(nx), y(ny)
9   { }
10   Vector(const Vector& other)
11     : x(other.x), y(other.y)
12   { }
13   Vector()
14     : x(0), y(0)
15   { }
16
17   bool operator ==(const Vector& other) const
18   {
19     return x == other.x && y == other.y;
20   }
21
22   const Vector& operator=(const Vector& other)
23   {
24     x = other.x;
25     y = other.y;
26     return *this;
27   }
28
29   Vector operator+(const Vector& other) const
30   {
31     return Vector(x + other.x, y + other.y);
32   }
33
34   Vector operator-(const Vector& other) const
35   {
36     return Vector(x - other.x, y - other.y);
37   }
38
39   Vector operator*(float s) const
40   {
41     return Vector(x * s, y * s);
42   }
43
44   const Vector& operator +=(const Vector& other)
45   {
46     x += other.x;
47     y += other.y;
48     return *this;
49   }
50
51   // ... add the other operators as needed, I'm too lazy now ...
52
53   float x, y; // leave this public, get/set methods just give me headaches
54               // for such simple stuff :)
55 };
56
57 #endif
58