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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/* *******************************************************************
* Includes
* ******************************************************************/
#include "HumanPlayer.h"
#include "System.h"
#include "Sprite.h"
#include "Cursor.h"
#include <Buttons.h>
#include <Gamebuino.h>
#include <stdint.h>
#include <string.h>
/* *******************************************************************
* Defines
* ******************************************************************/
/* *******************************************************************
* Types definition
* ******************************************************************/
/* *******************************************************************
* Global variables definition
* ******************************************************************/
/* *******************************************************************
* Local variables definition
* ******************************************************************/
/*****************************************************************//**
*
* \brief Bitmap data for idle UNIT_ID_PEASANT.
*
*********************************************************************/
static const PROGMEM uint8_t au8MouseSprData[] =
{
8,
8,
0xFC,
0x84,
0x88,
0x84,
0xA2,
0xD1,
0x0A,
0x04
};
/* *******************************************************************
* Local prototypes declaration
* ******************************************************************/
/* *******************************************************************
* Functions definition
* ******************************************************************/
/*****************************************************************//**
*
* \brief Constructor for HumanPlayer class.
*
*********************************************************************/
HumanPlayer::HumanPlayer(const char* const strPlayerName, const Camera& cam) :
Player(strPlayerName),
_cam(cam),
_ABtnFrames(0),
_eState(PLAYER_STATE_IDLE)
{
_unitsMap[0].create(Unit::UNIT_ID_PEASANT, 16, 16);
}
/*****************************************************************//**
*
* \brief Periodical event handler that calls HumanPlayer subtasks.
*
*********************************************************************/
void HumanPlayer::handler(void)
{
/* Execute HumanPlayerBtn submodule. */
buttonHandler();
/* Execute parent class unit handler. */
Player::handleUnits();
drawHandler();
}
/*****************************************************************//**
*
* \brief This function draws all units and player UI.
*
*********************************************************************/
void HumanPlayer::drawHandler(void)
{
/* Execute base class Unit drawHandler. */
Player::drawUnits();
if (_eState == PLAYER_STATE_UNIT_MENU)
{
gb.display.setColor(BLACK);
gb.display.drawRect(0, 40, 84, 8);
}
/* Configure cursor sprite object. */
Sprite cursorSpr(au8MouseSprData, false, INVERT);
/* Transfer Cursor to Sprite coordinates. */
cursorSpr.setPos(_cursor.getX(), _cursor.getY());
/* Draw cursor sprite. */
cursorSpr.draw();
}
/*****************************************************************//**
*
* \brief This function looks for units nearby and selects them.
* If no units can be selected, player state remains
* unchanged.
*
* \return New player state.
*
* \see \ref tPlayerState.
*
*********************************************************************/
enum tPlayerState HumanPlayer::selectUnit(void)
{
}
|