line-em-up 0.3.6 → 0.4.0
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/game_window.rb +38 -10
- data/line-em-up/lib/resolution_setting.rb +0 -1
- data/line-em-up/lib/z_order.rb +1 -1
- data/line-em-up/media/back_to_menu.png +0 -0
- data/line-em-up/media/laserbolt.png +0 -0
- data/line-em-up/media/mite.png +0 -0
- data/line-em-up/media/mite_original.png +0 -0
- data/line-em-up/media/progress_bar_0.png +0 -0
- data/line-em-up/media/progress_bar_1.png +0 -0
- data/line-em-up/media/progress_bar_10.png +0 -0
- data/line-em-up/media/progress_bar_11.png +0 -0
- data/line-em-up/media/progress_bar_12.png +0 -0
- data/line-em-up/media/progress_bar_13.png +0 -0
- data/line-em-up/media/progress_bar_14.png +0 -0
- data/line-em-up/media/progress_bar_15.png +0 -0
- data/line-em-up/media/progress_bar_16.png +0 -0
- data/line-em-up/media/progress_bar_17.png +0 -0
- data/line-em-up/media/progress_bar_18.png +0 -0
- data/line-em-up/media/progress_bar_19.png +0 -0
- data/line-em-up/media/progress_bar_2.png +0 -0
- data/line-em-up/media/progress_bar_20.png +0 -0
- data/line-em-up/media/progress_bar_3.png +0 -0
- data/line-em-up/media/progress_bar_4.png +0 -0
- data/line-em-up/media/progress_bar_5.png +0 -0
- data/line-em-up/media/progress_bar_6.png +0 -0
- data/line-em-up/media/progress_bar_7.png +0 -0
- data/line-em-up/media/progress_bar_8.png +0 -0
- data/line-em-up/media/progress_bar_9.png +0 -0
- data/line-em-up/media/rocket_launcher.png +0 -0
- data/line-em-up/media/rocket_launcher_original.png +0 -0
- data/line-em-up/media/tiny_missile.png +0 -0
- data/line-em-up/models/bomb_pack.rb +2 -1
- data/line-em-up/models/bullet.rb +86 -3
- data/line-em-up/models/bullet_open_gl_backup.rb +69 -0
- data/line-em-up/models/dumb_projectile.rb +2 -1
- data/line-em-up/models/enemy_bullet.rb +4 -3
- data/line-em-up/models/enemy_player.rb +1 -1
- data/line-em-up/models/footer_bar.rb +34 -1
- data/line-em-up/models/general_object.rb +2 -0
- data/line-em-up/models/health_pack.rb +5 -3
- data/line-em-up/models/horizontal_swarm.rb +123 -0
- data/line-em-up/models/main.rb +92 -0
- data/line-em-up/models/missile.rb +52 -5
- data/line-em-up/models/missile_boat.rb +9 -3
- data/line-em-up/models/missile_pack.rb +6 -1
- data/line-em-up/models/mite.rb +104 -0
- data/line-em-up/models/mothership.rb +4 -4
- data/line-em-up/models/player.rb +126 -40
- data/line-em-up/models/projectile.rb +28 -13
- data/line-em-up/models/rocket_launcher_pickup.rb +26 -0
- data/line-em-up/models/{enemy_homing_missile.rb → semi_guided_missile.rb} +13 -5
- data/line-em-up/models/small_explosion.rb +18 -6
- data/line-em-up/models/star.rb +7 -3
- data/menu_launcher.rb +1 -95
- metadata +35 -3
- data/line-em-up/media/bomb_original copy.png +0 -0
data/line-em-up/models/player.rb
CHANGED
@@ -1,23 +1,84 @@
|
|
1
1
|
require_relative 'general_object.rb'
|
2
|
+
require_relative 'rocket_launcher_pickup.rb'
|
2
3
|
|
3
4
|
class Player < GeneralObject
|
4
5
|
SPEED = 7
|
5
6
|
MAX_ATTACK_SPEED = 3.0
|
6
|
-
attr_accessor :cooldown_wait, :secondary_cooldown_wait, :attack_speed, :health, :armor, :x, :y, :rockets, :score, :time_alive
|
7
|
+
attr_accessor :cooldown_wait, :secondary_cooldown_wait, :attack_speed, :health, :armor, :x, :y, :rockets, :score, :time_alive
|
8
|
+
|
9
|
+
attr_accessor :bombs, :secondary_weapon, :grapple_hook_cooldown_wait, :damage_reduction, :boost_increase, :damage_increase, :kill_count
|
10
|
+
attr_accessor :special_attack
|
7
11
|
MAX_HEALTH = 200
|
8
12
|
|
9
|
-
SECONDARY_WEAPONS = %w[
|
13
|
+
SECONDARY_WEAPONS = [RocketLauncherPickup::NAME] + %w[bomb]
|
10
14
|
# Range goes clockwise around the 0-360 angle
|
11
15
|
MISSILE_LAUNCHER_MIN_ANGLE = 75
|
12
16
|
MISSILE_LAUNCHER_MAX_ANGLE = 105
|
13
17
|
MISSILE_LAUNCHER_INIT_ANGLE = 90
|
14
18
|
|
19
|
+
SPECIAL_POWER = 'laser'
|
20
|
+
SPECIAL_POWER_KILL_MAX = 50
|
21
|
+
|
22
|
+
def get_kill_count_max
|
23
|
+
self.class::SPECIAL_POWER_KILL_MAX
|
24
|
+
end
|
25
|
+
|
26
|
+
def ready_for_special?
|
27
|
+
@kill_count >= get_kill_count_max
|
28
|
+
end
|
29
|
+
|
30
|
+
def special_attack
|
31
|
+
# Fire special attack.
|
32
|
+
@kill_count = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
# Rocket Launcher, Rocket launcher, Cannon, Cannon, Bomb Launcher
|
36
|
+
HARD_POINTS = 12
|
37
|
+
|
38
|
+
def add_kill_count kill_count
|
39
|
+
if @kill_count + kill_count > get_kill_count_max
|
40
|
+
@kill_count = get_kill_count_max
|
41
|
+
else
|
42
|
+
@kill_count += kill_count
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_hard_point hard_point
|
47
|
+
@hard_point_items << hard_point
|
48
|
+
trigger_hard_point_load
|
49
|
+
end
|
50
|
+
|
51
|
+
def trigger_hard_point_load
|
52
|
+
@rocket_launchers, @bomb_launchers, @cannon_launchers = [0, 0, 0]
|
53
|
+
count = 0
|
54
|
+
# puts "RUNNING ON: #{@hard_point_items}"
|
55
|
+
@hard_point_items.each do |hard_point|
|
56
|
+
break if count == HARD_POINTS
|
57
|
+
case hard_point
|
58
|
+
when 'bomb_launcher'
|
59
|
+
@bomb_launchers += 1
|
60
|
+
when RocketLauncherPickup::NAME
|
61
|
+
# puts "INCREASTING ROCKET LAUNCHER: #{RocketLauncherPickup::NAME}"
|
62
|
+
@rocket_launchers += 1
|
63
|
+
when 'cannon_launcher'
|
64
|
+
@cannon_launchers += 1
|
65
|
+
else
|
66
|
+
"Raise should never get here. hard_point: #{hard_point}"
|
67
|
+
end
|
68
|
+
count += 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
15
72
|
def get_image
|
16
73
|
Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship.png")
|
17
74
|
end
|
18
75
|
|
19
76
|
def initialize(scale, x, y, screen_width, screen_height, options = {})
|
20
77
|
super(scale, x, y, screen_width, screen_height, options)
|
78
|
+
# Top of screen
|
79
|
+
@min_moveable_height = options[:min_moveable_height] || 0
|
80
|
+
# Bottom of the screen
|
81
|
+
@max_movable_height = options[:max_movable_height] || screen_height
|
21
82
|
@right_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_right.png")
|
22
83
|
@left_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_left.png")
|
23
84
|
@score = 0
|
@@ -25,19 +86,31 @@ class Player < GeneralObject
|
|
25
86
|
@secondary_cooldown_wait = 0
|
26
87
|
@grapple_hook_cooldown_wait = 0
|
27
88
|
@attack_speed = 1
|
28
|
-
@
|
89
|
+
# @attack_speed = 3
|
90
|
+
@health = 100.0
|
29
91
|
@armor = 0
|
30
|
-
@rockets =
|
92
|
+
@rockets = 50
|
31
93
|
# @rockets = 250
|
32
94
|
@bombs = 3
|
33
|
-
@secondary_weapon =
|
95
|
+
@secondary_weapon = RocketLauncherPickup::NAME
|
34
96
|
@turn_right = false
|
35
97
|
@turn_left = false
|
98
|
+
|
99
|
+
@hard_point_items = [RocketLauncherPickup::NAME, 'cannon_launcher', 'cannon_launcher', 'bomb_launcher']
|
100
|
+
@rocket_launchers = 0
|
101
|
+
@bomb_launchers = 0
|
102
|
+
@cannon_launchers = 0
|
103
|
+
trigger_hard_point_load
|
104
|
+
@damage_reduction = options[:handicap] ? options[:handicap] : 1
|
105
|
+
invert_handicap = 1 - options[:handicap]
|
106
|
+
@boost_increase = invert_handicap > 0 ? 1 + (invert_handicap * 1.25) : 1
|
107
|
+
@damage_increase = invert_handicap > 0 ? 1 + (invert_handicap) : 1
|
108
|
+
@kill_count = 0
|
36
109
|
end
|
37
110
|
|
38
111
|
|
39
112
|
def take_damage damage
|
40
|
-
@health -= damage
|
113
|
+
@health -= damage * @damage_reduction
|
41
114
|
end
|
42
115
|
|
43
116
|
def toggle_secondary
|
@@ -59,12 +132,12 @@ class Player < GeneralObject
|
|
59
132
|
end
|
60
133
|
|
61
134
|
|
62
|
-
def decrement_secondary_ammo_count
|
135
|
+
def decrement_secondary_ammo_count count = 1
|
63
136
|
return case @secondary_weapon
|
64
137
|
when 'bomb'
|
65
|
-
self.bombs -=
|
138
|
+
self.bombs -= count
|
66
139
|
else
|
67
|
-
self.rockets -=
|
140
|
+
self.rockets -= count
|
68
141
|
end
|
69
142
|
end
|
70
143
|
|
@@ -103,19 +176,24 @@ class Player < GeneralObject
|
|
103
176
|
end
|
104
177
|
|
105
178
|
def accelerate
|
106
|
-
|
179
|
+
# # Top of screen
|
180
|
+
# @min_moveable_height = options[:min_moveable_height] || 0
|
181
|
+
# # Bottom of the screen
|
182
|
+
# @max_movable_height = options[:max_movable_height] || screen_height
|
183
|
+
|
184
|
+
@y = [@y - get_speed, @min_moveable_height + (get_height/2)].max
|
107
185
|
end
|
108
186
|
|
109
187
|
def brake
|
110
|
-
@y = [@y + get_speed, @
|
188
|
+
@y = [@y + get_speed, @max_movable_height - (get_height/2)].min
|
111
189
|
end
|
112
190
|
|
113
191
|
|
114
192
|
def attack pointer
|
115
193
|
return {
|
116
194
|
projectiles: [
|
117
|
-
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'left',
|
118
|
-
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'right',
|
195
|
+
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'left', damage_increase: @damage_increase}),
|
196
|
+
Bullet.new(@scale, @screen_width, @screen_height, self, {side: 'right', damage_increase: @damage_increase})
|
119
197
|
],
|
120
198
|
cooldown: Bullet::COOLDOWN_DELAY
|
121
199
|
}
|
@@ -130,7 +208,6 @@ class Player < GeneralObject
|
|
130
208
|
self.secondary_cooldown_wait = cooldown.to_f.fdiv(self.attack_speed)
|
131
209
|
|
132
210
|
projectiles.each do |projectile|
|
133
|
-
self.decrement_secondary_ammo_count
|
134
211
|
return_projectiles.push(projectile)
|
135
212
|
end
|
136
213
|
end
|
@@ -146,35 +223,44 @@ class Player < GeneralObject
|
|
146
223
|
# end
|
147
224
|
|
148
225
|
def secondary_attack pointer
|
149
|
-
|
226
|
+
projectiles = []
|
227
|
+
cooldown = 0
|
228
|
+
case @secondary_weapon
|
150
229
|
when 'bomb'
|
151
|
-
{
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
{
|
172
|
-
|
173
|
-
|
174
|
-
}
|
230
|
+
projectiles << Bomb.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y, nil, nil, nil, {damage_increase: @damage_increase})
|
231
|
+
cooldown = Bomb::COOLDOWN_DELAY
|
232
|
+
when RocketLauncherPickup::NAME
|
233
|
+
# NEEED TO DECRETMENT AMMO BASED OFF OF LAUNCHERS!!!!!!!!!!!
|
234
|
+
# puts "ROCKET LAUNCHERS: #{@rocket_launchers}"
|
235
|
+
cooldown = Missile::COOLDOWN_DELAY
|
236
|
+
if get_secondary_ammo_count == 1 && @rocket_launchers > 0 || @rocket_launchers == 1
|
237
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {damage_increase: @damage_increase})
|
238
|
+
elsif get_secondary_ammo_count == 2 && @rocket_launchers >= 2 || @rocket_launchers == 2
|
239
|
+
projectiles << 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', damage_increase: @damage_increase})
|
240
|
+
projectiles << 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', damage_increase: @damage_increase})
|
241
|
+
elsif get_secondary_ammo_count == 3 && @rocket_launchers >= 3 || @rocket_launchers == 3
|
242
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {damage_increase: @damage_increase})
|
243
|
+
projectiles << 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', damage_increase: @damage_increase})
|
244
|
+
projectiles << 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', damage_increase: @damage_increase})
|
245
|
+
elsif get_secondary_ammo_count == 4 && @rocket_launchers >= 4 || @rocket_launchers == 4
|
246
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x - @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE + 15, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', damage_increase: @damage_increase})
|
247
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x + @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE - 15, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', damage_increase: @damage_increase})
|
248
|
+
|
249
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x - @image_width_half / 2, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE + 5, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', damage_increase: @damage_increase, relative_x_padding: (@image_width_half / 2) })
|
250
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x + @image_width_half / 2, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE - 5, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', damage_increase: @damage_increase, relative_x_padding: -(@image_width_half / 2) })
|
251
|
+
elsif get_secondary_ammo_count == 5 && @rocket_launchers >= 5 || @rocket_launchers >= 5
|
252
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {damage_increase: @damage_increase})
|
253
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x - @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE + 15, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', damage_increase: @damage_increase})
|
254
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x + @image_width_half, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE - 15, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', damage_increase: @damage_increase})
|
255
|
+
|
256
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x - @image_width_half / 2, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE + 5, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'left', damage_increase: @damage_increase, relative_x_padding: (@image_width_half / 2) })
|
257
|
+
projectiles << Missile.new(@scale, @screen_width, @screen_height, self, pointer.x + @image_width_half / 2, pointer.y, MISSILE_LAUNCHER_MIN_ANGLE - 5, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {side: 'right', damage_increase: @damage_increase, relative_x_padding: -(@image_width_half / 2) })
|
258
|
+
else
|
259
|
+
raise "Should never get here: @secondary_weapon: #{@secondary_weapon} for @rocket_launchers: #{@rocket_launchers} and get_secondary_ammo_count: #{get_secondary_ammo_count}"
|
175
260
|
end
|
176
261
|
end
|
177
|
-
|
262
|
+
decrement_secondary_ammo_count projectiles.count
|
263
|
+
return {projectiles: projectiles, cooldown: cooldown}
|
178
264
|
end
|
179
265
|
|
180
266
|
def get_draw_ordering
|
@@ -19,6 +19,11 @@ class Projectile < GeneralObject
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize(scale, screen_width, screen_height, object, end_point_x, end_point_y, angle_min = nil, angle_max = nil, angle_init = nil, options = {})
|
22
|
+
if options[:x_homing_padding]
|
23
|
+
end_point_x = end_point_x + options[:x_homing_padding]
|
24
|
+
end
|
25
|
+
@damage_increase = options[:damage_increase] || 1
|
26
|
+
@custom_initial_delay = options[:custom_initial_delay] if options[:custom_initial_delay]
|
22
27
|
options[:relative_object] = object
|
23
28
|
super(scale, nil, nil, screen_width, screen_height, options)
|
24
29
|
|
@@ -94,26 +99,26 @@ class Projectile < GeneralObject
|
|
94
99
|
|
95
100
|
|
96
101
|
new_speed = 0
|
97
|
-
if @time_alive > self.class.get_initial_delay
|
102
|
+
if @time_alive > (@custom_initial_delay || self.class.get_initial_delay)
|
98
103
|
new_speed = self.class.get_starting_speed + (self.class.get_speed_increase_factor > 0 ? @time_alive * self.class.get_speed_increase_factor : 0)
|
99
104
|
new_speed = self.class.get_max_speed if new_speed > self.class.get_max_speed
|
100
105
|
new_speed = new_speed * @scale
|
101
|
-
end
|
102
106
|
|
103
107
|
|
104
108
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
+
vx = 0
|
110
|
+
vy = 0
|
111
|
+
if new_speed != 0
|
112
|
+
vx = ((new_speed / 3) * 1) * Math.cos(@angle * Math::PI / 180)
|
109
113
|
|
110
|
-
|
111
|
-
|
112
|
-
|
114
|
+
vy = ((new_speed / 3) * 1) * Math.sin(@angle * Math::PI / 180)
|
115
|
+
vy = vy * -1
|
116
|
+
end
|
113
117
|
|
114
|
-
|
115
|
-
|
118
|
+
@x = @x + vx
|
119
|
+
@y = @y + vy
|
116
120
|
|
121
|
+
end
|
117
122
|
super(mouse_x, mouse_y)
|
118
123
|
end
|
119
124
|
|
@@ -165,7 +170,7 @@ class Projectile < GeneralObject
|
|
165
170
|
# hit_object = true
|
166
171
|
if self.class.get_aoe <= 0
|
167
172
|
if object.respond_to?(:health) && object.respond_to?(:take_damage)
|
168
|
-
object.take_damage(self.class.get_damage)
|
173
|
+
object.take_damage(self.class.get_damage * @damage_increase)
|
169
174
|
end
|
170
175
|
|
171
176
|
if object.respond_to?(:is_alive) && !object.is_alive && object.respond_to?(:drops)
|
@@ -189,7 +194,7 @@ class Projectile < GeneralObject
|
|
189
194
|
next if object.nil?
|
190
195
|
if Gosu.distance(@x, @y, object.x, object.y) < self.class.get_aoe * @scale
|
191
196
|
if object.respond_to?(:health) && object.respond_to?(:take_damage)
|
192
|
-
object.take_damage(self.class.get_damage)
|
197
|
+
object.take_damage(self.class.get_damage * @damage_increase)
|
193
198
|
end
|
194
199
|
|
195
200
|
if object.respond_to?(:is_alive) && !object.is_alive && object.respond_to?(:drops)
|
@@ -206,6 +211,16 @@ class Projectile < GeneralObject
|
|
206
211
|
end
|
207
212
|
end
|
208
213
|
end
|
214
|
+
|
215
|
+
# Drop projectile explosions
|
216
|
+
if hit_object
|
217
|
+
if self.respond_to?(:drops)
|
218
|
+
self.drops.each do |drop|
|
219
|
+
drops << drop
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
209
224
|
@y = @off_screen if hit_object
|
210
225
|
return {drops: drops, point_value: points, killed: killed}
|
211
226
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative 'pickup.rb'
|
2
|
+
|
3
|
+
class RocketLauncherPickup < Pickup
|
4
|
+
|
5
|
+
NAME = 'rocket_launcher'
|
6
|
+
|
7
|
+
def initialize(scale, screen_width, screen_height, x = nil, y = nil, options = {})
|
8
|
+
@x = x || rand(screen_width)
|
9
|
+
@y = y || 0
|
10
|
+
super(scale, screen_width, screen_height, @x, @y, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_image
|
14
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/rocket_launcher.png")
|
15
|
+
end
|
16
|
+
|
17
|
+
# def draw
|
18
|
+
# end
|
19
|
+
|
20
|
+
# def update
|
21
|
+
# end
|
22
|
+
|
23
|
+
def collected_by_player player
|
24
|
+
player.add_hard_point(RocketLauncherPickup::NAME)
|
25
|
+
end
|
26
|
+
end
|
@@ -1,11 +1,12 @@
|
|
1
1
|
require_relative 'projectile.rb'
|
2
|
-
|
2
|
+
# Follows targets location only at time of launch. Will not follow target
|
3
|
+
class SemiGuidedMissile < Projectile
|
3
4
|
attr_reader :x, :y, :time_alive, :mouse_start_x, :mouse_start_y, :health
|
4
5
|
COOLDOWN_DELAY = 75
|
5
|
-
MAX_SPEED =
|
6
|
+
MAX_SPEED = 30
|
6
7
|
STARTING_SPEED = 0.0
|
7
8
|
INITIAL_DELAY = 2
|
8
|
-
SPEED_INCREASE_FACTOR =
|
9
|
+
SPEED_INCREASE_FACTOR = 2
|
9
10
|
DAMAGE = 15
|
10
11
|
AOE = 0
|
11
12
|
|
@@ -15,13 +16,14 @@ class EnemyHomingMissile < Projectile
|
|
15
16
|
|
16
17
|
def get_image
|
17
18
|
# Gosu::Image.new("#{MEDIA_DIRECTORY}/mini_missile_reverse.png")
|
18
|
-
Gosu::Image.new("#{MEDIA_DIRECTORY}/
|
19
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/tiny_missile.png")
|
19
20
|
end
|
20
21
|
|
21
|
-
def initialize(scale, screen_width, screen_height, object, homing_object, angle_min, angle_max, angle_init, options = {})
|
22
|
+
def initialize(scale, screen_width, screen_height, object, homing_object, angle_min = nil, angle_max = nil, angle_init = nil, options = {})
|
22
23
|
options[:relative_object] = object
|
23
24
|
super(scale, screen_width, screen_height, object, homing_object.x, homing_object.y, angle_min, angle_max, angle_init, options)
|
24
25
|
@health = 5
|
26
|
+
# puts "CUSTOM DELAY: #{@custom_initial_delay}"
|
25
27
|
end
|
26
28
|
|
27
29
|
def destructable?
|
@@ -32,6 +34,12 @@ class EnemyHomingMissile < Projectile
|
|
32
34
|
@health > 0
|
33
35
|
end
|
34
36
|
|
37
|
+
def drops
|
38
|
+
[
|
39
|
+
SmallExplosion.new(@scale, @screen_width, @screen_height, @x, @y, nil, {ttl: 2, third_scale: true}),
|
40
|
+
]
|
41
|
+
end
|
42
|
+
|
35
43
|
|
36
44
|
def take_damage damage
|
37
45
|
@health -= damage
|
@@ -6,6 +6,9 @@ class SmallExplosion < GeneralObject
|
|
6
6
|
|
7
7
|
def initialize(scale, screen_width, screen_height, x = nil, y = nil, image = nil, options = {})
|
8
8
|
@scale = scale
|
9
|
+
if options[:third_scale]
|
10
|
+
@scale = @scale / 3
|
11
|
+
end
|
9
12
|
@smoke_scale = @scale * 1.2
|
10
13
|
@smoke = Gosu::Image.new("#{MEDIA_DIRECTORY}/smoke.png")
|
11
14
|
@image = image#Gosu::Image.new("#{MEDIA_DIRECTORY}/starfighterv4.png", :tileable => true)
|
@@ -13,15 +16,24 @@ class SmallExplosion < GeneralObject
|
|
13
16
|
@x = x || 0
|
14
17
|
@y = y || 0
|
15
18
|
@time_alive = 0
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
if @image
|
20
|
+
@image_width = @image.width * @scale
|
21
|
+
@image_height = @image.height * @scale
|
22
|
+
@image_size = @image_width * @image_height / 2
|
23
|
+
@image_radius = (@image_width + @image_height) / 4
|
24
|
+
else
|
25
|
+
@image_width = @smoke.width * @scale
|
26
|
+
@image_height = @smoke.height * @scale
|
27
|
+
@image_size = @image_width * @image_height / 2
|
28
|
+
@image_radius = (@image_width + @image_height) / 4
|
29
|
+
end
|
20
30
|
@current_speed = (SCROLLING_SPEED - 1) * @scale
|
21
31
|
|
22
32
|
@screen_width = screen_width
|
23
33
|
@screen_height = screen_height
|
24
34
|
@off_screen = screen_height + screen_height
|
35
|
+
|
36
|
+
@time_to_live = options[:ttl] || TIME_TO_LIVE
|
25
37
|
end
|
26
38
|
|
27
39
|
def draw
|
@@ -33,13 +45,13 @@ class SmallExplosion < GeneralObject
|
|
33
45
|
spin_down = @time_alive * 10
|
34
46
|
end
|
35
47
|
@smoke.draw_rot(@x, @y, ZOrder::SmallExplosions, (360 - spin_down), 0.5, 0.5, @smoke_scale, @smoke_scale)
|
36
|
-
@image.draw_rot(@x, @y, ZOrder::SmallExplosions, (360 - spin_down), 0.5, 0.5, @scale, @scale)
|
48
|
+
@image.draw_rot(@x, @y, ZOrder::SmallExplosions, (360 - spin_down), 0.5, 0.5, @scale, @scale) if @image
|
37
49
|
end
|
38
50
|
|
39
51
|
|
40
52
|
def update mouse_x = nil, mouse_y = nil, player = nil
|
41
53
|
# Remove even if hasn't gone offscreen
|
42
|
-
if @time_alive <=
|
54
|
+
if @time_alive <= @time_to_live
|
43
55
|
@time_alive += 1
|
44
56
|
@y += @current_speed
|
45
57
|
super(mouse_x, mouse_y)
|
data/line-em-up/models/star.rb
CHANGED
@@ -9,7 +9,7 @@ class Star < Pickup
|
|
9
9
|
# @scale = scale
|
10
10
|
# @image = get_image
|
11
11
|
# @time_alive = 0
|
12
|
-
@x = x || rand
|
12
|
+
@x = x || rand(screen_width)
|
13
13
|
@y = y || 0
|
14
14
|
super(scale, screen_width, screen_height, @x, @y, options)
|
15
15
|
@color = Gosu::Color.new(0xff_000000)
|
@@ -53,7 +53,11 @@ class Star < Pickup
|
|
53
53
|
# end
|
54
54
|
|
55
55
|
def collected_by_player player
|
56
|
-
|
57
|
-
player.attack_speed
|
56
|
+
value = 0.02
|
57
|
+
player.attack_speed += player.boost_increase * value
|
58
|
+
if player.attack_speed > Player::MAX_ATTACK_SPEED
|
59
|
+
player.attack_speed = Player::MAX_ATTACK_SPEED
|
60
|
+
player.health += 1
|
61
|
+
end
|
58
62
|
end
|
59
63
|
end
|
data/menu_launcher.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'gosu'
|
2
2
|
|
3
3
|
CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
|
4
|
-
MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/media"
|
4
|
+
MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/line-em-up/media"
|
5
5
|
CONFIG_FILE = "#{CURRENT_DIRECTORY}/config.txt"
|
6
6
|
|
7
7
|
Dir["#{CURRENT_DIRECTORY}/line-em-up/lib/*.rb"].each { |f| require f }
|
@@ -17,98 +17,4 @@ require "#{CURRENT_DIRECTORY}/line-em-up/game_window.rb"
|
|
17
17
|
# @menu.add_item(Gosu::Image.new("#{MEDIA_DIRECTORY}question.png"), 100, 200, 1, lambda { self.close }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}question.png", false))
|
18
18
|
# @menu.add_item(Gosu::Image.new("#{MEDIA_DIRECTORY}question.png"), 100, 250, 1, lambda { puts "something" }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}question.png", false))
|
19
19
|
|
20
|
-
|
21
|
-
class Main < Gosu::Window
|
22
|
-
def initialize
|
23
|
-
@width, @height = ResolutionSetting::RESOLUTIONS[0].split('x').collect{|s| s.to_i}
|
24
|
-
super(@width, @height, false)
|
25
|
-
@cursor = Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/cursor.png", false)
|
26
|
-
@gl_background = GLBackground.new
|
27
|
-
# x = self.width / 2 - 100
|
28
|
-
# y = self.height / 2 - 100
|
29
|
-
@center_ui_y = 0
|
30
|
-
@center_ui_x = 0
|
31
|
-
reset_center_font_ui_y
|
32
|
-
lineHeight = 50
|
33
|
-
@font = Gosu::Font.new(20)
|
34
|
-
self.caption = "A menu with Gosu"
|
35
|
-
# items = Array["exit", "additem", "item"]
|
36
|
-
# actions = Array[lambda { self.close }, lambda {
|
37
|
-
# @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/item.png", false), x, y, 1, lambda { })
|
38
|
-
# y += lineHeight
|
39
|
-
# }, lambda {}]
|
40
|
-
@menu = Menu.new(self)
|
41
|
-
# for i in (0..items.size - 1)
|
42
|
-
# @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/#{items[i]}.png", false), x, y, 1, actions[i], Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/#{items[i]}_hover.png", false))
|
43
|
-
# y += lineHeight
|
44
|
-
# end
|
45
|
-
exit_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/exit.png")
|
46
|
-
# puts "WIDTH HERE: #{exit_image.width}"
|
47
|
-
# 8
|
48
|
-
@menu.add_item(exit_image, ((@width / 2) - (exit_image.width / 2)), get_center_font_ui_y, 1, lambda { self.close }, exit_image)
|
49
|
-
window_height = Gosu.screen_height
|
50
|
-
@resolution_menu = ResolutionSetting.new(window_height, @width, @height, get_center_font_ui_y, CONFIG_FILE)
|
51
|
-
|
52
|
-
@difficulty = nil
|
53
|
-
@difficulty_menu = DifficultySetting.new(@width, @height, get_center_font_ui_y, CONFIG_FILE)
|
54
|
-
|
55
|
-
start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/start.png")
|
56
|
-
@game_window_width, @game_window_height, @full_screen = [nil, nil, nil]
|
57
|
-
@menu.add_item(start_image, (@width / 2) - (start_image.width / 2), get_center_font_ui_y, 1, lambda {self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true, difficulty: @difficulty}) }, start_image)
|
58
|
-
debug_start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/debug_start.png")
|
59
|
-
@menu.add_item(debug_start_image, (@width / 2) - (debug_start_image.width / 2), get_center_font_ui_y, 1, lambda {self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true, debug: true, difficulty: @difficulty}) }, start_image)
|
60
|
-
# @font.draw("<", width + 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
|
61
|
-
# @font.draw("Resolution", width / 2, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
|
62
|
-
# @font.draw(">", width - 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
|
63
|
-
# @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/start.png", false), get_center_font_ui_x, get_center_font_ui_y, 1, lambda { self.close; GameWindow.start(nil, nil, {block_controls_until_button_up: true}) }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/start.png", false))
|
64
|
-
end
|
65
|
-
|
66
|
-
def dynamic_get_resolution_fs
|
67
|
-
@fullscreen
|
68
|
-
end
|
69
|
-
|
70
|
-
def update
|
71
|
-
@menu.update
|
72
|
-
@resolution_menu.update(self.mouse_x, self.mouse_y)
|
73
|
-
@difficulty_menu.update(self.mouse_x, self.mouse_y)
|
74
|
-
|
75
|
-
@game_window_width, @game_window_height, @fullscreen = @resolution_menu.get_resolution
|
76
|
-
@difficulty = @difficulty_menu.get_difficulty
|
77
|
-
@gl_background.scroll
|
78
|
-
end
|
79
|
-
|
80
|
-
def draw
|
81
|
-
@cursor.draw(self.mouse_x, self.mouse_y, 2)
|
82
|
-
# @back.draw(0,0,0)
|
83
|
-
reset_center_font_ui_y
|
84
|
-
@menu.draw
|
85
|
-
@resolution_menu.draw
|
86
|
-
@difficulty_menu.draw
|
87
|
-
@gl_background.draw(ZOrder::Background)
|
88
|
-
end
|
89
|
-
|
90
|
-
def button_down id
|
91
|
-
if id == Gosu::MsLeft then
|
92
|
-
@menu.clicked
|
93
|
-
@resolution_menu.clicked(self.mouse_x, self.mouse_y)
|
94
|
-
@difficulty_menu.clicked(self.mouse_x, self.mouse_y)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def get_center_font_ui_y
|
99
|
-
return_value = @center_ui_y
|
100
|
-
@center_ui_y += 50
|
101
|
-
return return_value
|
102
|
-
end
|
103
|
-
|
104
|
-
def get_center_font_ui_x
|
105
|
-
return @center_ui_x
|
106
|
-
end
|
107
|
-
|
108
|
-
def reset_center_font_ui_y
|
109
|
-
@center_ui_y = self.height / 2 - 100
|
110
|
-
@center_ui_x = self.width / 2 - 100
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
20
|
Main.new.show
|