-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspring.cpp
73 lines (66 loc) · 1 KB
/
spring.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "spring.h"
#include "player.h"
#include "fallfloor.h"
Spring::Spring()
: Object(spring)
{
spr = 18;
}
void Spring::init()
{
hide_in = 0;
hide_for = 0;
}
void Spring::update()
{
if (hide_for > 0)
{
hide_for--;
if (hide_for <= 0)
{
spr = 18;
delay = 0;
}
}
else if (spr == 18)
{
Object * hit = collide(player, 0, 0);
if (hit && hit->spd.y >= 0)
{
spr = 19;
hit->y = y - 4;
hit->spd.x *= 0.2;
hit->spd.y = -3;
static_cast<Player*>(hit)->djump = max_djump;
delay = 10;
// breakable below us
Object * below = collide(fall_floor, 0, 1);
if (below)
{
static_cast<FallFloor*>(below)->break_fall_floor();
}
}
}
else if (delay > 0)
{
delay--;
if (delay <= 0)
{
spr = 18;
}
}
// begin hiding
if (hide_in > 0)
{
hide_in--;
if (hide_in <= 0)
{
hide_for = 60;
spr = 0;
}
}
}
void Spring::break_spring()
{
hide_in = 15;
}