line-em-up 0.4.0 → 2.0.0

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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/line-em-up/game_window.rb +189 -52
  3. data/line-em-up/irb_requirements.rb +24 -2
  4. data/line-em-up/lib/config_setting.rb +126 -16
  5. data/line-em-up/lib/difficulty_setting.rb +64 -64
  6. data/line-em-up/lib/lighting.rb +143 -0
  7. data/line-em-up/lib/resolution_setting.rb +58 -58
  8. data/line-em-up/lib/setting.rb +104 -0
  9. data/line-em-up/lib/ship_loadout_setting.rb +476 -0
  10. data/line-em-up/lib/ship_setting.rb +98 -0
  11. data/line-em-up/lib/z_order.rb +1 -1
  12. data/line-em-up/loadout_window.rb +253 -0
  13. data/line-em-up/media/bullet_launcher_hardpoint.png +0 -0
  14. data/line-em-up/media/hardpoint_empty.png +0 -0
  15. data/line-em-up/media/header@2x.psd +0 -0
  16. data/line-em-up/media/laser-end-background-half.png +0 -0
  17. data/line-em-up/media/laser-end-background.png +0 -0
  18. data/line-em-up/media/laser-end-overlay-half.png +0 -0
  19. data/line-em-up/media/laser-end-overlay.png +0 -0
  20. data/line-em-up/media/laser-middle-background-half.png +0 -0
  21. data/line-em-up/media/laser-middle-background.png +0 -0
  22. data/line-em-up/media/laser-middle-overlay-half.png +0 -0
  23. data/line-em-up/media/laser-middle-overlay-short.png +0 -0
  24. data/line-em-up/media/laser-middle-overlay.png +0 -0
  25. data/line-em-up/media/laser-overlay-half.png +0 -0
  26. data/line-em-up/media/laser-overlay.png +0 -0
  27. data/line-em-up/media/laser-start-background-half.png +0 -0
  28. data/line-em-up/media/laser-start-background.png +0 -0
  29. data/line-em-up/media/laser-start-overlay-half.png +0 -0
  30. data/line-em-up/media/laser-start-overlay.png +0 -0
  31. data/line-em-up/media/laser_beam_hardpoint copy.png +0 -0
  32. data/line-em-up/media/laser_beam_hardpoint.png +0 -0
  33. data/line-em-up/media/line-em-up-resolution.png +0 -0
  34. data/line-em-up/media/menu/loadout.png +0 -0
  35. data/line-em-up/media/{start.png → menu/start.png} +0 -0
  36. data/line-em-up/media/missile_launcher.png +0 -0
  37. data/line-em-up/media/{spaceship.png → pilotable_ships/basic_ship/default.png} +0 -0
  38. data/line-em-up/media/{spaceship_original.png → pilotable_ships/basic_ship/large.png} +0 -0
  39. data/line-em-up/media/{spaceship_left.png → pilotable_ships/basic_ship/left.png} +0 -0
  40. data/line-em-up/media/pilotable_ships/basic_ship/left_broadside.png +0 -0
  41. data/line-em-up/media/pilotable_ships/basic_ship/original.png +0 -0
  42. data/line-em-up/media/{spaceship_right.png → pilotable_ships/basic_ship/right.png} +0 -0
  43. data/line-em-up/media/pilotable_ships/basic_ship/right_broadside.png +0 -0
  44. data/line-em-up/media/pilotable_ships/mite_ship/default.png +0 -0
  45. data/line-em-up/media/pilotable_ships/mite_ship/large.png +0 -0
  46. data/line-em-up/media/pilotable_ships/mite_ship/left.png +0 -0
  47. data/line-em-up/media/pilotable_ships/mite_ship/left_broadside.png +0 -0
  48. data/line-em-up/media/pilotable_ships/mite_ship/original.png +0 -0
  49. data/line-em-up/media/pilotable_ships/mite_ship/right.png +0 -0
  50. data/line-em-up/media/pilotable_ships/mite_ship/right_broadside.png +0 -0
  51. data/line-em-up/media/pilotable_ships/mite_ship.zip +0 -0
  52. data/line-em-up/models/basic_ship.rb +94 -0
  53. data/line-em-up/models/bomb.rb +1 -1
  54. data/line-em-up/models/building.rb +2 -2
  55. data/line-em-up/models/bullet.rb +127 -74
  56. data/line-em-up/models/bullet_launcher.rb +23 -0
  57. data/line-em-up/models/cursor.rb +37 -1
  58. data/line-em-up/models/dumb_missile_launcher.rb +40 -0
  59. data/line-em-up/models/dumb_projectile.rb +9 -2
  60. data/line-em-up/models/enemy_bomb.rb +1 -1
  61. data/line-em-up/models/enemy_bullet.rb +55 -0
  62. data/line-em-up/models/enemy_player.rb +1 -1
  63. data/line-em-up/models/execute_open_gl.rb +80 -0
  64. data/line-em-up/models/general_object.rb +82 -9
  65. data/line-em-up/models/gl_background.rb +103 -30
  66. data/line-em-up/models/grappling_hook.rb +1 -1
  67. data/line-em-up/models/hardpoint.rb +120 -0
  68. data/line-em-up/models/laser_launcher.rb +192 -0
  69. data/line-em-up/models/laser_particle.rb +133 -0
  70. data/line-em-up/models/launcher.rb +149 -0
  71. data/line-em-up/models/main.rb +119 -26
  72. data/line-em-up/models/menu.rb +43 -3
  73. data/line-em-up/models/menu_item.rb +25 -14
  74. data/line-em-up/models/missile_boat.rb +5 -4
  75. data/line-em-up/models/mite.rb +3 -2
  76. data/line-em-up/models/mite_ship.rb +61 -0
  77. data/line-em-up/models/mothership.rb +1 -1
  78. data/line-em-up/models/pickup.rb +2 -2
  79. data/line-em-up/models/pilotable_ship.rb +599 -0
  80. data/line-em-up/models/player.rb +207 -150
  81. data/line-em-up/models/projectile.rb +3 -24
  82. data/line-em-up/models/semi_guided_missile.rb +1 -1
  83. data/line-em-up/models/small_explosion.rb +2 -2
  84. data/line-em-up/models/star.rb +7 -2
  85. data/menu_launcher.rb +10 -6
  86. metadata +113 -10
  87. data/line-em-up/media/spaceship_left-test.png +0 -0
