Game Development Reference
In-Depth Information
54
end
55
else
56
new_state
=
@roaming_state
57
end
58
set_state(new_state)
59
end
60
end
All the logic is in
choose_state
method, which is pretty ugly and procedural, but it
does the job. The code should be easy to understand, so instead of describing it, here is a
picture worth thousand words:
First real battle
You may notice a new crosshair, which replaced the old one that was never visible:
class
Camera
# ...
def
draw_crosshair
factor
= 0.5
x
=
$window
.
mouse_x
y
=
$window
.
mouse_y
c
=
crosshair
c
.
draw(x
-
c
.
width
*
factor
/ 2
,
y
-
c
.
height
*
factor
/ 2
,
1000
, factor, factor)
end
# ...
private
def
crosshair
@crosshair
||=
Gosu
::
Image
.
new(
$window
,
Utils
.
media_path(
'c_dot.png'
),
false
)
end
end