proto/p2/Dimension.hh
author ekku
Mon, 03 Nov 2008 22:20:21 +0000
changeset 4 e28b28b8817c
parent 3 5a209a8585c9
permissions -rw-r--r--
Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
     1
#ifndef DIMENSION_HH
5a209a8585c9 proto p2
terom
parents:
diff changeset
     2
#define DIMENSION_HH
5a209a8585c9 proto p2
terom
parents:
diff changeset
     3
5a209a8585c9 proto p2
terom
parents:
diff changeset
     4
class Dimension {
5a209a8585c9 proto p2
terom
parents:
diff changeset
     5
	public:
5a209a8585c9 proto p2
terom
parents:
diff changeset
     6
		uint32_t width;
5a209a8585c9 proto p2
terom
parents:
diff changeset
     7
		uint32_t height;
5a209a8585c9 proto p2
terom
parents:
diff changeset
     8
5a209a8585c9 proto p2
terom
parents:
diff changeset
     9
		Dimension (uint32_t width, uint32_t height) : width(width), height(height) { }
5a209a8585c9 proto p2
terom
parents:
diff changeset
    10
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    11
5a209a8585c9 proto p2
terom
parents:
diff changeset
    12
class Coordinate {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    13
	public:
5a209a8585c9 proto p2
terom
parents:
diff changeset
    14
		uint32_t x;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    15
		uint32_t y;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    16
5a209a8585c9 proto p2
terom
parents:
diff changeset
    17
		Coordinate (uint32_t x, uint32_t y) : x(x), y(y) { }
5a209a8585c9 proto p2
terom
parents:
diff changeset
    18
5a209a8585c9 proto p2
terom
parents:
diff changeset
    19
		Coordinate &operator+= (const PositionDelta &d) {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    20
			this->x += d.dx;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    21
			this->y += d.dy;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    22
		}
4
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    23
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    24
		uint32_t scaledX() {
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    25
			// Scale the coordinate so that it 
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    26
			// matches the pixel resolution
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    27
			return this->x/1;
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    28
		}
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    29
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    30
		uint32_t scaledY() {
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    31
			return this->y/1;
e28b28b8817c Drawer lis?tty. Pari metodia gamestateen ja dimensioniin.
ekku
parents: 3
diff changeset
    32
		}
3
5a209a8585c9 proto p2
terom
parents:
diff changeset
    33
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    34
5a209a8585c9 proto p2
terom
parents:
diff changeset
    35
class PositionDelta {
5a209a8585c9 proto p2
terom
parents:
diff changeset
    36
	public:
5a209a8585c9 proto p2
terom
parents:
diff changeset
    37
		uint32_t dx;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    38
		uint32_t dy;
5a209a8585c9 proto p2
terom
parents:
diff changeset
    39
5a209a8585c9 proto p2
terom
parents:
diff changeset
    40
		PositionDelta (uint32_t dx, uint32_t dy) : dx(dx), dy(dy) { }
5a209a8585c9 proto p2
terom
parents:
diff changeset
    41
};
5a209a8585c9 proto p2
terom
parents:
diff changeset
    42
5a209a8585c9 proto p2
terom
parents:
diff changeset
    43
#endif