Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F145279
bubble.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
947 B
Referenced Files
None
Subscribers
None
bubble.cpp
View Options
#include
<cmath>
#include
<array>
#include
"bubble.h"
Bubble
::
Bubble
()
:
state
(
BubbleState
::
DICE
),
timeCounter
(
0
),
posY
(
0
)
{
spritesBubbles
=
{{
spriteDice
,
spriteFootSteps
}};
if
(
!
textureDice
.
loadFromFile
(
"assets/img/bubble_dice.png"
))
std
::
exit
(
1
);
if
(
!
textureFootSteps
.
loadFromFile
(
"assets/img/bubble_footsteps.png"
))
std
::
exit
(
1
);
spritesBubbles
[
0
].
setTexture
(
textureDice
);
spritesBubbles
[
1
].
setTexture
(
textureFootSteps
);
}
void
Bubble
::
setPosition
(
float
x
,
float
y
)
{
Transformable
::
setPosition
(
x
,
y
);
posY
=
y
;
}
void
Bubble
::
draw
(
sf
::
RenderTarget
&
target
,
sf
::
RenderStates
states
)
const
{
states
.
transform
*=
getTransform
();
target
.
draw
(
spritesBubbles
[
state
],
states
);
}
void
Bubble
::
update
(
sf
::
Time
deltaTime
)
{
timeCounter
+=
deltaTime
.
asSeconds
()
*
10
;
float
modifier
=
sin
(
timeCounter
)
*
5
;
Transformable
::
setPosition
(
getPosition
().
x
,
posY
+
modifier
);
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Aug 16, 8:41 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
77436
Default Alt Text
bubble.cpp (947 B)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline