Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F145195
credits.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
credits.cpp
View Options
#include
<array>
#include
"credits.h"
#include
<iostream>
Credits
::
Credits
(
sf
::
Font
*
gameFont
)
:
txtInterval
(
2
),
timeCounter
(
0
),
txtState
(
state_nothing
),
txtNumber
(
0
)
{
creditsTxt
[
0
]
=
"for Olaf & Igor, on their birthday"
;
creditsTxt
[
1
]
=
"game design, code, audio: bluszcz"
;
creditsTxt
[
2
]
=
"game design, visual art: ukata"
;
creditsTxt
[
3
]
=
"game design, tests: igor & olaf"
;
text
.
setFont
(
*
gameFont
);
text
.
setCharacterSize
(
30
);
setTxt
(
0
);
text
.
setString
(
"asdasd"
);
text
.
setFont
(
*
gameFont
);
text
.
setColor
(
sf
::
Color
(
sf
::
Color
::
White
));
}
void
Credits
::
setTxt
(
int
number
)
{
text
.
setString
(
creditsTxt
[
number
]);
sf
::
FloatRect
rectTxt
=
text
.
getLocalBounds
();
text
.
setPosition
(((
1360
/
2
)
-
(
rectTxt
.
width
/
2
)),((
768
*
0.85
)
-
(
rectTxt
.
height
/
2
)));
}
void
Credits
::
update
(
sf
::
Time
frameTime
)
{
timeCounter
+=
frameTime
.
asSeconds
();
if
(
timeCounter
>
txtInterval
){
changeState
();
}
float
ratio
=
255
/
2
;
if
(
txtState
==
state_fade_in
)
{
text
.
setColor
(
sf
::
Color
(
255
,
255
,
255
,
ratio
*
timeCounter
));
}
else
if
(
txtState
==
state_fade_out
)
{
text
.
setColor
(
sf
::
Color
(
255
,
255
,
255
,
255
-
(
ratio
*
timeCounter
)));
}
else
if
(
txtState
==
state_text
)
{
text
.
setColor
(
sf
::
Color
(
255
,
255
,
255
,
255
));
}
}
void
Credits
::
draw
(
sf
::
RenderTarget
&
target
,
sf
::
RenderStates
states
)
const
{
if
(
txtState
!=
state_nothing
)
{
states
.
transform
*=
getTransform
();
target
.
draw
(
text
,
states
);
}
}
void
Credits
::
changeState
(){
timeCounter
=
0
;
if
(
txtState
==
state_nothing
)
{
txtState
=
state_fade_in
;
return
;
}
if
(
txtState
==
state_fade_in
)
{
txtState
=
state_text
;
return
;
}
if
(
txtState
==
state_text
)
{
txtState
=
state_fade_out
;
return
;
}
if
(
txtState
==
state_fade_out
)
{
txtState
=
state_nothing
;
txtNumber
+=
1
;
if
(
txtNumber
>
3
)
{
txtNumber
=
0
;
}
setTxt
(
txtNumber
);
return
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Aug 16, 5:05 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
77374
Default Alt Text
credits.cpp (2 KB)
Attached To
Mode
R82 deerportal
Attached
Detach File
Event Timeline