@@ -1,13 +1,24 @@
1
1
  require_relative 'general_object.rb'
2
2
  require_relative 'rocket_launcher_pickup.rb'
3
+ require_relative '../lib/config_setting.rb'
4
+ require 'gosu'
5
+
6
+ require 'opengl'
7
+ require 'glut'
8
+
9
+
10
+ include OpenGL
11
+ include GLUT
3
12
 
4
13
  class Player < GeneralObject
14
+ CONFIG_FILE = "#{CURRENT_DIRECTORY}/../config.txt"
15
+ puts "CONFIG SHOULD BE HERE: #{CONFIG_FILE}"
5
16
  SPEED = 7
6
17
  MAX_ATTACK_SPEED = 3.0
7
18
  attr_accessor :cooldown_wait, :secondary_cooldown_wait, :attack_speed, :health, :armor, :x, :y, :rockets, :score, :time_alive
8
19
 
9
20
  attr_accessor :bombs, :secondary_weapon, :grapple_hook_cooldown_wait, :damage_reduction, :boost_increase, :damage_increase, :kill_count
10
- attr_accessor :special_attack
21
+ attr_accessor :special_attack, :main_weapon, :drawable_items_near_self, :broadside_mode
11
22
  MAX_HEALTH = 200
12
23
 
13
24
  SECONDARY_WEAPONS = [RocketLauncherPickup::NAME] + %w[bomb]
@@ -19,6 +30,53 @@ class Player < GeneralObject
19
30
  SPECIAL_POWER = 'laser'
20
31
  SPECIAL_POWER_KILL_MAX = 50
21
32
 
