-
Notifications
You must be signed in to change notification settings - Fork 0
/
CGraphicCell.cpp
69 lines (55 loc) · 1.39 KB
/
CGraphicCell.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "CGraphicCell.h"
/*
int CGraphicCell::CellW = 0;
int CGraphicCell::CellH = 0;
*/
int CGraphicCell::CellSize = 0;
SDL_Surface* CGraphicCell::SurfDead = NULL;
SDL_Surface* CGraphicCell::SurfAlive = NULL;
SDL_Surface* CGraphicCell::SurfReprod = NULL;
SDL_Surface* CGraphicCell::SurfDying = NULL;
CGraphicCell::CGraphicCell( int x, int y )
: CDrawable( CGraphicCell::SurfDead, x, y, CellSize, CellSize )
{
setState( CGraphicCell::GCELL_TYPE_DEAD );
}
CGraphicCell::CGraphicCell( int x, int y, GCellState newState )
: CDrawable( CGraphicCell::SurfDead, x, y, CellSize, CellSize )
{
setState( newState );
}
CGraphicCell::GCellState CGraphicCell::getState()
{
return state;
}
void CGraphicCell::setState( GCellState newState )
{
state = newState;
setSurfState( newState );
}
void CGraphicCell::setSurfState( GCellState newState )
{
switch ( newState )
{
case GCELL_TYPE_DEAD:
{
setSurface( CGraphicCell::SurfDead );
break;
}
case GCELL_TYPE_ALIVE:
{
setSurface( CGraphicCell::SurfAlive );
break;
}
case GCELL_TYPE_REPROD:
{
setSurface( CGraphicCell::SurfReprod );
break;
}
case GCELL_TYPE_DYING:
{
setSurface( CGraphicCell::SurfDying );
break;
}
}
}