-
Notifications
You must be signed in to change notification settings - Fork 1
Trait: Pod
floere edited this page Sep 14, 2010
·
2 revisions
Use this if you need a thing that can have other things attached.
The Shot trait can be applied as usual:
class Tank < Thing
it_is_a Pod
or
class Tank < Thing
it_is_a Pod do
# …
end
Pod just has one property attach
, which defines what is attached.
class Tank < Thing
# …
attach MainGun, 5, 5
Pod installs basically two methods, attach
and detach
.
The first of these, attach <thing>, x, y
can be used to dynamically attach something. The is an instance of a thing.
class BattleCruiser < Thing
# …
def damaged!
attach BlastHole, (rand-0.5)*20, (rand-0.5)*20
end
The second, detach <thing>
can be used to again remove the thing from the other thing. It will then freely move, obeying gravity and what not.