line-em-up 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/line-em-up/game_window.rb +118 -104
- data/line-em-up/irb_requirements.rb +5 -6
- data/line-em-up/lib/config_setting.rb +22 -9
- data/line-em-up/lib/difficulty_setting.rb +78 -0
- data/line-em-up/media/mini_missile.png +0 -0
- data/line-em-up/models/bomb.rb +2 -2
- data/line-em-up/models/building.rb +20 -14
- data/line-em-up/models/bullet.rb +3 -34
- data/line-em-up/models/cursor.rb +12 -5
- data/line-em-up/models/dumb_projectile.rb +110 -0
- data/line-em-up/models/enemy_bomb.rb +2 -6
- data/line-em-up/models/enemy_bullet.rb +4 -35
- data/line-em-up/models/enemy_homing_missile.rb +10 -65
- data/line-em-up/models/enemy_player.rb +16 -23
- data/line-em-up/models/general_object.rb +131 -8
- data/line-em-up/models/grappling_hook.rb +16 -20
- data/line-em-up/models/health_pack.rb +4 -18
- data/line-em-up/models/missile.rb +26 -21
- data/line-em-up/models/missile_boat.rb +18 -22
- data/line-em-up/models/mothership.rb +36 -37
- data/line-em-up/models/pickup.rb +8 -16
- data/line-em-up/models/player.rb +38 -57
- data/line-em-up/models/projectile.rb +97 -38
- data/line-em-up/models/small_explosion.rb +7 -3
- data/line-em-up/models/star.rb +7 -10
- data/menu_launcher.rb +9 -2
- metadata +4 -1
@@ -2,7 +2,7 @@ require_relative 'projectile.rb'
|
|
2
2
|
class Missile < Projectile
|
3
3
|
attr_reader :x, :y, :time_alive, :mouse_start_x, :mouse_start_y
|
4
4
|
COOLDOWN_DELAY = 30
|
5
|
-
MAX_SPEED =
|
5
|
+
MAX_SPEED = 20
|
6
6
|
STARTING_SPEED = 0.0
|
7
7
|
INITIAL_DELAY = 2
|
8
8
|
SPEED_INCREASE_FACTOR = 0.5
|
@@ -17,6 +17,11 @@ class Missile < Projectile
|
|
17
17
|
# super(object_groups)
|
18
18
|
# end
|
19
19
|
|
20
|
+
# def initialize(scale, screen_width, screen_height, object, end_point_x, end_point_y, angle_min, angle_max, angle_init, options)
|
21
|
+
# super(scale, screen_width, screen_height, object, end_point_x, end_point_y, angle_min, angle_max, angle_init, options)
|
22
|
+
# # puts "MYYYY MISSILE ANGLE: #{@angle}"
|
23
|
+
# end
|
24
|
+
|
20
25
|
def get_image
|
21
26
|
Gosu::Image.new("#{MEDIA_DIRECTORY}/missile.png")
|
22
27
|
end
|
@@ -39,28 +44,28 @@ class Missile < Projectile
|
|
39
44
|
# @mouse_start_y = mouse_y
|
40
45
|
# end
|
41
46
|
|
42
|
-
def update
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
# def update mouse_x = nil, mouse_y = nil, player = nil
|
48
|
+
# new_speed = 0
|
49
|
+
# if @time_alive > self.class.get_initial_delay
|
50
|
+
# new_speed = self.class.get_starting_speed + (self.class.get_speed_increase_factor > 0 ? @time_alive * self.class.get_speed_increase_factor : 0)
|
51
|
+
# new_speed = self.class.get_max_speed if new_speed > self.class.get_max_speed
|
52
|
+
# new_speed = new_speed * @scale
|
53
|
+
# end
|
49
54
|
|
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
|
|
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
56
|
|
61
|
-
|
62
|
-
|
57
|
+
# vx = 0
|
58
|
+
# vy = 0
|
59
|
+
# if new_speed != 0
|
60
|
+
# vx = ((new_speed / 3) * 1) * Math.cos(@angle * Math::PI / 180)
|
63
61
|
|
64
|
-
|
65
|
-
|
62
|
+
# vy = ((new_speed / 3) * 1) * Math.sin(@angle * Math::PI / 180)
|
63
|
+
# vy = vy * -1
|
64
|
+
# end
|
65
|
+
|
66
|
+
# @x = @x + vx
|
67
|
+
# @y = @y + vy
|
68
|
+
|
69
|
+
# super(mouse_x, mouse_y)
|
70
|
+
# end
|
66
71
|
end
|
@@ -5,28 +5,24 @@ require_relative 'small_explosion.rb'
|
|
5
5
|
require_relative 'star.rb'
|
6
6
|
|
7
7
|
class MissileBoat < GeneralObject
|
8
|
-
|
8
|
+
SPEED = 5
|
9
9
|
MAX_ATTACK_SPEED = 3.0
|
10
10
|
POINT_VALUE_BASE = 50
|
11
|
+
MISSILE_LAUNCHER_MIN_ANGLE = 255
|
12
|
+
MISSILE_LAUNCHER_MAX_ANGLE = 285
|
13
|
+
MISSILE_LAUNCHER_INIT_ANGLE = 270
|
11
14
|
attr_accessor :cooldown_wait, :attack_speed, :health, :armor, :x, :y
|
12
15
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
20
|
-
@x = x || rand(width)
|
21
|
-
@y = y || 0
|
16
|
+
def get_image
|
17
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/missile_boat_reverse.png")
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(scale, screen_width, screen_height, x = nil, y = nil, options = {})
|
21
|
+
super(scale, x || rand(screen_width), y || 0, screen_width, screen_height, options)
|
22
22
|
@cooldown_wait = 0
|
23
23
|
@attack_speed = 0.5
|
24
24
|
@health = 10
|
25
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
26
|
@current_speed = (rand(5) * @scale).round + 1
|
31
27
|
end
|
32
28
|
|
@@ -43,9 +39,9 @@ class MissileBoat < GeneralObject
|
|
43
39
|
@health -= damage
|
44
40
|
end
|
45
41
|
|
46
|
-
def attack
|
42
|
+
def attack player
|
47
43
|
return {
|
48
|
-
projectiles: [EnemyHomingMissile.new(@scale,
|
44
|
+
projectiles: [EnemyHomingMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE)],
|
49
45
|
cooldown: EnemyHomingMissile::COOLDOWN_DELAY
|
50
46
|
}
|
51
47
|
end
|
@@ -53,8 +49,8 @@ class MissileBoat < GeneralObject
|
|
53
49
|
|
54
50
|
def drops
|
55
51
|
[
|
56
|
-
SmallExplosion.new(@scale, @x, @y, @image),
|
57
|
-
Star.new(@scale, @x, @y)
|
52
|
+
SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, @image),
|
53
|
+
Star.new(@scale, @screen_width, @screen_height, @x, @y)
|
58
54
|
]
|
59
55
|
end
|
60
56
|
|
@@ -67,7 +63,7 @@ class MissileBoat < GeneralObject
|
|
67
63
|
|
68
64
|
# end
|
69
65
|
|
70
|
-
def update
|
66
|
+
def update mouse_x = nil, mouse_y = nil, player = nil
|
71
67
|
@cooldown_wait -= 1 if @cooldown_wait > 0
|
72
68
|
if is_alive
|
73
69
|
# Stay above the player
|
@@ -77,7 +73,7 @@ class MissileBoat < GeneralObject
|
|
77
73
|
if rand(2).even?
|
78
74
|
@y += @current_speed
|
79
75
|
|
80
|
-
@y =
|
76
|
+
@y = @screen_height / 2 if @y > @screen_height / 2
|
81
77
|
else
|
82
78
|
@y -= @current_speed
|
83
79
|
|
@@ -86,13 +82,13 @@ class MissileBoat < GeneralObject
|
|
86
82
|
end
|
87
83
|
if rand(2).even?
|
88
84
|
@x += @current_speed
|
89
|
-
@x =
|
85
|
+
@x = @screen_width if @x > @screen_width
|
90
86
|
else
|
91
87
|
@x -= @current_speed
|
92
88
|
@x = 0 + (get_width / 2) if @x < 0 + (get_width / 2)
|
93
89
|
end
|
94
90
|
|
95
|
-
@y <
|
91
|
+
@y < @screen_height + (get_height / 2)
|
96
92
|
else
|
97
93
|
false
|
98
94
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative 'player.rb'
|
1
|
+
# require_relative 'player.rb'
|
2
2
|
require_relative 'enemy_bullet.rb'
|
3
3
|
require_relative 'enemy_homing_missile.rb'
|
4
4
|
require_relative 'small_explosion.rb'
|
@@ -6,39 +6,37 @@ require_relative 'star.rb'
|
|
6
6
|
require_relative 'enemy_bomb.rb'
|
7
7
|
|
8
8
|
class Mothership < GeneralObject
|
9
|
-
|
9
|
+
SPEED = 5
|
10
10
|
MAX_ATTACK_SPEED = 3.0
|
11
11
|
POINT_VALUE_BASE = 1000
|
12
|
+
|
13
|
+
MISSILE_LAUNCHER_MIN_ANGLE = nil
|
14
|
+
MISSILE_LAUNCHER_MAX_ANGLE = nil
|
15
|
+
MISSILE_LAUNCHER_INIT_ANGLE = nil
|
16
|
+
|
12
17
|
attr_accessor :cooldown_wait, :attack_speed, :health, :armor, :x, :y, :secondary_cooldown_wait, :tertiary_cooldown_wait
|
13
18
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
22
|
-
@x = width / 2
|
23
|
-
@y = 0 + @image.height
|
19
|
+
def get_image
|
20
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/mothership.png")
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(scale, screen_width, screen_height, options = {})
|
24
|
+
super(scale, screen_width / 2, get_image.height, screen_width, screen_height, options)
|
25
|
+
|
24
26
|
@cooldown_wait = 0
|
25
27
|
@secondary_cooldown_wait = 0
|
26
28
|
@tertiary_cooldown_wait = 0
|
27
29
|
@attack_speed = 0.5
|
28
|
-
@health =
|
30
|
+
@health = 2500
|
29
31
|
@armor = 0
|
30
|
-
@
|
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
|
32
|
+
@current_speed = (SPEED * @scale).round + 1
|
35
33
|
end
|
36
34
|
|
37
|
-
def draw
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
35
|
+
# def draw
|
36
|
+
# # Will generate error if class name is not listed on ZOrder
|
37
|
+
# @image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering, @scale, @scale)
|
38
|
+
# # @image.draw(@xΩ - @image.width / 2, @y - @image.height / 2, get_draw_ordering)
|
39
|
+
# end
|
42
40
|
|
43
41
|
def get_points
|
44
42
|
return POINT_VALUE_BASE
|
@@ -54,31 +52,32 @@ class Mothership < GeneralObject
|
|
54
52
|
end
|
55
53
|
|
56
54
|
|
57
|
-
def attack
|
55
|
+
def attack player
|
58
56
|
return {
|
59
57
|
projectiles: [
|
60
|
-
EnemyBullet.new(@scale,
|
61
|
-
EnemyBullet.new(@scale,
|
62
|
-
EnemyBullet.new(@scale,
|
58
|
+
EnemyBullet.new(@scale, @screen_width, @screen_height, self, {side: 'left', relative_object: self }),
|
59
|
+
EnemyBullet.new(@scale, @screen_width, @screen_height, self, {side: 'right', relative_object: self }),
|
60
|
+
EnemyBullet.new(@scale, @screen_width, @screen_height, self)
|
63
61
|
],
|
64
62
|
cooldown: EnemyBullet::COOLDOWN_DELAY
|
65
63
|
}
|
66
64
|
end
|
67
65
|
|
68
|
-
def secondary_attack
|
66
|
+
def secondary_attack player
|
69
67
|
return {
|
70
68
|
projectiles: [
|
71
|
-
|
72
|
-
EnemyHomingMissile.new(@scale,
|
69
|
+
# relative_object not required yet for these
|
70
|
+
EnemyHomingMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', relative_object: self }),
|
71
|
+
EnemyHomingMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', relative_object: self })
|
73
72
|
],
|
74
73
|
cooldown: EnemyHomingMissile::COOLDOWN_DELAY
|
75
74
|
}
|
76
75
|
end
|
77
76
|
|
78
77
|
|
79
|
-
def tertiary_attack
|
78
|
+
def tertiary_attack player
|
80
79
|
return {
|
81
|
-
projectiles: [EnemyBomb.new(@scale,
|
80
|
+
projectiles: [EnemyBomb.new(@scale, @screen_width, @screen_height, self, player.x, player.y)],
|
82
81
|
cooldown: EnemyBomb::COOLDOWN_DELAY
|
83
82
|
}
|
84
83
|
end
|
@@ -86,7 +85,7 @@ class Mothership < GeneralObject
|
|
86
85
|
|
87
86
|
def drops
|
88
87
|
[
|
89
|
-
SmallExplosion.new(@scale, @x, @y, @image)
|
88
|
+
SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, @image)
|
90
89
|
# Star.new(@scale, @x, @y)
|
91
90
|
]
|
92
91
|
end
|
@@ -100,7 +99,7 @@ class Mothership < GeneralObject
|
|
100
99
|
|
101
100
|
# end
|
102
101
|
|
103
|
-
def update
|
102
|
+
def update mouse_x = nil, mouse_y = nil, player = nil
|
104
103
|
@cooldown_wait -= 1 if @cooldown_wait > 0
|
105
104
|
@secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
|
106
105
|
@tertiary_cooldown_wait -= 1 if @tertiary_cooldown_wait > 0
|
@@ -112,7 +111,7 @@ class Mothership < GeneralObject
|
|
112
111
|
if rand(2).even?
|
113
112
|
@y += @current_speed
|
114
113
|
|
115
|
-
@y =
|
114
|
+
@y = @screen_height / 2 if @y > @screen_height / 2
|
116
115
|
else
|
117
116
|
@y -= @current_speed
|
118
117
|
|
@@ -121,13 +120,13 @@ class Mothership < GeneralObject
|
|
121
120
|
end
|
122
121
|
if rand(2).even?
|
123
122
|
@x += @current_speed
|
124
|
-
@x =
|
123
|
+
@x = @screen_width if @x > @screen_width
|
125
124
|
else
|
126
125
|
@x -= @current_speed
|
127
126
|
@x = 0 + (get_width / 2) if @x < 0 + (get_width / 2)
|
128
127
|
end
|
129
128
|
|
130
|
-
@y <
|
129
|
+
@y < @screen_height + (get_height / 2)
|
131
130
|
else
|
132
131
|
false
|
133
132
|
end
|
data/line-em-up/models/pickup.rb
CHANGED
@@ -4,16 +4,8 @@ class Pickup < GeneralObject
|
|
4
4
|
POINT_VALUE_BASE = 0
|
5
5
|
attr_reader :x, :y
|
6
6
|
|
7
|
-
def initialize(scale, x = nil, y = nil)
|
8
|
-
|
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
|
7
|
+
def initialize(scale, screen_width, screen_height, x = nil, y = nil, options = {})
|
8
|
+
super(scale, x, y, screen_width, screen_height, options = {})
|
17
9
|
@current_speed = SCROLLING_SPEED * @scale
|
18
10
|
end
|
19
11
|
|
@@ -21,16 +13,16 @@ class Pickup < GeneralObject
|
|
21
13
|
ZOrder::Pickups
|
22
14
|
end
|
23
15
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
# Most classes will want to just override this
|
17
|
+
def draw
|
18
|
+
@image.draw_rot(@x, @y, ZOrder::Pickups, @y, 0.5, 0.5, 1, 1)
|
19
|
+
end
|
28
20
|
|
29
21
|
|
30
|
-
def update
|
22
|
+
def update mouse_x = nil, mouse_y = nil, player = nil
|
31
23
|
@y += @current_speed
|
32
24
|
|
33
|
-
super(
|
25
|
+
super(mouse_x, mouse_y)
|
34
26
|
end
|
35
27
|
|
36
28
|
def collected_by_player player
|
data/line-em-up/models/player.rb
CHANGED
@@ -7,44 +7,32 @@ class Player < GeneralObject
|
|
7
7
|
MAX_HEALTH = 200
|
8
8
|
|
9
9
|
SECONDARY_WEAPONS = %w[missile bomb]
|
10
|
+
# Range goes clockwise around the 0-360 angle
|
11
|
+
MISSILE_LAUNCHER_MIN_ANGLE = 75
|
12
|
+
MISSILE_LAUNCHER_MAX_ANGLE = 105
|
13
|
+
MISSILE_LAUNCHER_INIT_ANGLE = 90
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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")
|
15
|
+
def get_image
|
16
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship.png")
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(scale, x, y, screen_width, screen_height, options = {})
|
20
|
+
super(scale, x, y, screen_width, screen_height, options)
|
21
21
|
@right_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_right.png")
|
22
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
23
|
@score = 0
|
26
24
|
@cooldown_wait = 0
|
27
25
|
@secondary_cooldown_wait = 0
|
28
26
|
@grapple_hook_cooldown_wait = 0
|
29
27
|
@attack_speed = 1
|
30
|
-
# @attack_speed = 3
|
31
|
-
# temp
|
32
28
|
@health = 100
|
33
|
-
# @health = 100000
|
34
29
|
@armor = 0
|
35
30
|
@rockets = 25
|
36
|
-
# @rockets =
|
37
|
-
# @rocket_launcher = {}
|
31
|
+
# @rockets = 250
|
38
32
|
@bombs = 3
|
39
|
-
# @bombs = 300
|
40
|
-
@time_alive = 0
|
41
33
|
@secondary_weapon = "missile"
|
42
34
|
@turn_right = false
|
43
35
|
@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
36
|
end
|
49
37
|
|
50
38
|
|
@@ -104,36 +92,39 @@ class Player < GeneralObject
|
|
104
92
|
(SPEED * @scale).round
|
105
93
|
end
|
106
94
|
|
107
|
-
def move_left
|
95
|
+
def move_left
|
108
96
|
@turn_left = true
|
109
97
|
@x = [@x - get_speed, (get_width/3)].max
|
110
98
|
end
|
111
99
|
|
112
|
-
def move_right
|
100
|
+
def move_right
|
113
101
|
@turn_right = true
|
114
|
-
@x = [@x + get_speed, (
|
102
|
+
@x = [@x + get_speed, (@screen_width - (get_width/3))].min
|
115
103
|
end
|
116
104
|
|
117
|
-
def accelerate
|
105
|
+
def accelerate
|
118
106
|
@y = [@y - get_speed, (get_height/2)].max
|
119
107
|
end
|
120
108
|
|
121
|
-
def brake
|
122
|
-
@y = [@y + get_speed,
|
109
|
+
def brake
|
110
|
+
@y = [@y + get_speed, @screen_height].min
|
123
111
|
end
|
124
112
|
|
125
113
|
|
126
|
-
def attack
|
114
|
+
def attack pointer
|
127
115
|
return {
|
128
|
-
projectiles: [
|
116
|
+
projectiles: [
|
117
|
+
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'left', relative_object: self}),
|
118
|
+
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'right', relative_object: self})
|
119
|
+
],
|
129
120
|
cooldown: Bullet::COOLDOWN_DELAY
|
130
121
|
}
|
131
122
|
end
|
132
123
|
|
133
|
-
def trigger_secondary_attack
|
124
|
+
def trigger_secondary_attack pointer
|
134
125
|
return_projectiles = []
|
135
126
|
if self.secondary_cooldown_wait <= 0 && self.get_secondary_ammo_count > 0
|
136
|
-
results = self.secondary_attack(
|
127
|
+
results = self.secondary_attack(pointer)
|
137
128
|
projectiles = results[:projectiles]
|
138
129
|
cooldown = results[:cooldown]
|
139
130
|
self.secondary_cooldown_wait = cooldown.to_f.fdiv(self.attack_speed)
|
@@ -154,22 +145,31 @@ class Player < GeneralObject
|
|
154
145
|
# return second_weapon
|
155
146
|
# end
|
156
147
|
|
157
|
-
def secondary_attack
|
148
|
+
def secondary_attack pointer
|
158
149
|
second_weapon = case @secondary_weapon
|
159
150
|
when 'bomb'
|
160
151
|
{
|
161
|
-
projectiles: [Bomb.new(@scale,
|
152
|
+
projectiles: [Bomb.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y)],
|
162
153
|
cooldown: Bomb::COOLDOWN_DELAY
|
163
154
|
}
|
164
155
|
else
|
165
156
|
if get_secondary_ammo_count > 1
|
166
157
|
{
|
167
|
-
projectiles: [
|
158
|
+
projectiles: [
|
159
|
+
Missile.new(@scale, @screen_width, @screen_height, self, pointer.x - @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', relative_object: self}),
|
160
|
+
Missile.new(@scale, @screen_width, @screen_height, self, pointer.x + @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', relative_object: self})
|
161
|
+
],
|
168
162
|
cooldown: Missile::COOLDOWN_DELAY
|
169
163
|
}
|
164
|
+
# {
|
165
|
+
# projectiles: [
|
166
|
+
# Missile.new(@scale, @screen_width, @screen_height, self, mouse_x, mouse_y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE)
|
167
|
+
# ],
|
168
|
+
# cooldown: Missile::COOLDOWN_DELAY
|
169
|
+
# }
|
170
170
|
else get_secondary_ammo_count == 1
|
171
171
|
{
|
172
|
-
projectiles: [Missile.new(@scale,
|
172
|
+
projectiles: [Missile.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y, {relative_object: self})],
|
173
173
|
cooldown: Missile::COOLDOWN_DELAY
|
174
174
|
}
|
175
175
|
end
|
@@ -195,31 +195,13 @@ class Player < GeneralObject
|
|
195
195
|
@turn_left = false
|
196
196
|
end
|
197
197
|
|
198
|
-
def update
|
199
|
-
# puts "TEST HERE: width: #{get_width} and height: #{get_height}"
|
198
|
+
def update mouse_x = nil, mouse_y = nil, player = nil
|
200
199
|
@cooldown_wait -= 1 if @cooldown_wait > 0
|
201
200
|
@secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
|
202
201
|
@grapple_hook_cooldown_wait -= 1 if @grapple_hook_cooldown_wait > 0
|
203
202
|
@time_alive += 1 if self.is_alive
|
204
203
|
end
|
205
204
|
|
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
205
|
def collect_pickups(pickups)
|
224
206
|
pickups.reject! do |pickup|
|
225
207
|
if Gosu.distance(@x, @y, pickup.x, pickup.y) < ((self.get_radius) + (pickup.get_radius)) * 1.2 && pickup.respond_to?(:collected_by_player)
|
@@ -237,5 +219,4 @@ class Player < GeneralObject
|
|
237
219
|
end
|
238
220
|
|
239
221
|
|
240
|
-
|
241
222
|
end
|