Game Development Reference
In-Depth Information
19
if
@health
.
nil?
||
@tank
.
health
.
health
!=
@health
20
@health
=
@tank
.
health
.
health
@health_image
=
Gosu
::
Image
.
from_text(
21
$window
,
"Health:
#{
@health
}
"
,
Utils
.
main_font,
20
)
22
23
end
24
@health_image
25
end
26
27
def
stats_image
28
stats
=
@tank
.
input
.
stats
29
if
@stats_image
.
nil?
||
stats
.
changed_at
<=
Gosu
.
milliseconds
30
@stats_image
=
Gosu
::
Image
.
from_text(
$window
,
"Kills:
#{
stats
.
kills
}
"
,
Utils
.
main_font,
20
)
31
32
end
33
@stats_image
34
end
35
36
def
fire_rate_image
37
if
@tank
.
fire_rate_modifier
> 1
38
if
@fire_rate
!=
@tank
.
fire_rate_modifier
39
@fire_rate
=
@tank
.
fire_rate_modifier
@fire_rate_image
=
Gosu
::
Image
.
from_text(
40
$window
,
"Fire rate:
#{
@fire_rate
.
round(
2
)
}
X"
,
41
Utils
.
main_font,
20
)
42
43
end
44
else
45
@fire_rate_image
=
nil
46
end
47
@fire_rate_image
48
end
49
50
def
speed_image
51
if
@tank
.
speed_modifier
> 1
52
if
@speed
!=
@tank
.
speed_modifier
53
@speed
=
@tank
.
speed_modifier
@speed_image
=
Gosu
::
Image
.
from_text(
54
$window
,
"Speed:
#{
@speed
.
round(
2
)
}
X"
,
55
Utils
.
main_font,
20
)
56
57
end
58
else
59
@speed_image
=
nil
60
end
61
@speed_image
62
end
63
64
def
draw