Game Development Reference
In-Depth Information
$debug
= !
$debug
end
# ...
end
# ...
end
Then add extra drawing instructions to your objects and their components. For example,
this will make
Tank
display it's current
TankMotionState
implementation class
beneath it:
class
TankMotionFSM
# ...
def
set_state
(state)
# ...
if
$debug
@image
=
Gosu
::
Image
.
from_text(
$window
, state
.
class
.
to_s,
Gosu
.
default_font_name,
18
)
end
end
# ...
def
draw
(viewport)
if
$debug
@image
&&
@image
.
draw(
@object
.
x
-
@image
.
width
/ 2
,
@object
.
y
+
@object
.
graphics
.
height
/ 2 -
@image
.
height,
100
)
end
end
# ...
end
To mark tank's desired gun angle as blue line and actual gun angle as red line, you can do
this:
class
AiGun
# ...
def
draw
(viewport)
if
$debug
color
=
Gosu
::
Color
::
BLUE
x, y
=
@object
.
x,
@object
.
y
t_x, t_y
=
Utils
.
point_at_distance(x, y,
@desired_gun_angle
,
BulletPhysics
::
MAX_DIST
)
$window
.
draw_line(x, y, color, t_x, t_y, color,
1001
)