line-em-up 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/line-em-up/models/bomb.rb +40 -0
- data/line-em-up/models/bomb_pack.rb +17 -0
- data/line-em-up/models/building.rb +60 -0
- data/line-em-up/models/bullet.rb +43 -0
- data/line-em-up/models/cursor.rb +25 -0
- data/line-em-up/models/enemy_bomb.rb +40 -0
- data/line-em-up/models/enemy_bullet.rb +43 -0
- data/line-em-up/models/enemy_homing_missile.rb +103 -0
- data/line-em-up/models/enemy_player.rb +105 -0
- data/line-em-up/models/footer_bar.rb +164 -0
- data/line-em-up/models/general_object.rb +104 -0
- data/line-em-up/models/gl_background.rb +93 -0
- data/line-em-up/models/grappling_hook.rb +242 -0
- data/line-em-up/models/guidable_torpedo.rb +117 -0
- data/line-em-up/models/health_pack.rb +47 -0
- data/line-em-up/models/menu.rb +31 -0
- data/line-em-up/models/menu_item.rb +74 -0
- data/line-em-up/models/missile.rb +66 -0
- data/line-em-up/models/missile_boat.rb +101 -0
- data/line-em-up/models/missile_pack.rb +17 -0
- data/line-em-up/models/mothership.rb +136 -0
- data/line-em-up/models/pickup.rb +40 -0
- data/line-em-up/models/player.rb +241 -0
- data/line-em-up/models/projectile.rb +244 -0
- data/line-em-up/models/small_explosion.rb +48 -0
- data/line-em-up/models/star.rb +62 -0
- metadata +27 -1
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'projectile.rb'
|
2
|
+
class Missile < Projectile
|
3
|
+
attr_reader :x, :y, :time_alive, :mouse_start_x, :mouse_start_y
|
4
|
+
COOLDOWN_DELAY = 30
|
5
|
+
MAX_SPEED = 25
|
6
|
+
STARTING_SPEED = 0.0
|
7
|
+
INITIAL_DELAY = 2
|
8
|
+
SPEED_INCREASE_FACTOR = 0.5
|
9
|
+
DAMAGE = 50
|
10
|
+
AOE = 0
|
11
|
+
|
12
|
+
MAX_CURSOR_FOLLOW = 4
|
13
|
+
ADVANCED_HIT_BOX_DETECTION = true
|
14
|
+
|
15
|
+
# def hit_objects(object_groups)
|
16
|
+
# puts "HERE: #{self.class.get_damage}"
|
17
|
+
# super(object_groups)
|
18
|
+
# end
|
19
|
+
|
20
|
+
def get_image
|
21
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/missile.png")
|
22
|
+
end
|
23
|
+
|
24
|
+
# def initialize(object, mouse_x = nil, mouse_y = nil, options = {})
|
25
|
+
# @image = get_image
|
26
|
+
|
27
|
+
# if LEFT == options[:side]
|
28
|
+
# @x = object.get_x - (object.get_width / 2)
|
29
|
+
# @y = object.get_y# - player.get_height
|
30
|
+
# elsif RIGHT == options[:side]
|
31
|
+
# @x = (object.get_x + object.get_width / 2) - 4
|
32
|
+
# @y = object.get_y# - player.get_height
|
33
|
+
# else
|
34
|
+
# @x = object.get_x
|
35
|
+
# @y = object.get_y
|
36
|
+
# end
|
37
|
+
# @time_alive = 0
|
38
|
+
# @mouse_start_x = mouse_x
|
39
|
+
# @mouse_start_y = mouse_y
|
40
|
+
# end
|
41
|
+
|
42
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
43
|
+
new_speed = 0
|
44
|
+
if @time_alive > self.class.get_initial_delay
|
45
|
+
new_speed = self.class.get_starting_speed + (self.class.get_speed_increase_factor > 0 ? @time_alive * self.class.get_speed_increase_factor : 0)
|
46
|
+
new_speed = self.class.get_max_speed if new_speed > self.class.get_max_speed
|
47
|
+
new_speed = new_speed * @scale
|
48
|
+
end
|
49
|
+
|
50
|
+
vx = 0
|
51
|
+
vy = 0
|
52
|
+
if new_speed > 0
|
53
|
+
vx = ((new_speed / 3) * 1) * Math.cos(@angle * Math::PI / 180)
|
54
|
+
|
55
|
+
vy = ((new_speed / 3) * 1) * Math.sin(@angle * Math::PI / 180)
|
56
|
+
vy = vy * -1
|
57
|
+
# Because our y is inverted
|
58
|
+
vy = vy - ((new_speed / 3) * 2)
|
59
|
+
end
|
60
|
+
|
61
|
+
@x = @x + vx
|
62
|
+
@y = @y + vy
|
63
|
+
|
64
|
+
super(width, height, mouse_x, mouse_y)
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require_relative 'player.rb'
|
2
|
+
require_relative 'enemy_bullet.rb'
|
3
|
+
require_relative 'enemy_homing_missile.rb'
|
4
|
+
require_relative 'small_explosion.rb'
|
5
|
+
require_relative 'star.rb'
|
6
|
+
|
7
|
+
class MissileBoat < GeneralObject
|
8
|
+
Speed = 5
|
9
|
+
MAX_ATTACK_SPEED = 3.0
|
10
|
+
POINT_VALUE_BASE = 50
|
11
|
+
attr_accessor :cooldown_wait, :attack_speed, :health, :armor, :x, :y
|
12
|
+
|
13
|
+
def initialize(scale, width, height, x = nil, y = nil)
|
14
|
+
@scale = scale
|
15
|
+
# image = Magick::Image::read("#{MEDIA_DIRECTORY}/starfighterv4.png").first
|
16
|
+
# @image = Gosu::Image.new(image, :tileable => true)
|
17
|
+
# @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/starfighterv4.png")
|
18
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/missile_boat_reverse.png")
|
19
|
+
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
20
|
+
@x = x || rand(width)
|
21
|
+
@y = y || 0
|
22
|
+
@cooldown_wait = 0
|
23
|
+
@attack_speed = 0.5
|
24
|
+
@health = 10
|
25
|
+
@armor = 0
|
26
|
+
@image_width = @image.width * @scale
|
27
|
+
@image_height = @image.height * @scale
|
28
|
+
@image_size = @image_width * @image_height / 2
|
29
|
+
@image_radius = (@image_width + @image_height) / 4
|
30
|
+
@current_speed = (rand(5) * @scale).round + 1
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_points
|
34
|
+
return POINT_VALUE_BASE
|
35
|
+
end
|
36
|
+
|
37
|
+
def is_alive
|
38
|
+
@health > 0
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def take_damage damage
|
43
|
+
@health -= damage
|
44
|
+
end
|
45
|
+
|
46
|
+
def attack width, height, player
|
47
|
+
return {
|
48
|
+
projectiles: [EnemyHomingMissile.new(@scale, width, height, self, nil, nil, player)],
|
49
|
+
cooldown: EnemyHomingMissile::COOLDOWN_DELAY
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def drops
|
55
|
+
[
|
56
|
+
SmallExplosion.new(@scale, @x, @y, @image),
|
57
|
+
Star.new(@scale, @x, @y)
|
58
|
+
]
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_draw_ordering
|
62
|
+
ZOrder::Enemy
|
63
|
+
end
|
64
|
+
|
65
|
+
# SPEED = 1
|
66
|
+
# def get_speed
|
67
|
+
|
68
|
+
# end
|
69
|
+
|
70
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
71
|
+
@cooldown_wait -= 1 if @cooldown_wait > 0
|
72
|
+
if is_alive
|
73
|
+
# Stay above the player
|
74
|
+
if player.is_alive && player.y < @y
|
75
|
+
@y -= @current_speed
|
76
|
+
else
|
77
|
+
if rand(2).even?
|
78
|
+
@y += @current_speed
|
79
|
+
|
80
|
+
@y = height / 2 if @y > height / 2
|
81
|
+
else
|
82
|
+
@y -= @current_speed
|
83
|
+
|
84
|
+
@y = 0 + (get_height / 2) if @y < 0 + (get_height / 2)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
if rand(2).even?
|
88
|
+
@x += @current_speed
|
89
|
+
@x = width if @x > width
|
90
|
+
else
|
91
|
+
@x -= @current_speed
|
92
|
+
@x = 0 + (get_width / 2) if @x < 0 + (get_width / 2)
|
93
|
+
end
|
94
|
+
|
95
|
+
@y < height + (get_height / 2)
|
96
|
+
else
|
97
|
+
false
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'pickup.rb'
|
2
|
+
|
3
|
+
class MissilePack < Pickup
|
4
|
+
def get_image
|
5
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/missile_pack.png", :tileable => true)
|
6
|
+
end
|
7
|
+
|
8
|
+
def draw
|
9
|
+
# @image.draw_rot(@x, @y, ZOrder::Pickups, @y, 0.5, 0.5, 1, 1)
|
10
|
+
draw_rot()
|
11
|
+
end
|
12
|
+
|
13
|
+
def collected_by_player player
|
14
|
+
player.rockets += 25
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require_relative 'player.rb'
|
2
|
+
require_relative 'enemy_bullet.rb'
|
3
|
+
require_relative 'enemy_homing_missile.rb'
|
4
|
+
require_relative 'small_explosion.rb'
|
5
|
+
require_relative 'star.rb'
|
6
|
+
require_relative 'enemy_bomb.rb'
|
7
|
+
|
8
|
+
class Mothership < GeneralObject
|
9
|
+
Speed = 5
|
10
|
+
MAX_ATTACK_SPEED = 3.0
|
11
|
+
POINT_VALUE_BASE = 1000
|
12
|
+
attr_accessor :cooldown_wait, :attack_speed, :health, :armor, :x, :y, :secondary_cooldown_wait, :tertiary_cooldown_wait
|
13
|
+
|
14
|
+
def initialize(scale, width, height, x = nil, y = nil)
|
15
|
+
@scale = scale
|
16
|
+
# image = Magick::Image::read("#{MEDIA_DIRECTORY}/starfighterv4.png").first
|
17
|
+
# @image = Gosu::Image.new(image, :tileable => true)
|
18
|
+
# @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/starfighterv4.png")
|
19
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/mothership.png")
|
20
|
+
# @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/missile_boat_reverse.png")
|
21
|
+
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
22
|
+
@x = width / 2
|
23
|
+
@y = 0 + @image.height
|
24
|
+
@cooldown_wait = 0
|
25
|
+
@secondary_cooldown_wait = 0
|
26
|
+
@tertiary_cooldown_wait = 0
|
27
|
+
@attack_speed = 0.5
|
28
|
+
@health = 5000
|
29
|
+
@armor = 0
|
30
|
+
@image_width = @image.width * @scale
|
31
|
+
@image_height = @image.height * @scale
|
32
|
+
@image_size = @image_width * @image_height / 2
|
33
|
+
@image_radius = (@image_width + @image_height) / 4
|
34
|
+
@current_speed = (rand(5) * @scale).round + 1
|
35
|
+
end
|
36
|
+
|
37
|
+
def draw
|
38
|
+
# Will generate error if class name is not listed on ZOrder
|
39
|
+
@image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering, @scale, @scale)
|
40
|
+
# @image.draw(@xΩ - @image.width / 2, @y - @image.height / 2, get_draw_ordering)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_points
|
44
|
+
return POINT_VALUE_BASE
|
45
|
+
end
|
46
|
+
|
47
|
+
def is_alive
|
48
|
+
@health > 0
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def take_damage damage
|
53
|
+
@health -= damage
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def attack width, height, player
|
58
|
+
return {
|
59
|
+
projectiles: [
|
60
|
+
EnemyBullet.new(@scale, width, height, self, nil, nil, {side: 'left'}),
|
61
|
+
EnemyBullet.new(@scale, width, height, self, nil, nil, {side: 'right'}),
|
62
|
+
EnemyBullet.new(@scale, width, height, self, nil, nil)
|
63
|
+
],
|
64
|
+
cooldown: EnemyBullet::COOLDOWN_DELAY
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
def secondary_attack width, height, player
|
69
|
+
return {
|
70
|
+
projectiles: [
|
71
|
+
EnemyHomingMissile.new(@scale, width, height, self, nil, nil, player, {side: 'left'}),
|
72
|
+
EnemyHomingMissile.new(@scale, width, height, self, nil, nil, player, {side: 'right'})
|
73
|
+
],
|
74
|
+
cooldown: EnemyHomingMissile::COOLDOWN_DELAY
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def tertiary_attack width, height, player
|
80
|
+
return {
|
81
|
+
projectiles: [EnemyBomb.new(@scale, width, height, self, player.x, player.y)],
|
82
|
+
cooldown: EnemyBomb::COOLDOWN_DELAY
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
def drops
|
88
|
+
[
|
89
|
+
SmallExplosion.new(@scale, @x, @y, @image)
|
90
|
+
# Star.new(@scale, @x, @y)
|
91
|
+
]
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_draw_ordering
|
95
|
+
ZOrder::Enemy
|
96
|
+
end
|
97
|
+
|
98
|
+
# SPEED = 1
|
99
|
+
# def get_speed
|
100
|
+
|
101
|
+
# end
|
102
|
+
|
103
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
104
|
+
@cooldown_wait -= 1 if @cooldown_wait > 0
|
105
|
+
@secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
|
106
|
+
@tertiary_cooldown_wait -= 1 if @tertiary_cooldown_wait > 0
|
107
|
+
if is_alive
|
108
|
+
# Stay above the player
|
109
|
+
if player.is_alive && player.y < @y
|
110
|
+
@y -= @current_speed
|
111
|
+
else
|
112
|
+
if rand(2).even?
|
113
|
+
@y += @current_speed
|
114
|
+
|
115
|
+
@y = height / 2 if @y > height / 2
|
116
|
+
else
|
117
|
+
@y -= @current_speed
|
118
|
+
|
119
|
+
@y = 0 + (get_height / 2) if @y < 0 + (get_height / 2)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
if rand(2).even?
|
123
|
+
@x += @current_speed
|
124
|
+
@x = width if @x > width
|
125
|
+
else
|
126
|
+
@x -= @current_speed
|
127
|
+
@x = 0 + (get_width / 2) if @x < 0 + (get_width / 2)
|
128
|
+
end
|
129
|
+
|
130
|
+
@y < height + (get_height / 2)
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'general_object.rb'
|
2
|
+
|
3
|
+
class Pickup < GeneralObject
|
4
|
+
POINT_VALUE_BASE = 0
|
5
|
+
attr_reader :x, :y
|
6
|
+
|
7
|
+
def initialize(scale, x = nil, y = nil)
|
8
|
+
@scale = scale
|
9
|
+
@image = get_image
|
10
|
+
@x = x
|
11
|
+
@y = y
|
12
|
+
@time_alive = 0
|
13
|
+
@image_width = @image.width * @scale
|
14
|
+
@image_height = @image.height * @scale
|
15
|
+
@image_size = @image_width * @image_height / 2
|
16
|
+
@image_radius = (@image_width + @image_height) / 4
|
17
|
+
@current_speed = SCROLLING_SPEED * @scale
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_draw_ordering
|
21
|
+
ZOrder::Pickups
|
22
|
+
end
|
23
|
+
|
24
|
+
# def draw
|
25
|
+
# # @image.draw_rot(@x, @y, ZOrder::Pickups, @y, 0.5, 0.5, 1, 1)
|
26
|
+
# raise "override me!"
|
27
|
+
# end
|
28
|
+
|
29
|
+
|
30
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
31
|
+
@y += @current_speed
|
32
|
+
|
33
|
+
super(width, height, mouse_x, mouse_y)
|
34
|
+
end
|
35
|
+
|
36
|
+
def collected_by_player player
|
37
|
+
raise "Override me!"
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,241 @@
|
|
1
|
+
require_relative 'general_object.rb'
|
2
|
+
|
3
|
+
class Player < GeneralObject
|
4
|
+
SPEED = 7
|
5
|
+
MAX_ATTACK_SPEED = 3.0
|
6
|
+
attr_accessor :cooldown_wait, :secondary_cooldown_wait, :attack_speed, :health, :armor, :x, :y, :rockets, :score, :time_alive, :bombs, :secondary_weapon, :grapple_hook_cooldown_wait
|
7
|
+
MAX_HEALTH = 200
|
8
|
+
|
9
|
+
SECONDARY_WEAPONS = %w[missile bomb]
|
10
|
+
|
11
|
+
# def draw
|
12
|
+
# # Will generate error if class name is not listed on ZOrder
|
13
|
+
# @image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering || Module.const_get("ZOrder::#{self.class.name}"))
|
14
|
+
# # @image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering)
|
15
|
+
# end
|
16
|
+
def initialize(scale, x, y)
|
17
|
+
@scale = scale
|
18
|
+
# image = Magick::Image::read("#{MEDIA_DIRECTORY}/spaceship.png").first.resize(0.3)
|
19
|
+
# @image = Gosu::Image.new(image, :tileable => true)
|
20
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship.png")
|
21
|
+
@right_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_right.png")
|
22
|
+
@left_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_left.png")
|
23
|
+
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
24
|
+
@x, @y = x, y
|
25
|
+
@score = 0
|
26
|
+
@cooldown_wait = 0
|
27
|
+
@secondary_cooldown_wait = 0
|
28
|
+
@grapple_hook_cooldown_wait = 0
|
29
|
+
@attack_speed = 1
|
30
|
+
# @attack_speed = 3
|
31
|
+
# temp
|
32
|
+
@health = 100
|
33
|
+
# @health = 100000
|
34
|
+
@armor = 0
|
35
|
+
@rockets = 25
|
36
|
+
# @rockets = 25000
|
37
|
+
# @rocket_launcher = {}
|
38
|
+
@bombs = 3
|
39
|
+
# @bombs = 300
|
40
|
+
@time_alive = 0
|
41
|
+
@secondary_weapon = "missile"
|
42
|
+
@turn_right = false
|
43
|
+
@turn_left = false
|
44
|
+
@image_width = @image.width * @scale
|
45
|
+
@image_height = @image.height * @scale
|
46
|
+
@image_size = @image_width * @image_height / 2
|
47
|
+
@image_radius = (@image_width + @image_height) / 4
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def take_damage damage
|
52
|
+
@health -= damage
|
53
|
+
end
|
54
|
+
|
55
|
+
def toggle_secondary
|
56
|
+
current_index = SECONDARY_WEAPONS.index(@secondary_weapon)
|
57
|
+
if current_index == SECONDARY_WEAPONS.count - 1
|
58
|
+
@secondary_weapon = SECONDARY_WEAPONS[0]
|
59
|
+
else
|
60
|
+
@secondary_weapon = SECONDARY_WEAPONS[current_index + 1]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_secondary_ammo_count
|
65
|
+
return case @secondary_weapon
|
66
|
+
when 'bomb'
|
67
|
+
self.bombs
|
68
|
+
else
|
69
|
+
self.rockets
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
def decrement_secondary_ammo_count
|
75
|
+
return case @secondary_weapon
|
76
|
+
when 'bomb'
|
77
|
+
self.bombs -= 1
|
78
|
+
else
|
79
|
+
self.rockets -= 1
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def get_secondary_name
|
84
|
+
return case @secondary_weapon
|
85
|
+
when 'bomb'
|
86
|
+
'Bomb'
|
87
|
+
else
|
88
|
+
'Rocket'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_x
|
93
|
+
@x
|
94
|
+
end
|
95
|
+
def get_y
|
96
|
+
@y
|
97
|
+
end
|
98
|
+
|
99
|
+
def is_alive
|
100
|
+
health > 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_speed
|
104
|
+
(SPEED * @scale).round
|
105
|
+
end
|
106
|
+
|
107
|
+
def move_left width
|
108
|
+
@turn_left = true
|
109
|
+
@x = [@x - get_speed, (get_width/3)].max
|
110
|
+
end
|
111
|
+
|
112
|
+
def move_right width
|
113
|
+
@turn_right = true
|
114
|
+
@x = [@x + get_speed, (width - (get_width/3))].min
|
115
|
+
end
|
116
|
+
|
117
|
+
def accelerate height
|
118
|
+
@y = [@y - get_speed, (get_height/2)].max
|
119
|
+
end
|
120
|
+
|
121
|
+
def brake height
|
122
|
+
@y = [@y + get_speed, height].min
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
def attack width, height, mouse_x = nil, mouse_y = nil
|
127
|
+
return {
|
128
|
+
projectiles: [Bullet.new(@scale, width, height, self, mouse_x, mouse_y, {side: 'left'}), Bullet.new(@scale, width, height, self, mouse_x, mouse_y, {side: 'right'})],
|
129
|
+
cooldown: Bullet::COOLDOWN_DELAY
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def trigger_secondary_attack width, height, mouse_x, mouse_y
|
134
|
+
return_projectiles = []
|
135
|
+
if self.secondary_cooldown_wait <= 0 && self.get_secondary_ammo_count > 0
|
136
|
+
results = self.secondary_attack(width, height, mouse_x, mouse_y)
|
137
|
+
projectiles = results[:projectiles]
|
138
|
+
cooldown = results[:cooldown]
|
139
|
+
self.secondary_cooldown_wait = cooldown.to_f.fdiv(self.attack_speed)
|
140
|
+
|
141
|
+
projectiles.each do |projectile|
|
142
|
+
self.decrement_secondary_ammo_count
|
143
|
+
return_projectiles.push(projectile)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
return return_projectiles
|
147
|
+
end
|
148
|
+
|
149
|
+
# def toggle_state_secondary_attack
|
150
|
+
# second_weapon = case @secondary_weapon
|
151
|
+
# when 'bomb'
|
152
|
+
# else
|
153
|
+
# end
|
154
|
+
# return second_weapon
|
155
|
+
# end
|
156
|
+
|
157
|
+
def secondary_attack width, height, mouse_x = nil, mouse_y = nil
|
158
|
+
second_weapon = case @secondary_weapon
|
159
|
+
when 'bomb'
|
160
|
+
{
|
161
|
+
projectiles: [Bomb.new(@scale, width, height, self, mouse_x, mouse_y)],
|
162
|
+
cooldown: Bomb::COOLDOWN_DELAY
|
163
|
+
}
|
164
|
+
else
|
165
|
+
if get_secondary_ammo_count > 1
|
166
|
+
{
|
167
|
+
projectiles: [Missile.new(@scale, width, height, self, mouse_x, mouse_y, {side: 'left'}), Missile.new(@scale, width, height, self, mouse_x, mouse_y, {side: 'right'})],
|
168
|
+
cooldown: Missile::COOLDOWN_DELAY
|
169
|
+
}
|
170
|
+
else get_secondary_ammo_count == 1
|
171
|
+
{
|
172
|
+
projectiles: [Missile.new(@scale, width, height, self, mouse_x, mouse_y)],
|
173
|
+
cooldown: Missile::COOLDOWN_DELAY
|
174
|
+
}
|
175
|
+
end
|
176
|
+
end
|
177
|
+
return second_weapon
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_draw_ordering
|
181
|
+
ZOrder::Player
|
182
|
+
end
|
183
|
+
|
184
|
+
def draw
|
185
|
+
if @turn_right
|
186
|
+
image = @right_image
|
187
|
+
elsif @turn_left
|
188
|
+
image = @left_image
|
189
|
+
else
|
190
|
+
image = @image
|
191
|
+
end
|
192
|
+
# super
|
193
|
+
image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering, @scale, @scale)
|
194
|
+
@turn_right = false
|
195
|
+
@turn_left = false
|
196
|
+
end
|
197
|
+
|
198
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
199
|
+
# puts "TEST HERE: width: #{get_width} and height: #{get_height}"
|
200
|
+
@cooldown_wait -= 1 if @cooldown_wait > 0
|
201
|
+
@secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
|
202
|
+
@grapple_hook_cooldown_wait -= 1 if @grapple_hook_cooldown_wait > 0
|
203
|
+
@time_alive += 1 if self.is_alive
|
204
|
+
end
|
205
|
+
|
206
|
+
# def collect_stars(stars)
|
207
|
+
# stars.reject! do |star|
|
208
|
+
# if Gosu.distance(@x, @y, star.x, star.y) < 35
|
209
|
+
# @score += 10
|
210
|
+
# @attack_speed = @attack_speed + 0.1
|
211
|
+
# @attack_speed = MAX_ATTACK_SPEED if @attack_speed > MAX_ATTACK_SPEED
|
212
|
+
|
213
|
+
# # stop that!
|
214
|
+
# # @beep.play
|
215
|
+
# true
|
216
|
+
# else
|
217
|
+
# false
|
218
|
+
# end
|
219
|
+
# end
|
220
|
+
# end
|
221
|
+
|
222
|
+
|
223
|
+
def collect_pickups(pickups)
|
224
|
+
pickups.reject! do |pickup|
|
225
|
+
if Gosu.distance(@x, @y, pickup.x, pickup.y) < ((self.get_radius) + (pickup.get_radius)) * 1.2 && pickup.respond_to?(:collected_by_player)
|
226
|
+
pickup.collected_by_player(self)
|
227
|
+
if pickup.respond_to?(:get_points)
|
228
|
+
self.score += pickup.get_points
|
229
|
+
end
|
230
|
+
# stop that!
|
231
|
+
# @beep.play
|
232
|
+
true
|
233
|
+
else
|
234
|
+
false
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
end
|