33
+ def initialize(scale, x, y, screen_width, screen_height, options = {})
34
+ super(scale, x, y, screen_width, screen_height, options)
35
+ # Top of screen
36
+ @min_moveable_height = options[:min_moveable_height] || 0
37
+ # Bottom of the screen
38
+ @max_movable_height = options[:max_movable_height] || screen_height
39
+ # @right_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_right.png")
40
+ # @left_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_left.png")
41
+ # @broadside_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_broadside.png")
42
+ @score = 0
43
+ @cooldown_wait = 0
44
+ @secondary_cooldown_wait = 0
45
+ @grapple_hook_cooldown_wait = 0
46
+ @attack_speed = 3
47
+ # @attack_speed = 3
48
+ @health = 100.0
49
+ @armor = 0
50
+ @rockets = 50
51
+ # @rockets = 250
52
+ @bombs = 3
53
+ @secondary_weapon = RocketLauncherPickup::NAME
54
+ @turn_right = false
55
+ @turn_left = false
56
+
57
+ @hard_point_items = [RocketLauncherPickup::NAME, 'cannon_launcher', 'cannon_launcher', 'bomb_launcher']
58
+ @rocket_launchers = 0
59
+ @bomb_launchers = 0
60
+ @cannon_launchers = 0
61
+ trigger_hard_point_load
62
+ @damage_reduction = options[:handicap] ? options[:handicap] : 1
63
+ invert_handicap = 1 - options[:handicap]
64
+ @boost_increase = invert_handicap > 0 ? 1 + (invert_handicap * 1.25) : 1
65
+ @damage_increase = invert_handicap > 0 ? 1 + (invert_handicap) : 1
66
+ @kill_count = 0
67
+ @main_weapon = nil
68
+ # @drawable_items_near_self = []
69
+ @broadside_mode = false
70
+ ship = ConfigSetting.get_setting(CONFIG_FILE, 'ship', BasicShip)
71
+ if ship
72
+ ship_class = eval(ship)
73
+ @ship = ship_class.new(scale, x, y, screen_width, screen_height, options)
74
+ else
75
+ @ship = BasicShip.new(scale, x, y, screen_width, screen_height, options)
76
+ end
77
+ @angle = 90
78
+ end
79
+
22
80
  def get_kill_count_max
23
81
  self.class::SPECIAL_POWER_KILL_MAX
24
82
  end
@@ -27,11 +85,54 @@ class Player < GeneralObject
27
85
  @kill_count >= get_kill_count_max
28
86
  end
29
87
 
30
- def special_attack
88
+ def special_attack object_groups
31
89
  # Fire special attack.
32
90
  @kill_count = 0
91
+ projectiles = []
92
+ object_groups.each do |group|
93
+ group.each do |object|
94
+ next if object.nil?
95
+ projectiles << Missile.new(@scale, @screen_width, @screen_height, self, object.x, object.y, nil, nil, nil, {damage_increase: @damage_increase})
96
+ end
97
+ end
98
+ return projectiles
33
99
  end
34
100
 
101
+
102
+ def special_attack_2
103
+ # Fire special attack.
104
+ @kill_count = 0
105
+ projectiles = []
106
+ # object_groups.each do |group|
107
+ # group.each do |object|
108
+ # next if object.nil?
109
+ # projectiles << Missile.new(@scale, @screen_width, @screen_height, self, object.x, object.y, nil, nil, nil, {damage_increase: @damage_increase})
110
+ # end
111
+ # end
112
+
113
+ r = 10 * @scale
114
+ theta = 0
115
+ count_max = 360
116
+ max_passes = 3
117
+ pass_count = 0
118
+ theta = 0
119
+ # Need a projectile queue system?
120
+ while theta < count_max
121
+ x = @x + r * Math.cos(theta)
122
+ y = @y + r * Math.sin(theta)
123
+ if y < @y
124
+
125
+ projectiles << Missile.new(@scale, @screen_width, @screen_height, self, x, y, nil, nil, nil, {damage_increase: @damage_increase})
126
+
127
+ end
128
+ theta += 5
129
+ end
130
+ # where r is the radius of the circle, and h,k are the coordinates of the center.
131
+
132
+ return projectiles
133
+ end
134
+
135
+
35
136
  # Rocket Launcher, Rocket launcher, Cannon, Cannon, Bomb Launcher
