Game Development Reference
In-Depth Information
54 Gosu . default_font_name, font_size)
55 @health_updated = false
56 end
57 end
58
59 def after_death
60 if @explodes
61 if Thread . list . count < 8
62 Thread . new do
63 sleep ( rand ( 0.1. . 0.3 ))
64 Explosion . new( @object_pool , x, y)
65 sleep 0.3
66 object . mark_for_removal
67 end
68 else
69 Explosion . new( @object_pool , x, y)
70 object . mark_for_removal
71 end
72 else
73 object . mark_for_removal
74 end
75 end
76 end
Yes, you can make tree explode when it's destroyed. And it causes cool chain reactions
blowing up whole tree clusters. But let's not do that, because we will add something more
appropriate for explosions.
Our Tree is ready to fill the landscape. We will do it in Map class, which will now need
to know about ObjectPool , because trees will go there.
class Map
# ...
def initialize (object_pool)
load_tiles
@object_pool = object_pool
object_pool . map = self
@map = generate_map
generate_trees
end
# ...
def generate_trees
noises = Perlin :: Noise . new( 2 )
contrast = Perlin :: Curve . contrast(
Search WWH ::




Custom Search