-
Notifications
You must be signed in to change notification settings - Fork 3
/
board.h
44 lines (41 loc) · 938 Bytes
/
board.h
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
37
38
39
40
41
42
43
44
#ifndef BOARD_H
#define BOARD_H
#include <cstring>
class Board
{
private:
unsigned int width, height;
unsigned char *pix;
public:
Board(unsigned int w, unsigned h)
{
pix = new unsigned char[w*h];
width = w; height = h;
memset(pix, 0, w*h);
}
unsigned char getPixel(unsigned int x, unsigned int y)
{
if(x < width && y < height)
return pix[y*width+x];
else
return 1;
}
void setPixel(unsigned int x, unsigned int y, unsigned char val)
{
pix[y*width+x] = val;
}
unsigned int getWidth()
{
return width;
}
unsigned int getHeight()
{
return height;
}
virtual ~Board()
{
delete [] pix;
pix = NULL;
}
};
#endif // BOARD_H