-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
65 lines (51 loc) · 1.37 KB
/
Player.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "GameObject.h"
#define PLAYER_FIRE_TIMEOUT 0.2f
// forward declaration
class SpaceInvaderMainScene;
class Player
: public GameObject
{
public:
Player ( ) : GameObject ( 5, 3 )
{
// first row
m_symbol[0].AsciiChar = ' ';
m_symbol[1].AsciiChar = ' ';
m_symbol[2].UnicodeChar = 0x25B2;
m_symbol[3].AsciiChar = ' ';
m_symbol[4].AsciiChar = ' ';
// second row
m_symbol[5].AsciiChar = '|';
m_symbol[6].AsciiChar = '/';
m_symbol[7].AsciiChar = '|';
m_symbol[8].AsciiChar = '\\';
m_symbol[9].AsciiChar = '|';
// third row
m_symbol[10].AsciiChar = '/';
m_symbol[11].AsciiChar = ' ';
m_symbol[12].AsciiChar = '|';
m_symbol[13].AsciiChar = ' ';
m_symbol[14].AsciiChar = '\\';
for (int i = 0; i < (int) ( m_width * m_height ); i++)
{
m_symbol[ i ].Attributes = CellColour::Fore_Cyan;
}
}
// Inherited via GameObject
const pRenderCellData draw ( ) const override
{
return m_active ? ( pRenderCellData ) m_symbol : nullptr;
};
void onCollision ( const GameObject & collision, const Vector2Int & collisionPoint ) override
{
setActive ( false );
}
void tick ( SpaceInvaderMainScene * game );
private:
RenderCellData m_symbol [ 15 ];
float fireTimeout = PLAYER_FIRE_TIMEOUT;
float m_lastFireTime = 0;
void processMovement ( SpaceInvaderMainScene * game );
void processCombat ( SpaceInvaderMainScene * game );
};