forked from clickteam-plugin/TileMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.h
More file actions
36 lines (30 loc) · 597 Bytes
/
Tile.h
File metadata and controls
36 lines (30 loc) · 597 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
union Tile {
static const unsigned short EMPTY = 0xffff;
struct {
unsigned char x;
unsigned char y;
};
unsigned short id;
static Tile ByXY(unsigned char x, unsigned char y)
{
Tile t;
t.x = x;
t.y = y;
return t;
}
static Tile ByID(unsigned short id)
{
Tile t;
t.id = id;
return t;
}
};
struct TileRange {
Tile a;
Tile b;
bool isWithin(const Tile & tile) const
{
return tile.x >= a.x && tile.y >= a.y && tile.x <= b.x && tile.y <= b.y;
}
};