-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBullet.hpp
More file actions
43 lines (33 loc) · 1.06 KB
/
Bullet.hpp
File metadata and controls
43 lines (33 loc) · 1.06 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
#ifndef EXAMPLE_BULLET_HPP
#define EXAMPLE_BULLET_HPP
#include <Tails/World/Actor.hpp>
#include <Tails/World/Components/SpriteComponent.hpp>
#include <Tails/Assets/AssetPtr.hpp>
#include <Tails/Assets/Texture.hpp>
class CBullet final : public tails::CActor
{
public:
CBullet()
{
m_spriteComponent = createComponent<tails::CSpriteComponent>();
m_spriteComponent->size = {16.f, 16.f};
m_spriteComponent->colour = tails::SColour::yellow;
//m_spriteComponent->texture = m_texture.load();
setRootComponent(m_spriteComponent);
}
tails::SVector2f moveDirection;
private:
void onTick(const float deltaSeconds) override
{
move(moveDirection * m_speed * deltaSeconds);
m_lifeTimer += deltaSeconds;
// destroy ourselves after a bit
if (m_lifeTimer >= 0.5f)
destroy();
}
tails::CSpriteComponent* m_spriteComponent;
float m_speed {750.f};
float m_lifeTimer {0.f};
tails::TAssetPtr<tails::CTexture> m_texture {"face.png"};
};
#endif // EXAMPLE_BULLET_HPP