36
137
  HARD_POINTS = 12
37
138
 
@@ -69,48 +170,55 @@ class Player < GeneralObject
69
170
  end
70
171
  end
71
172
 
72
- def get_image
73
- Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship.png")
74
- end
173
+ # Issue with image.. probably shouldn't be using images to define sizes
174
+ # def get_image
175
+ # # if @inited
176
+ # # @ship.get_image
177
+ # # end
178
+ # if @broadside_mode
179
+ # Gosu::Image.new("#{MEDIA_DIRECTORY}/pilotable_ships/basic_ship/spaceship_broadside.png")
180
+ # else
181
+ # Gosu::Image.new("#{MEDIA_DIRECTORY}/pilotable_ships/basic_ship/spaceship.png")
182
+ # end
183
+ # end
184
+
185
+ # def get_image_path
186
+ # "#{MEDIA_DIRECTORY}/spaceship.png"
187
+ # end
75
188
 
76
- def initialize(scale, x, y, screen_width, screen_height, options = {})
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
82
- @right_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_right.png")
83
- @left_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/spaceship_left.png")
84
- @score = 0
85
- @cooldown_wait = 0
86
- @secondary_cooldown_wait = 0
87
- @grapple_hook_cooldown_wait = 0
88
- @attack_speed = 1
89
- # @attack_speed = 3
90
- @health = 100.0
91
- @armor = 0
92
- @rockets = 50
93
- # @rockets = 250
94
- @bombs = 3
95
- @secondary_weapon = RocketLauncherPickup::NAME
96
- @turn_right = false
97
- @turn_left = false
98
189
 
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
190
+ def rotate_counterclockwise
191
+ return @ship.rotate_counterclockwise
109
192
  end
110
193
 
194
+ def rotate_clockwise
195
+ return @ship.rotate_clockwise
196
+ end
197
+
198
+ # def laser_attack pointer
199
+ # if @main_weapon.nil?
200
+ # # options = {damage_increase: @damage_increase, relative_y_padding: @image_height_half}
201
+ # options = {damage_increase: @damage_increase}
202
+ # @main_weapon = LaserBeam.new(@scale, @screen_width, @screen_height, self, options)
203
+ # @drawable_items_near_self << @main_weapon
204
+ # return {
205
+ # projectiles: [@main_weapon.attack],
206
+ # cooldown: LaserBeam::COOLDOWN_DELAY
207
+ # }
208
+ # else
209
+ # @main_weapon.active = true if @main_weapon.active == false
210
+ # @drawable_items_near_self << @main_weapon
211
+ # return {
212
+ # projectiles: [@main_weapon.attack],
213
+ # cooldown: LaserBeam::COOLDOWN_DELAY
214
+ # }
215
+ # end
216
+ # end
217
+
111
218
 
112
219
  def take_damage damage
113
- @health -= damage * @damage_reduction
220
+ @ship.take_damage(damage)
221
+ # @health -= damage * @damage_reduction
114
222
  end
115
223
 
116
224
  def toggle_secondary
@@ -158,130 +266,92 @@ class Player < GeneralObject
158
266
  end
159
267
 
160
268
  def is_alive
161
- health > 0
269
+ @ship.is_alive
270
+ # health > 0
162
271
  end
163
272
 
164
- def get_speed
165
- (SPEED * @scale).round
166
- end
273
+ # CAP movement w/ Acceleration!!!!!!!!!!!!!!!!!!!
167
274
 
168
- def move_left
169
- @turn_left = true
170
- @x = [@x - get_speed, (get_width/3)].max
275
+ def move_left movement_x = 0, movement_y = 0
276
+ # @x = @ship.move_left
277
+ return [movement_x - 1.0, movement_y]
171
278
  end
172
279
 
173
- def move_right
174
- @turn_right = true
175
- @x = [@x + get_speed, (@screen_width - (get_width/3))].min
280
+ def move_right movement_x = 0, movement_y = 0
281
+ # @x = @ship.move_right
282
+ return [movement_x + 1.0, movement_y]
176
283
  end
177
284
 
