-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop.cpp
82 lines (70 loc) · 1.69 KB
/
drop.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
74
75
76
77
78
79
80
81
82
#include "drop.h"
using namespace sf;
using namespace std;
Drop::Drop(int score, sf::Vector2f position):
m_speed(200),
m_frameWidth(50),
m_score(score),
m_frameHeight(50),
m_position(position)
{
m_image = new Image();
//Choix de l'image en fonction du score
switch(score)
{
case 50:
*m_image = image_manager::getInstance()->getImage("images/Vie.png");
break;
case 100:
*m_image = image_manager::getInstance()->getImage("images/Vie.png");
break;
case 500:
*m_image = image_manager::getInstance()->getImage("images/Vie-fade.png");
break;
}
if(score > 500)
*m_image = image_manager::getInstance()->getImage("images/Vie-fade.png");
m_image->CreateMaskFromColor(Color(255, 0, 255));
sprite.SetImage(*m_image);
sprite.SetPosition(m_position);
}
Drop::~Drop()
{
delete m_image;
}
unsigned short Drop::getScore()
{
return m_score;
}
Sprite Drop::getSprite()
{
return sprite;
}
Vector2f Drop::getPosition()
{
return m_position;
}
void Drop::setPosition(Vector2f position)
{
m_position = position;
sprite.Move(0,10);
}
short Drop::getSpeed() const
{
return m_speed;
}
void Drop::move(Vector2f position, Vector2f speed)
{
m_position = position;
sprite.Move(speed);
}
IntRect Drop::getBoundingBox()
{
//Récupère le rectangle de collision pour le drop
IntRect boundingBox;
boundingBox.Left = m_position.x;
boundingBox.Right = boundingBox.Left + m_frameWidth;
boundingBox.Top = m_position.y;
boundingBox.Bottom = boundingBox.Top + m_frameHeight;
return boundingBox;
}