-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparticle_beam.cpp
More file actions
39 lines (29 loc) · 910 Bytes
/
particle_beam.cpp
File metadata and controls
39 lines (29 loc) · 910 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
#include "particle_beam.h"
#include "precomp.h"
namespace Tmpl8
{
Particle_beam::Particle_beam() : min_position(), max_position(), particle_beam_sprite(nullptr), sprite_frame(0), rectangle(), damage(1)
{
}
Particle_beam::Particle_beam(vec2 min, vec2 max, Sprite* particle_beam_sprite, int damage) : particle_beam_sprite(particle_beam_sprite), sprite_frame(0), damage(damage)
{
min_position = min;
max_position = min + max;
rectangle = Rectangle2D(min_position, max_position);
}
void Particle_beam::tick()
{
if (++sprite_frame == 30)
{
sprite_frame = 0;
}
}
void Particle_beam::Draw(Surface* screen)
{
vec2 position = rectangle.min;
const int offsetX = 23;
const int offsetY = 137;
particle_beam_sprite->SetFrame(sprite_frame / 10);
particle_beam_sprite->Draw(screen, (int)(position.x - offsetX), (int)(position.y - offsetY));
}
} // namespace Tmpl8