178
- def accelerate
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
285
+ def accelerate movement_x = 0, movement_y = 0
286
+ # @y = @ship.accelerate
287
+ puts "ACCELLERATE"
288
+ return [movement_x, movement_y + 1.0]
185
289
  end
186
290
 
187
- def brake
188
- @y = [@y + get_speed, @max_movable_height - (get_height/2)].min
291
+ def brake movement_x = 0, movement_y = 0
292
+ # @y = @ship.brake
293
+ return [movement_x, movement_y - 1.0]
189
294
  end
190
295
 
191
296
 
192
- def attack pointer
193
- return {
194
- projectiles: [
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})
197
- ],
198
- cooldown: Bullet::COOLDOWN_DELAY
199
- }
297
+ def attack_group_1 pointer
298
+ @ship.attack_group_1(pointer)
299
+ end
300
+
301
+ def deactivate_group_1
302
+ @ship.deactivate_group_1
200
303
  end
201
304
 
202
- def trigger_secondary_attack pointer
203
- return_projectiles = []
204
- if self.secondary_cooldown_wait <= 0 && self.get_secondary_ammo_count > 0
205
- results = self.secondary_attack(pointer)
206
- projectiles = results[:projectiles]
207
- cooldown = results[:cooldown]
208
- self.secondary_cooldown_wait = cooldown.to_f.fdiv(self.attack_speed)
209
-
210
- projectiles.each do |projectile|
211
- return_projectiles.push(projectile)
212
- end
213
- end
214
- return return_projectiles
305
+ def attack_group_2 pointer
306
+ @ship.attack_group_2(pointer)
307
+ end
308
+
309
+ def deactivate_group_2
310
+ @ship.deactivate_group_2
215
311
  end
216
312
 
217
- # def toggle_state_secondary_attack
218
- # second_weapon = case @secondary_weapon
219
- # when 'bomb'
220
- # else
313
+
314
+ # def trigger_secondary_attack pointer
315
+ # return_projectiles = []
316
+ # if self.secondary_cooldown_wait <= 0 && self.get_secondary_ammo_count > 0
317
+ # results = @ship.secondary_attack(pointer)
318
+ # projectiles = results[:projectiles]
319
+ # cooldown = results[:cooldown]
320
+ # self.secondary_cooldown_wait = cooldown.to_f.fdiv(self.attack_speed)
321
+
322
+ # projectiles.each do |projectile|
323
+ # return_projectiles.push(projectile)
324
+ # end
221
325
  # end
222
- # return second_weapon
326
+ # return return_projectiles
223
327
  # end
224
328
 
225
- def secondary_attack pointer
226
- projectiles = []
227
- cooldown = 0
228
- case @secondary_weapon
229
- when 'bomb'
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}"
260
- end
261
- end
262
- decrement_secondary_ammo_count projectiles.count
263
- return {projectiles: projectiles, cooldown: cooldown}
264
- end
265
-
266
329
  def get_draw_ordering
267
330
  ZOrder::Player
268
331
  end
269
332
 
270
333
  def draw
271
- if @turn_right
272
- image = @right_image
273
- elsif @turn_left
274
- image = @left_image
275
- else
276
- image = @image
277
- end
278
- # super
279
- image.draw(@x - get_width / 2, @y - get_height / 2, get_draw_ordering, @scale, @scale)
280
- @turn_right = false
281
- @turn_left = false
334
+ # @drawable_items_near_self.reject! { |item| item.draw }
335
+ @ship.draw
336
+ end
337
+
338
+ POINTS_X = 7
339
+ POINTS_Y = 7
340
+
341
+ def draw_gl_list
342
+ # @drawable_items_near_self + [self]
343
+ @ship.draw_gl_list
344
+ end
345
+
346
+ def draw_gl
347
+ @ship.draw_gl
282
348
  end
283
349
 
284
- def update mouse_x = nil, mouse_y = nil, player = nil
350
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
351
+ @ship.update(mouse_x, mouse_y, player, scroll_factor)
352
+ # Update list of weapons for special cases like beans. Could iterate though an association in the future.
353
+ # @main_weapon.update(mouse_x, mouse_y, player) if @main_weapon
354
+
285
355
  @cooldown_wait -= 1 if @cooldown_wait > 0
