-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathballoon.cpp
More file actions
52 lines (48 loc) · 757 Bytes
/
balloon.cpp
File metadata and controls
52 lines (48 loc) · 757 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
43
44
45
46
47
48
49
50
51
52
#include "balloon.h"
#include "player.h"
Balloon::Balloon()
: Object(balloon)
{
spr = 22;
}
void Balloon::init()
{
offset = rnd(1);
start = y;
timer = 0;
hitbox.x = -1;
hitbox.y = -1;
hitbox.w = 10;
hitbox.h = 10;
}
void Balloon::update()
{
if (spr == 22)
{
offset += 0.04;
y = start + sin(offset) * 2;
Object * hit = collide(player, 0, 0);
if (hit && static_cast<Player*>(hit)->djump < max_djump)
{
static_cast<Player*>(hit)->djump = max_djump;
spr = 0;
timer = 60;
}
}
else if (timer > 0)
{
timer--;
}
else
{
spr = 22;
}
}
void Balloon::draw()
{
if (spr == 22)
{
drawSprite(13 + static_cast<int>(offset * 2) % 3, x, y + 6);
drawSprite(spr, x, y);
}
}