-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEnemy.cpp
39 lines (32 loc) · 840 Bytes
/
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
#include "Application.h"
#include "Enemy.h"
#include "ModuleCollision.h"
#include "ModuleParticles.h"
#include "ModuleRender.h"
#include "ModulePlayer.h"
#include "ModuleAudio.h"
#include "ModuleSceneStage4.h"
Enemy::Enemy(int x, int y) : position(x, y)
{
}
Enemy::~Enemy()
{
if (collider != nullptr)
collider->to_delete = true;
}
const Collider* Enemy::GetCollider() const
{
return collider;
}
void Enemy::Draw(SDL_Texture* sprites,float flip)
{
if (collider != nullptr)
collider->SetPos(position.x + offset.x, position.y + offset.y);
if (animation != nullptr)
App->render->Blit(sprites, position.x, position.y, &(animation->GetCurrentFrame()),1.0f,flip);
}
void Enemy::OnCollision(Collider* collider)
{
App->particles->AddParticle(App->particles->explosion_enemy, position.x, position.y);
App->player->score += score;
}