Game Development Reference
In-Depth Information
86 ! @scene_ready || @explosions . any?
87 end
88
89 def draw
90 @scene_ready ||= true
91 @background . draw( 0 , 0 , 0 )
92 @explosions . map( & :draw )
93 end
94 end
95
96 window = GameWindow . new
97 window . show
Run it and click around to enjoy those beautiful special effects:
$ ruby 01-hello/hello_animation.rb
Multiple explosions on screen
Now let's figure out how it works. Our GameWindow initializes with @background
Gosu::Image and @animation , that holds array of Gosu::Image instances, one for
each frame of explosion. Gosu::Image.load_tiles handles it for us.
Explosion::SPRITE points to “tileset” image, which is just a regular image that
contains equally sized smaller image frames arranged in ordered sequence. Rows of frames
are read left to right, like you would read a topic.
Search WWH ::




Custom Search