-
Notifications
You must be signed in to change notification settings - Fork 3
/
fakewall.cpp
51 lines (45 loc) · 889 Bytes
/
fakewall.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
#include "fakewall.h"
#include "constants.h"
#include "player.h"
#include "fruit.h"
FakeWall::FakeWall()
: Object(fake_wall)
{
spr = 64;
if_not_fruit = true;
}
void FakeWall::init()
{
hitbox.x = 0;
hitbox.y = 0;
hitbox.w = 16;
hitbox.h = 16;
}
void FakeWall::update()
{
hitbox.x = -1;
hitbox.y = -1;
hitbox.w = 18;
hitbox.h = 18;
Object * hit = collide(player, 0, 0);
if (hit && static_cast<Player*>(hit)->dash_effect_time > 0)
{
hit->spd.x = -sign(hit->spd.x) * 1.5;
hit->spd.y = -1.5;
static_cast<Player*>(hit)->dash_time = -1;
destroy_object(this);
Fruit * fruit = new Fruit;
init_object(fruit, x+4, y+4);
}
hitbox.x = 0;
hitbox.y = 0;
hitbox.w = 16;
hitbox.h = 16;
}
void FakeWall::draw()
{
drawSprite(64, x, y);
drawSprite(65, x + 8, y);
drawSprite(80, x, y + 8);
drawSprite(81, x + 8, y + 8);
}