Description: You can reference an array's members by using the "[]" syntax. You can also overload the "[]" operator for a class if you want the behavior of array index references to be unique for this class.
Code Sample:
def random_target_enemy(hp0 = false)
roulette = []
for enemy in @enemies
if (not hp0 and enemy.exist?) or (hp0 and enemy.hp0?)
roulette.push(enemy)
end
end
if roulette.size == 0
return nil
end
return roulette[rand(roulette.size)]
end
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.