Game Development Reference
In-Depth Information
Target practice
But what if we blow ourselves up by shooting nearby? We would still be able to move
around. To fix this, we will simply cut out player input when we are dead:
class
PlayerInput
<
Component
# ...
def
update
returnif
object
.
health
.
dead?
# ...
end
# ...
end
And to prevent tank from throttling forever if the pedal was down before it got killed:
class
TankPhysics
<
Component
# ...
def
update
if
object
.
throttle_down
&& !
object
.
health
.
dead?
accelerate
else
decelerate
end
# ...
end
# ...
end
That's it. All we need right now is some resistance from those brain dead enemies. We will
spark some life into them in next chapter.