286
356
  @secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
287
357
  @grapple_hook_cooldown_wait -= 1 if @grapple_hook_cooldown_wait > 0
@@ -289,20 +359,7 @@ class Player < GeneralObject
289
359
  end
290
360
 
291
361
  def collect_pickups(pickups)
292
- pickups.reject! do |pickup|
293
- if Gosu.distance(@x, @y, pickup.x, pickup.y) < ((self.get_radius) + (pickup.get_radius)) * 1.2 && pickup.respond_to?(:collected_by_player)
294
- pickup.collected_by_player(self)
295
- if pickup.respond_to?(:get_points)
296
- self.score += pickup.get_points
297
- end
298
- # stop that!
299
- # @beep.play
300
- true
301
- else
302
- false
303
- end
304
- end
362
+ @ship.collect_pickups(pickups)
305
363
  end
306
364
 
307
-
308
365
  end
@@ -18,6 +18,8 @@ class Projectile < GeneralObject
18
18
  Gosu::Image.new("#{MEDIA_DIRECTORY}/question.png")
19
19
  end
20
20
 
21
+ def draw_gl
22
+ end
21
23
  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
24
  if options[:x_homing_padding]
23
25
  end_point_x = end_point_x + options[:x_homing_padding]
@@ -28,15 +30,10 @@ class Projectile < GeneralObject
28
30
  super(scale, nil, nil, screen_width, screen_height, options)
29
31
 
30
32
  start_point = OpenStruct.new(:x => @x - screen_width / 2, :y => @y - screen_height / 2)
31
- # start_point = GeoPoint.new(@x - WIDTH / 2, @y - HEIGHT / 2)
32
- # end_point = OpenStruct.new(:x => @mouse_start_x, :y => @mouse_start_y)
33
33
  end_point = OpenStruct.new(:x => end_point_x - screen_width / 2, :y => end_point_y - screen_height / 2)
34
- # end_point = GeoPoint.new(@mouse_start_x - WIDTH / 2, @mouse_start_y - HEIGHT / 2)
35
34
  @angle = calc_angle(start_point, end_point)
36
35
  @radian = calc_radian(start_point, end_point)
37
36
 
38
- # puts "PRE-ANGLE: #{@angle}"
39
-
40
37
  @image_angle = @angle
41
38
  if @angle < 0
42
39
  @angle = 360 - @angle.abs
@@ -45,39 +42,22 @@ class Projectile < GeneralObject
45
42
  if angle_min.nil? && angle_max.nil?
46
43
  # do nothing
47
44
  else
48
- # if @angle < angle_min
49
- # @angle = angle_max
50
- # # elsif @angle < angle_min && @angle > add_angles(@angle, 180)
51
- # # @angle = angle_max
52
45
  if is_angle_between_two_angles?(@angle, angle_min, angle_max)
53
46
  # Do nothing, we're good
54
- # puts "ANGLE WAS BETWEEN TWO POINTS: #{@angle} was between #{angle_min} and #{angle_max}"
55
47
  else
56
- # puts "ANGLE WAS CHOSEN TO BE NEAREST: #{@angle} with #{angle_min} and #{angle_max}"
57
48
  @angle = nearest_angle(@angle, angle_min, angle_max)
58
- # puts "ANGLE WAS CHSOEN: #{@angle}"
59
49
  end
60
50
  end
61
51
 
62
-
63
52
  if angle_init
64
53
  @current_image_angle = (angle_init - 90) * -1
65
54
  @end_image_angle = (@angle - 90) * -1
66
55
  else
67
56
  @current_image_angle = (@angle - 90) * -1
68
57
  end
69
-
70
- # puts "POST-ANGLE: #{@angle}"
71
-
72
- # # Limit extreme angles 180 and 0 are the
73
- # image_angle = 0
74
- # if @angle > 160 <
75
- # if @angle > 160 && @ange
76
-
77
-
78
58
  end
79
59
 
80
- def update mouse_x = nil, mouse_y = nil
60
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
81
61
  if @end_image_angle && @time_alive > 10
