| author | terom |
| Mon, 10 Nov 2008 16:49:09 +0000 | |
| branch | no-netsession |
| changeset 31 | d0d7489d4e8b |
| parent 25 | af75a1894a32 |
| child 42 | eb1a93a38cde |
| permissions | -rw-r--r-- |
| 3 | 1 |
#ifndef DIMENSION_HH |
2 |
#define DIMENSION_HH |
|
3 |
||
|
23
8d802b573cf0
fixed more network code, there's actually a high probability of it working now
terom
parents:
6
diff
changeset
|
4 |
#include <iostream> |
| 6 | 5 |
|
| 3 | 6 |
class Dimension {
|
| 24 | 7 |
public: |
| 25 | 8 |
uint32_t w; |
9 |
uint32_t h; |
|
| 3 | 10 |
|
| 25 | 11 |
Dimension (uint32_t w, uint32_t h) : w(w), h(h) { }
|
| 3 | 12 |
}; |
13 |
||
| 6 | 14 |
class PositionDelta {
|
| 24 | 15 |
public: |
| 25 | 16 |
int32_t dx; |
17 |
int32_t dy; |
|
| 6 | 18 |
|
| 25 | 19 |
PositionDelta (int32_t dx, int32_t dy) : dx(dx), dy(dy) { }
|
| 6 | 20 |
}; |
21 |
||
| 3 | 22 |
class Coordinate {
|
| 24 | 23 |
public: |
24 |
uint32_t x; |
|
25 |
uint32_t y; |
|
| 6 | 26 |
|
| 24 | 27 |
Coordinate (uint32_t x, uint32_t y) : x(x), y(y) { }
|
|
4
e28b28b8817c
Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents:
3
diff
changeset
|
28 |
|
| 24 | 29 |
Coordinate &operator+= (const PositionDelta &d) {
|
30 |
this->x += d.dx; |
|
31 |
this->y += d.dy; |
|
|
4
e28b28b8817c
Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents:
3
diff
changeset
|
32 |
|
| 24 | 33 |
return *this; |
34 |
} |
|
35 |
||
| 25 | 36 |
Coordinate operator+ (const PositionDelta &d) {
|
37 |
return Coordinate(x + d.dx, y + d.dy); |
|
| 24 | 38 |
} |
39 |
||
| 25 | 40 |
// Scale the coordinate so that it matches the pixel resolution |
41 |
uint32_t scaledX() { return x; }
|
|
42 |
||
43 |
uint32_t scaledY() { return y; }
|
|
| 3 | 44 |
}; |
45 |
||
|
23
8d802b573cf0
fixed more network code, there's actually a high probability of it working now
terom
parents:
6
diff
changeset
|
46 |
std::ostream& operator<< (std::ostream &s, const Coordinate &c); |
|
8d802b573cf0
fixed more network code, there's actually a high probability of it working now
terom
parents:
6
diff
changeset
|
47 |
std::ostream& operator<< (std::ostream &s, const PositionDelta &c); |
|
8d802b573cf0
fixed more network code, there's actually a high probability of it working now
terom
parents:
6
diff
changeset
|
48 |
|
| 3 | 49 |
#endif |