-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnemy.cpp
More file actions
42 lines (32 loc) · 713 Bytes
/
Enemy.cpp
File metadata and controls
42 lines (32 loc) · 713 Bytes
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
#include "Enemy.h"
Enemy::Enemy(const Sprite& sprite) noexcept : GameComponent(sprite)
{
this->init();
}
Enemy::Enemy(const Enemy& copy) noexcept : GameComponent(copy.sprite)
{
this->init();
}
void Enemy::init() noexcept
{
this->reset();
++Enemy::s_seed;
}
void Enemy::reset() noexcept
{
this->basePosition = { (seed % 10) * 60 + 120.f, (seed / 10) * 60 + 70.f };
this->position = this->basePosition;
this->size = { (10 + ((seed) % 17)) * 2, (10 + ((seed) % 17)) * 2 };
this->visible = true;
}
void Enemy::tick(const Time time)
{
if (!this->visible)
{
return;
}
// Let the brain to do its work = compute new position
// Compute bounding box
this->recomputeBoundingBox();
this->draw();
}