-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpikePair.cpp
52 lines (40 loc) · 1.17 KB
/
SpikePair.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
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "SpikePair.hpp"
#include "RectangleFunctions.hpp"
#include "Renderer.hpp"
#include "Spritesheet.hpp"
namespace TappyPlane {
using namespace SDLW::Video;
static auto& topSpikeSourceBounds()
{
static auto bounds = Spritesheet::instance().sourceBounds("topSpike");
return bounds;
}
static auto& bottomSpikeSourceBounds()
{
static auto bounds = Spritesheet::instance().sourceBounds("bottomSpike");
return bounds;
}
constexpr Rectangle topSpikeBounds{0, -10, 409, 902};
constexpr Rectangle bottomSpikeBounds{0, canvasBounds.height() - 902, 409, 902};
SpikePair::SpikePair()
: topSpikeBounds(TappyPlane::topSpikeBounds)
, bottomSpikeBounds(TappyPlane::bottomSpikeBounds)
{
}
int SpikePair::x() const noexcept
{
return topSpikeBounds.x();
}
void SpikePair::setX(const int value) noexcept
{
topSpikeBounds.setX(value);
bottomSpikeBounds.setX(value);
}
void SpikePair::draw() const
{
Renderer::instance().copy(Spritesheet::instance().texture(),
topSpikeSourceBounds(), topSpikeBounds);
Renderer::instance().copy(Spritesheet::instance().texture(),
bottomSpikeSourceBounds(), bottomSpikeBounds);
}
} // namespace TappyPlane