-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBalls.cpp
96 lines (77 loc) · 1.74 KB
/
Balls.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "Balls.h"
void Balls::initVariables()
{
}
void Balls::initShape(const RenderWindow& window)
{
//random color and radius
this->shape.setRadius(static_cast<float>(rand() % 20 + 3));
//switch for deciding type color
Color color;
switch(this->type)
{
case balltypes::DEFAULT:
this->shape.setFillColor(Color(rand() % 255 + 1, rand() % 255 + 1, rand() % 255 + 1, 255));
this->shape.setOutlineColor(Color::Red);
this->shape.setOutlineThickness(2.f);
break;
case balltypes::DAMAGING:
this->shape.setFillColor(Color::Red);
this->shape.setOutlineColor(Color::White);
this->shape.setOutlineThickness(2.f);
break;
case balltypes::HEALING:
this->shape.setFillColor(Color::Green);
this->shape.setOutlineColor(Color::White);
this->shape.setOutlineThickness(2.f);
break;
default:
break;
}
this->shape.setPosition(
Vector2f(
static_cast <float>(rand() % window.getSize().x - this->getGlobadBounds().width),
static_cast <float>(rand() % window.getSize().y - this->getGlobadBounds().height)
)
);
}
// Balls::Balls()
// {
// this->initVariables();
// this->initShape();
// }
Balls::Balls(RenderWindow& window, int type):type(type)
{
this->initVariables();
this->initShape(window);
}
Balls::~Balls()
{
}
const FloatRect Balls::getGlobadBounds() const
{
return FloatRect();
}
const CircleShape Balls::getShape() const
{
return this->shape;
}
const int& Balls::gettype() const
{
return this->type;
}
void Balls::updateinput()
{
}
// void Balls::update(RenderTarget& target)
// {
// this->shape.move(0.f, 1.f);
// if (this->shape.getPosition().y > target.getSize().y)
// {
// this->shape.setPosition(Vector2f(rand() % 700 + 1, 0.f));
// }
// }
void Balls::render(RenderTarget& target)
{
target.draw(this->shape);
}