Class: GamesAndRpgParadise::ParticleSimulator::Hunter
- Inherits:
-
Entity
- Object
- Entity
- GamesAndRpgParadise::ParticleSimulator::Hunter
show all
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb
Constant Summary
Constants inherited
from Entity
Entity::CAP, Entity::DAMPEN
Instance Attribute Summary collapse
Attributes inherited from Entity
#vx, #vy, #x
Instance Method Summary
collapse
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#initialize(game, color) ⇒ Hunter
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#update(preys) ⇒ Object
# === update ========================================================================= #.
Methods inherited from Entity
#accelerate, #find_closest, #move, #y?
Constructor Details
#initialize(game, color) ⇒ Hunter
18
19
20
21
22
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 18
def initialize(game, color)
super(game) @color = color
reset
end
|
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
13
14
15
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 13
def color
@color
end
|
#frags ⇒ Object
Returns the value of attribute frags.
12
13
14
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 12
def frags
@frags
end
|
Instance Method Details
#draw ⇒ Object
65
66
67
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 65
def draw
@game.draw_square(@x, @y, H_RADIUS, @color)
end
|
#reset ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 27
def reset
@accel = H_ACCEL
@frags = 0
end
|
#update(preys) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/games_and_rpg_paradise/gui/gosu/particle_simulator/hunter.rb', line 41
def update(preys)
closest = find_closest(preys)
if Gosu.distance(closest.x, closest.y, @x, @y) < 5
closest.eaten = true
@frags += 1
end
accelerate(
Gosu.angle(@x, @y, closest.x, closest.y)
)
move
end
|