82
62
  incrementing_amount = 0.5
83
63
  angle_difference = (@current_image_angle - @end_image_angle)
@@ -90,7 +70,6 @@ class Projectile < GeneralObject
90
70
  elsif angle_difference < 0
91
71
  @current_image_angle += incrementing_amount
92
72
  else
93
- # puts "ENDING IMAGE HERE!!!!!!"
94
73
  @current_image_angle = @end_image_angle
95
74
  @end_image_angle = nil
96
75
  end
@@ -46,7 +46,7 @@ class SemiGuidedMissile < Projectile
46
46
  end
47
47
 
48
48
 
49
- def update mouse_x = nil, mouse_y = nil
49
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
50
50
  if is_alive
51
51
  super(mouse_x, mouse_y)
52
52
  else
@@ -49,11 +49,11 @@ class SmallExplosion < GeneralObject
49
49
  end
50
50
 
51
51
 
52
- def update mouse_x = nil, mouse_y = nil, player = nil
52
+ def update mouse_x = nil, mouse_y = nil, player = nil, factor = 1
53
53
  # Remove even if hasn't gone offscreen
54
54
  if @time_alive <= @time_to_live
55
55
  @time_alive += 1
56
- @y += @current_speed
56
+ @y += @current_speed * factor
57
57
  super(mouse_x, mouse_y)
58
58
  else
59
59
  false
@@ -46,7 +46,7 @@ class Star < Pickup
46
46
  @image.draw_rot(@x, @y, ZOrder::Pickups, @y, 0.5, 0.5, @scale, @scale, @color, :add)
47
47
  end
48
48
 
49
- # def update mouse_x = nil, mouse_y = nil
49
+ # def update mouse_x = nil, mouse_y = nil, scroll_factor = 1
50
50
  # # Move towards bottom of screen
51
51
  # @y += 1
52
52
  # super(mouse_x, mouse_y)
@@ -57,7 +57,12 @@ class Star < Pickup
57
57
  player.attack_speed += player.boost_increase * value
58
58
  if player.attack_speed > Player::MAX_ATTACK_SPEED
59
59
  player.attack_speed = Player::MAX_ATTACK_SPEED
60
- player.health += 1
60
+ if player.health + value > player.class::MAX_HEALTH
61
+ player.health = player.class::MAX_HEALTH
62
+ else
63
+
64
+ player.health += 1
65
+ end
61
66
  end
62
67
  end
63
68
  end
data/menu_launcher.rb CHANGED
@@ -1,20 +1,24 @@
1
1
  require 'gosu'
2
2
 
3
- CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
3
+ current_directory = File.expand_path('../', __FILE__)
4
4
  MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/line-em-up/media"
5
- CONFIG_FILE = "#{CURRENT_DIRECTORY}/config.txt"
5
+ config_file = "#{current_directory}/config.txt"
6
+ vendor_directory = File.expand_path('../', __FILE__) + "/vendors"
7
+ require "#{vendor_directory}/lib/luit.rb"
6
8
 
7
- Dir["#{CURRENT_DIRECTORY}/line-em-up/lib/*.rb"].each { |f| require f }
9
+
10
+ Dir["#{current_directory}/line-em-up/lib/*.rb"].each { |f| require f }
8
11
  # Shouldn't need models
9
12
  # Does need the GL BACKGROUND Model
10
- require "#{CURRENT_DIRECTORY}/line-em-up/models/gl_background.rb"
13
+ require "#{current_directory}/line-em-up/models/gl_background.rb"
11
14
  # Dir["#{CURRENT_DIRECTORY}/line-em-up/models/*.rb"].each { |f| require f }
12
15
 
13
- require "#{CURRENT_DIRECTORY}/line-em-up/game_window.rb"
16
+ require "#{current_directory}/line-em-up/game_window.rb"
17
+ require "#{current_directory}/line-em-up/loadout_window.rb"
14
18
 
15
19
  # @menu = Menu.new(self) #instantiate the menu, passing the Window in the constructor
16
20
 
17
21
  # @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
22
  # @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
23
 
20
- Main.new.show
24
+ Main.new(config_file).show