/
PowerUpsMushroom.cpp
65 lines (53 loc) · 1.27 KB
/
PowerUpsMushroom.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
#include "PowerUpsMushroom.h"
#include "GFX.h"
#include "GVC.h"
PowerUpsMushroom::PowerUpsMushroom()
{
width = al_get_bitmap_width(GFX::mushroom);
height = al_get_bitmap_height(GFX::mushroom);
resetSpeed();
}
PowerUpsMushroom::~PowerUpsMushroom()
{
//dtor
}
void PowerUpsMushroom::makeEffect(Player& player)
{
if(player.getDead()) return;
if(player.getLife() < 2)
{
player.setLife(player.getLife() + 1);
al_stop_sample_instance(GFX::powerupInstance);
al_play_sample_instance(GFX::powerupInstance);
}
else
{
GVC::score->add(250);
al_stop_sample_instance(GFX::oneupInstance);
al_play_sample_instance(GFX::oneupInstance);
}
GVC::gameSpeed -= 0.5;
}
void PowerUpsMushroom::resetSpeed()
{
setSpeed(-0.02,0);
}
void PowerUpsMushroom::update(Player& player, Plataforma& plataforma1, Plataforma& plataforma2, Plataforma& plataforma3)
{
if(!locked)
{
ObjectInGame::update();
collidePlayer(player);
collidePlatform(plataforma1);
collidePlatform(plataforma2);
collidePlatform(plataforma3);
fall = true;
}
}
void PowerUpsMushroom::draw()
{
if(able)
{
al_draw_bitmap(GFX::mushroom,position.getX(),position.getY(),0);
}
}