Game Development Reference
In-Depth Information
9
10 def sound
11
@@sound ||= StereoSample . new(
$window , Utils . media_path( 'explosion.mp3' ))
12
13 end
14 end
15 end
After wiring everything so that sound components have access to ObjectPool , the rest
is straightforward.
Giving Enemies Identity
Wouldn't it be great if you could tell yourself apart from the enemies. Moreover, enemies
could have names, so you would know which one is more aggressive or have, you know,
personal issues with someone.
To do that we need to ask the player to input a nickname, and choose some funny names
for each enemy AI. Here is a nice list we will grab: http://www.paulandstorm.com/wha/
clown-names/
We first compile everything into a text filed called names.txt , that looks like this:
media/names.txt
Strippy
Boffo
Buffo
Drips
. . .
Now we need a class to parse the list and give out random names from it. We also want to
limit name length to something that displays nicely.
09-polishing/misc/names.rb
1 class Names
2 def initialize (file)
3 @names = File . read(file) . split( " \n " ) . reject do | n |
4 n . size > 12
5 end
6 end
7
8 def random
Search WWH ::




Custom Search