-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy.cpp
60 lines (44 loc) · 1.34 KB
/
enemy.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
#include "enemy.h"
#include "pixelgeinterface.h"
extern PixelGEinterface * Game;
Enemy::Enemy()
{
}
//Default enemy spawn constructor
Enemy::Enemy(float posX, float posY)
{
enemyPosX = posX;
enemyPosY = posY;
enemySprite = new olc::Sprite("./img/enemy.png");
enemyDecal = new olc::Decal(enemySprite);
}
//Same as bullet, except this will be generated(Spawned) Directly from the Game object.
bool Enemy::move(float Timer)
{
if (enemyDecal != nullptr)
{
if (enemyPosY < 0){
delete enemyDecal;
enemyDecal = nullptr;
return true;
}
float offset = eHealth * 1.6;
Game->DrawDecal({enemyPosX,enemyPosY}, enemyDecal,{0.7f,0.7f});
Game->FillRectDecal({enemyPosX,enemyPosY - 10.0f},{offset,5}, olc::RED);
//Game->DrawDecal({enemyPosX + 15.0f,enemyPosY + 30.0f}, Game->bulletdecal, {0.2f,0.2f});
//Game->DrawDecal({enemyPosX + 33.0f,enemyPosY + 30.0f}, Game->bulletdecal, {0.2f,0.2f});
enemyPosY += enemySpeed * Timer;
}
return false;
}
//Draw method for the enemy, for other forms of enemy spawn
//It will only draw if enemy object has been initiated.
void Enemy::DrawEnemy()
{
if (enemyDecal != nullptr)
Game->DrawDecal({enemyPosX,enemyPosY}, enemyDecal,{0.7f,0.7f});
}
float Enemy::getEPosY()
{
return enemyPosY;
}