-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEnemyPilot.cpp
More file actions
59 lines (47 loc) · 1.48 KB
/
EnemyPilot.cpp
File metadata and controls
59 lines (47 loc) · 1.48 KB
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
#include "Application.h"
#include "EnemyPilot.h"
#include "ModuleCollision.h"
#include "ModuleEnemies.h"
#include "Path.h"
#include "ModuleRender.h"
EnemyPilot::EnemyPilot(int x, int y, powerUpTypes type, SDL_Texture* thisTexture) : Enemy(x, y)
{
//links the correct spritesheet texture ----
enemyTex = thisTexture;
// -----------------------------------------
die.PushBack({ 0,0,12,16 });
die.PushBack({ 12,0,13,16 });
die.PushBack({ 25,0,14,16 });
die.PushBack({ 39,0,13,16 });
die.PushBack({ 52,0,15,16 });
die.PushBack({ 67,0,12,16 });
die.PushBack({ 79,0,11,16 });
die.PushBack({ 90,0,12,16 });
die.speed = 0.16666666f;
animation = ¨ //links animation
//Path
path.PushBack({ 0.5f, -1.0f }, 30, &die);
path.PushBack({ 0.5f, -0.5f }, 5, &die);
path.PushBack({ 0.5f, -0.2f }, 5, &die);
path.PushBack({ 0.5f, 0.0f }, 5, &die);
path.PushBack({ 0.5f, 0.2f }, 5, &die);
path.PushBack({ 0.5f, 0.5f }, 5, &die);
path.PushBack({ 0.5f, 1.0f }, 5, &die);
path.PushBack({ 0.5f, 1.2f }, 5, &die);
path.PushBack({ 0.5f, 1.5f }, 5, &die);
path.PushBack({ 0.5f, 2.0f }, 1000, &die);
original_pos.x = x;
original_pos.y = y;
}
void EnemyPilot::Move()
{
position = original_pos + path.GetCurrentSpeed(&animation);
// protection to autokill enemy if the scene doesnt kill it
if (position.y >= SCREEN_SIZE * SCREEN_HEIGHT) {
killMe = true;
}
}
void EnemyPilot::Draw() {
SDL_Rect PilotRect = die.GetCurrentFrame();
App->render->Blit(enemyTex, position.x, position.y, &PilotRect);
}