-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEnemyRedbird.cpp
More file actions
67 lines (52 loc) · 1.31 KB
/
EnemyRedbird.cpp
File metadata and controls
67 lines (52 loc) · 1.31 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
60
61
62
63
64
65
66
67
#include "Application.h"
#include "EnemyRedbird.h"
#include "ModuleCollision.h"
#include "ModuleEnemies.h"
#include "ModuleParticles.h"
#include "ModuleRender.h"
EnemyRedbird::EnemyRedbird(int x, int y, powerUpTypes type, SDL_Texture* thisTexture) : Enemy(x, y)
{
//links correct spritesheet texture
enemyTex = thisTexture;
waveAnim.PushBack({ 0,0,26,29 });
waveAnim.PushBack({ 26,0,26,29 });
waveAnim.PushBack({ 52,0,26,29 });
waveAnim.PushBack({ 78,0,26,29 });
waveAnim.PushBack({ 104,0,26,29 });
waveAnim.PushBack({ 130,0,26,29 });
waveAnim.PushBack({ 156,0,27,29 });
waveAnim.PushBack({ 183,0,26,29 });
waveAnim.speed = 0.125f;
animation = &waveAnim;
powerUpType = type;
collider = App->collision->AddCollider({ 0, 14, 26, 18 }, COLLIDER_TYPE::COLLIDER_ENEMY, (Module*)App->enemies);
original_y = y;
life = 1;
enemyScore = 100;
}
void EnemyRedbird::Move()
{
//update collider pos
if (collider != nullptr)
collider->SetPos(position.x, position.y + 7);
if (going_up)
{
if (wave > 1.0f)
going_up = false;
else
wave += 0.08f;
}
else
{
if (wave < -1.0f)
going_up = true;
else
wave -= 0.08f;
}
position.y = original_y + int(20.0f * sinf(wave));
position.x -= 1;
}
void EnemyRedbird::Draw()
{
App->render->Blit(enemyTex, position.x, position.y, &waveAnim.GetCurrentFrame());
}