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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8342c51e3321fb4fece0302657a4ca034a4d78a6
4
- data.tar.gz: 87f084f07f94bc47e837d0527cf54d3111528dcf
3
+ metadata.gz: b7ab411416d21726d2c0e5bbc52b6432a765c3b3
4
+ data.tar.gz: 9d63371403a4bc9b12a192891d7ec4cc80d2f3d7
5
5
  SHA512:
6
- metadata.gz: 868ba45bb2b797f9af0b9e9fcb8377d556dc32172f6a59c3cb2bca296134573b9b62c62c55c43813599aea07e582f34e7aec2f7c6eb28542e2625597f5294f2c
7
- data.tar.gz: 8a8b90012fae38067138062d0ab5444c45e24de6fef95a91c7ab4d4de7ceadf8df4ca7494de63ef9fdbef20e912f096604d71b8184fda52cfd379c7016eb5209
6
+ metadata.gz: 3d71a41dadf48523a227b964ce971459c7517382fc3ba2d57a96676fbba26b7280c8f6de461aa9ff74bb3967a9db85fd6c4b32cbce2cc70cc10c0234d66af82f
7
+ data.tar.gz: e7a0965624b497028586b7c383c0f22b446f9030abd77ee833dd770d0f4877f9d4ee57759bbabb8f63f7403da87e495d8643c3609cd7fa2632629b1832bbf607
@@ -27,6 +27,8 @@ require 'gosu'
27
27
 
28
28
  CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
29
29
  MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/media"
30
+ VENDOR_DIRECTORY = File.expand_path('../', __FILE__) + "/../vendors"
31
+ require "#{VENDOR_DIRECTORY}/lib/luit.rb"
30
32
 
31
33
  # ONLY ENABLE FOR WINDOWS COMPILATION
32
34
  # Place opengl lib in lib library
@@ -60,16 +62,23 @@ Dir["#{CURRENT_DIRECTORY}/models/*.rb"].each { |f| require f }
60
62
  # exit if Object.const_defined?(:Ocra) #allow ocra to create an exe without executing the entire script
61
63
 
62
64
 
63
- DEFAULT_WIDTH, DEFAULT_HEIGHT = 640, 480
64
65
 
65
- RESOLUTIONS = [[640, 480], [800, 600], [960, 720], [1024, 768], [1280, 960], [1400, 1050], [1440, 1080], [1600, 1200], [1856, 1392], [1920, 1440], [2048, 1536]]
66
66
  # RESOLUTIONS = [[640, 480], [800, 600], [960, 720], [1024, 768]]
67
67
  # WIDTH, HEIGHT = 1080, 720
68
68
 
69
69
  class GameWindow < Gosu::Window
70
+ RESOLUTIONS = [[640, 480], [800, 600], [960, 720], [1024, 768], [1280, 960], [1400, 1050], [1440, 1080], [1600, 1200], [1856, 1392], [1920, 1440], [2048, 1536]]
71
+ DEFAULT_WIDTH, DEFAULT_HEIGHT = 640, 480
72
+
73
+ CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
74
+ CONFIG_FILE = "#{CURRENT_DIRECTORY}/../config.txt"
75
+
70
76
  attr_accessor :width, :height, :block_all_controls
71
77
 
72
78
  def initialize width = nil, height = nil, fullscreen = false, options = {}
79
+ @config_path = self.class::CONFIG_FILE
80
+ @window = self
81
+ @open_gl_executer = ExecuteOpenGl.new
73
82
  @difficulty = options[:difficulty]
74
83
  @block_all_controls = !options[:block_controls_until_button_up].nil? && options[:block_controls_until_button_up] == true ? true : false
75
84
  @debug = options[:debug]
@@ -78,20 +87,43 @@ class GameWindow < Gosu::Window
78
87
  @center_ui_y = 0
79
88
  @center_ui_x = 0
80
89
 
81
- @width = width || DEFAULT_WIDTH
82
- @height = height || DEFAULT_HEIGHT
90
+ # @width = width || DEFAULT_WIDTH
91
+ # @height = height || DEFAULT_HEIGHT
83
92
 
84
- reset_center_font_ui_y
93
+ # reset_center_font_ui_y
85
94
 
86
- index = GameWindow.find_index_of_current_resolution(self.width, self.height)
87
- if index == 0
95
+ # Need to just pull from config file.. and then do scaling. See LoadoutWindow
96
+ # index = GameWindow.find_index_of_current_resolution(self.width, self.height)
97
+ # if index == 0
98
+ # @scale = 1
99
+ # else
100
+ # original_width, original_height = RESOLUTIONS[0]
101
+ # width_scale = @width / original_width.to_f
102
+ # height_scale = @height / original_height.to_f
103
+ # @scale = (width_scale + height_scale) / 2
104
+ # end
105
+ value = ConfigSetting.get_setting(@config_path, 'resolution', ResolutionSetting::SELECTION[0])
106
+ raise "DID NOT GET A RESOLUTION FROM CONFIG" if value.nil?
107
+ width, height = value.split('x')
108
+ @width, @height = [width.to_i, height.to_i]
109
+
110
+ default_width, default_height = ResolutionSetting::SELECTION[0].split('x')
111
+ # default_width, default_height = default_value.split('x')
112
+ default_width, default_height = [default_width.to_i, default_height.to_i]
113
+
114
+
115
+ # Need to just pull from config file.. and then do scaling.
116
+ # index = GameWindow.find_index_of_current_resolution(self.width, self.height)
117
+ if @width == default_width && @height == @default_height
88
118
  @scale = 1
89
119
  else
90
- original_width, original_height = RESOLUTIONS[0]
91
- width_scale = @width / original_width.to_f
92
- height_scale = @height / original_height.to_f
120
+ # original_width, original_height = RESOLUTIONS[0]
121
+ width_scale = @width / default_width.to_f
122
+ height_scale = @height / default_height.to_f
93
123
  @scale = (width_scale + height_scale) / 2
94
124
  end
125
+
126
+
95
127
  super(@width, @height)
96
128
 
97
129
  @game_pause = false
@@ -105,6 +137,7 @@ class GameWindow < Gosu::Window
105
137
  @can_toggle_fullscreen_a = true
106
138
  @can_toggle_fullscreen_b = true
107
139
 
140
+
108
141
  self.caption = "OpenGL Integration"
109
142
 
110
143
  @gl_background = GLBackground.new
@@ -127,9 +160,10 @@ class GameWindow < Gosu::Window
127
160
  @enemies_killed = 0
128
161
 
129
162
  @font = Gosu::Font.new(20)
130
- @max_enemies = 4
163
+ # @max_enemies = 4
164
+ @max_enemies = 0
131
165
 
132
- @pointer = Cursor.new(@scale)
166
+ @pointer = Cursor.new(@scale, @width, @height)
133
167
  @ui_y = 0
134
168
  @footer_bar = FooterBar.new(@scale, @width, @height)
135
169
  reset_font_ui_y
@@ -149,10 +183,15 @@ class GameWindow < Gosu::Window
149
183
  @handicap = 1
150
184
  end
151
185
  @player = Player.new(@scale, @width / 2, @height / 2, @width, @height, {handicap: @handicap, max_movable_height: @height - @footer_bar.height})
152
-
186
+ @scroll_factor = 1
187
+ @movement_x = 0.0
188
+ @movement_y = 0.0
189
+ @can_toggle_scroll_factor = true
153
190
  @boss_active = false
154
191
  @boss = nil
155
192
  @boss_killed = false
193
+
194
+ @debug = true #is_debug?
156
195
  end
157
196
 
158
197
 
@@ -169,7 +208,8 @@ class GameWindow < Gosu::Window
169
208
  # KB_LEFT_CONTROL = 224,
170
209
  if id == Gosu::KB_LEFT_CONTROL && @player.ready_for_special?
171
210
  puts "Gosu::KB_LEFT_CONTROL CLICKED!!"
172
- @player.special_attack
211
+ # @projectiles += @player.special_attack([@enemies, @buildings, @enemy_destructable_projectiles, [@boss]])
212
+ @projectiles += @player.special_attack_2
173
213
  end
174
214
  end
175
215
 
@@ -179,10 +219,16 @@ class GameWindow < Gosu::Window
179
219
  window = GameWindow.new(window.width, window.height, window.fullscreen?, options.merge({block_controls_until_button_up: true})).show
180
220
  end
181
221
 
182
-
183
222
  def self.start width = nil, height = nil, fullscreen = false, options = {}
223
+ # begin
184
224
  # window = GameWindow.new.show
185
- GameWindow.new(width, height, fullscreen, options).show
225
+ GameWindow.new(width, height, fullscreen, options).show
226
+ # rescue Exception => e
227
+ # puts "Exception caught in GameWindow"
228
+ # puts e.message
229
+ # puts e.backtrace
230
+ # raise e
231
+ # end
186
232
  end
187
233
 
188
234
  # When fullscreen, try to match window with screen resolution
@@ -253,6 +299,9 @@ class GameWindow < Gosu::Window
253
299
  if (id == Gosu::KB_TAB)
254
300
  @can_toggle_secondary = true
255
301
  end
302
+ if (id == Gosu::KB_Q || id == Gosu::KB_E)
303
+ @can_toggle_scroll_factor = true
304
+ end
256
305
 
257
306
  if id == Gosu::KB_RETURN
258
307
  @can_toggle_fullscreen_a = true
@@ -266,11 +315,17 @@ class GameWindow < Gosu::Window
266
315
  if id == Gosu::KB_EQUALS
267
316
  @can_resize = true
268
317
  end
318
+ if id == Gosu::MS_LEFT
319
+ @player.deactivate_group_2
320
+ end
321
+ if id == Gosu::KB_SPACE
322
+ @player.deactivate_group_1
323
+ end
269
324
  end
270
325
 
271
326
  def get_center_font_ui_y
272
327
  return_value = @center_ui_y
273
- @center_ui_y += 50
328
+ @center_ui_y += 10 * @scale
274
329
  return return_value
275
330
  end
276
331
 
@@ -278,9 +333,13 @@ class GameWindow < Gosu::Window
278
333
  return @center_ui_x
279
334
  end
280
335
 
281
- def reset_center_font_ui_y
282
- @center_ui_y = @height / 2 - 100
283
- @center_ui_x = @width / 2 - 100
336
+ # def reset_center_font_ui_y
337
+ # @center_ui_y = @height / 2
338
+ # @center_ui_x = @width / 2
339
+ # end
340
+
341
+ def is_debug?
342
+ ENV['debug'] == 'true' || ENV['debug'] == true
284
343
  end
285
344
 
286
345
  def update
@@ -289,16 +348,69 @@ class GameWindow < Gosu::Window
289
348
  @start_fullscreen = false
290
349
  GameWindow.fullscreen(self)
291
350
  end
292
- reset_center_font_ui_y
351
+ # reset_center_font_ui_y
293
352
  @menu.update if @menu
294
353
  if !@block_all_controls
295
354
  if Gosu.button_down?(Gosu::KbEscape) && @can_open_menu
296
355
  @menu_open = true
297
356
  @can_open_menu = false
298
- @menu = Menu.new(self)
299
- @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/resume.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { @menu_open = false; @menu = nil; @can_open_menu = true; }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/resume.png", false))
300
- @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { self.close; Main.new.show }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false))
301
- @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/exit.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { self.close }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/exit.png", false))
357
+ # @menu = Menu.new(self)
358
+ @menu = Menu.new(self, @width / 2, 10 * @scale, ZOrder::UI, @scale)
359
+
360
+ button_key = :resume
361
+ @menu.add_item(
362
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Resume", 0, 1),
363
+ 0,
364
+ 0,
365
+ lambda {|window, id| @menu_open = false; @menu = nil; @can_open_menu = true; },
366
+ # { self.close; Main.new.show }, # lambda { self.close; Main.new.show },
367
+ nil, # Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false)
368
+ {is_button: true, key: button_key}
369
+ )
370
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/resume.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { @menu_open = false; @menu = nil; @can_open_menu = true; }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/resume.png", false))
371
+
372
+
373
+ # @loadout_button = LUIT::Button.new(self, :loadout, (@width / 2), get_center_font_ui_y, "Back To Menu", 0, 1)
374
+ # (object, x, y, z, callback, hover_image = nil, options = {})
375
+ button_key = :loadout
376
+ @menu.add_item(
377
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Inventory", 0, 1),
378
+ 0,
379
+ 0,
380
+ lambda {|window, id|
381
+ self.close
382
+ LoadoutWindow.new(nil,nil,nil,{game_window: @window}).show
383
+ },
384
+ # { self.close; Main.new.show }, # lambda { self.close; Main.new.show },
385
+ nil, # Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false)
386
+ {is_button: true, key: button_key}
387
+ )
388
+ button_key = :back_to_menu
389
+ @menu.add_item(
390
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Back To Menu", 0, 1),
391
+ 0,
392
+ 0,
393
+ lambda {|window, id| self.close; Main.new.show },
394
+ # lambda {|window, id| self.close; LoadoutWindow.new.show },
395
+ # { self.close; Main.new.show }, # lambda { self.close; Main.new.show },
396
+ nil, # Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false)
397
+ {is_button: true, key: button_key}
398
+ )
399
+
400
+ button_key = :exit
401
+ @menu.add_item(
402
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Exit", 0, 1),
403
+ 0,
404
+ 0,
405
+ lambda {|window, id| self.close; },
406
+ # lambda {|window, id| self.close; LoadoutWindow.new.show },
407
+ # { self.close; Main.new.show }, # lambda { self.close; Main.new.show },
408
+ nil, # Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false)
409
+ {is_button: true, key: button_key}
410
+ )
411
+
412
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { self.close; Main.new.show }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/back_to_menu.png", false))
413
+ # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/exit.png", false), get_center_font_ui_x, get_center_font_ui_y, ZOrder::UI, lambda { self.close }, Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/exit.png", false))
302
414
  # close!
303
415
  end
304
416
  if Gosu.button_down?(Gosu::KB_M)
@@ -337,12 +449,24 @@ class GameWindow < Gosu::Window
337
449
  @player.toggle_secondary
338
450
  end
339
451
 
452
+ if Gosu.button_down?(Gosu::KB_Q) && @can_toggle_scroll_factor
453
+ @can_toggle_scroll_factor = false
454
+ @scroll_factor = @player.rotate_counterclockwise
455
+ end
456
+
457
+ if Gosu.button_down?(Gosu::KB_E) && @can_toggle_scroll_factor
458
+ @can_toggle_scroll_factor = false
459
+ @scroll_factor = @player.rotate_clockwise
460
+ end
461
+
340
462
  if @player.is_alive && !@game_pause && !@menu_open
341
- @player.update()
342
- @player.move_left() if Gosu.button_down?(Gosu::KB_LEFT) || Gosu.button_down?(Gosu::GP_LEFT) || Gosu.button_down?(Gosu::KB_A)
343
- @player.move_right() if Gosu.button_down?(Gosu::KB_RIGHT) || Gosu.button_down?(Gosu::GP_RIGHT) || Gosu.button_down?(Gosu::KB_D)
344
- @player.accelerate() if Gosu.button_down?(Gosu::KB_UP) || Gosu.button_down?(Gosu::GP_UP) || Gosu.button_down?(Gosu::KB_W)
345
- @player.brake() if Gosu.button_down?(Gosu::KB_DOWN) || Gosu.button_down?(Gosu::GP_DOWN) || Gosu.button_down?(Gosu::KB_S)
463
+ @player.update(self.mouse_x, self.mouse_y, @player)
464
+ puts "FIRST: #{@movement_x} and #{@movement_y}"
465
+ @movement_x, @movement_y = @player.move_left(@movement_x, @movement_y) if Gosu.button_down?(Gosu::KB_LEFT) || Gosu.button_down?(Gosu::GP_LEFT) || Gosu.button_down?(Gosu::KB_A)
466
+ @movement_x, @movement_y = @player.move_right(@movement_x, @movement_y) if Gosu.button_down?(Gosu::KB_RIGHT) || Gosu.button_down?(Gosu::GP_RIGHT) || Gosu.button_down?(Gosu::KB_D)
467
+ puts "MOVEMENT HERE: #{@movement_x} and #{@movemeny_y}"if Gosu.button_down?(Gosu::KB_UP) || Gosu.button_down?(Gosu::GP_UP) || Gosu.button_down?(Gosu::KB_W)
468
+ @movement_x, @movement_y = @player.accelerate(@movement_x, @movement_y) if Gosu.button_down?(Gosu::KB_UP) || Gosu.button_down?(Gosu::GP_UP) || Gosu.button_down?(Gosu::KB_W)
469
+ @movement_x, @movement_y = @player.brake(@movement_x, @movement_y) if Gosu.button_down?(Gosu::KB_DOWN) || Gosu.button_down?(Gosu::GP_DOWN) || Gosu.button_down?(Gosu::KB_S)
346
470
 
347
471
  if Gosu.button_down?(Gosu::MS_RIGHT)
348
472
  if @grappling_hook == nil && @player.grapple_hook_cooldown_wait <= 0
@@ -352,20 +476,32 @@ class GameWindow < Gosu::Window
352
476
  end
353
477
 
354
478
  if Gosu.button_down?(Gosu::MS_LEFT)
355
- @projectiles = @projectiles + @player.trigger_secondary_attack(@pointer)
479
+ new_projectiles = @player.attack_group_2(@pointer)
480
+ # puts "NEW PROJECTILES: #{new_projectiles}" if @debug
481
+ if @debug
482
+ raise "BAD Projectile found: #{new_projectiles}" if new_projectiles.include?(nil)
483
+ end
484
+ @projectiles = @projectiles + new_projectiles
485
+ else
486
+ # @player.deactivate_group_2
356
487
  end
357
488
 
358
489
  if Gosu.button_down?(Gosu::KB_SPACE)
359
490
  if @player.cooldown_wait <= 0
360
- results = @player.attack(@pointer)
361
- projectiles = results[:projectiles]
362
- cooldown = results[:cooldown]
363
- @player.cooldown_wait = cooldown.to_f.fdiv(@player.attack_speed)
364
-
365
- projectiles.each do |projectile|
366
- @projectiles.push(projectile)
491
+ @player.attack_group_1(@pointer).each do |results|
492
+ # puts "NEW PROJECTILESv2: #{results}" if @debug
493
+ projectiles = results[:projectiles]
494
+ # cooldown = results[:cooldown]
495
+ # @player.cooldown_wait = cooldown.to_f.fdiv(@player.attack_speed)
496
+
497
+ projectiles.each do |projectile|
498
+ @projectiles.push(projectile)
499
+ end
367
500
  end
368
501
  end
502
+ else
503
+ # MOVE ELSEWHERE... KEY UP
504
+ # @player.deactivate_group_1
369
505
  end
370
506
 
371
507
 
@@ -398,23 +534,23 @@ class GameWindow < Gosu::Window
398
534
 
399
535
 
400
536
 
401
- @buildings.reject! { |building| !building.update() }
537
+ @buildings.reject! { |building| !building.update(nil, nil, nil, @scroll_factor) }
402
538
 
403
539
  if @player.is_alive && @grappling_hook
404
540
  grap_result = @grappling_hook.update(@player)
405
541
  @grappling_hook = nil if !grap_result
406
542
  end
407
543
 
408
- @pickups.reject! { |pickup| !pickup.update(self.mouse_x, self.mouse_y) }
544
+ @pickups.reject! { |pickup| !pickup.update(self.mouse_x, self.mouse_y, @player, @scroll_factor) }
409
545
 
410
- @projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y) }
546
+ @projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y, @player, @scroll_factor) }
411
547
 
412
- @enemy_projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y) }
413
- @enemy_destructable_projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y) }
414
- @enemies.reject! { |enemy| !enemy.update(nil, nil, @player) }
548
+ @enemy_projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y, @player, @scroll_factor) }
549
+ @enemy_destructable_projectiles.reject! { |projectile| !projectile.update(self.mouse_x, self.mouse_y, @player, @scroll_factor) }
550
+ @enemies.reject! { |enemy| !enemy.update(nil, nil, @player, @scroll_factor) }
415
551
 
416
552
  if @boss
417
- result = @boss.update(nil, nil, @player)
553
+ result = @boss.update(nil, nil, @player, @scroll_factor)
418
554
  if !result
419
555
  @boss_killed = true
420
556
  @boss = nil
@@ -424,7 +560,7 @@ class GameWindow < Gosu::Window
424
560
  end
425
561
 
426
562
 
427
- @gl_background.scroll
563
+ @movement_x, @movement_y = @gl_background.scroll(@scroll_factor, @movement_x, @movement_y)
428
564
 
429
565
 
430
566
  if !@boss_killed && !@boss_active
@@ -441,13 +577,13 @@ class GameWindow < Gosu::Window
441
577
  end
442
578
  if @player.is_alive && (@player.time_alive % 1300 == 0) # && @enemies.count <= @max_enemies
443
579
  # @enemies.push(EnemyPlayer.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
444
- swarm = HorizontalSwarm.trigger_swarm(@scale, @width, @height)
445
- @enemies = @enemies + swarm
580
+ # swarm = HorizontalSwarm.trigger_swarm(@scale, @width, @height)
581
+ # @enemies = @enemies + swarm
446
582
  end
447
583
 
448
584
  if @player.is_alive && rand(@enemies_random_spawn_timer) == 0 && @enemies.count <= @max_enemies
449
585
  (0..(@enemies_spawner_counter / 2).round).each do |count|
450
- @enemies.push(EnemyPlayer.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
586
+ # @enemies.push(EnemyPlayer.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
451
587
  end
452
588
  end
453
589
  if @player.time_alive % 500 == 0
@@ -459,7 +595,7 @@ class GameWindow < Gosu::Window
459
595
  # temp
460
596
  if @player.time_alive % 200 == 0
461
597
  (0..(@enemies_spawner_counter / 4).round).each do |count|
462
- @enemies.push(MissileBoat.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
598
+ # @enemies.push(MissileBoat.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
463
599
  end
464
600
  end
465
601
  if @player.time_alive % 5000 == 0
@@ -552,11 +688,12 @@ class GameWindow < Gosu::Window
552
688
  end # END UPDATE FUNCTION
553
689
 
554
690
  def draw
691
+ @open_gl_executer.draw(@gl_background, @projectiles + @enemy_projectiles + @enemy_destructable_projectiles, @player)
692
+ @pointer.draw# if @grappling_hook.nil? || !@grappling_hook.active
555
693
  @menu.draw if @menu
556
694
  @footer_bar.draw(@player)
557
695
  @boss.draw if @boss
558
696
  # @pointer.draw(self.mouse_x, self.mouse_y) if @grappling_hook.nil? || !@grappling_hook.active
559
- @pointer.draw# if @grappling_hook.nil? || !@grappling_hook.active
560
697
 
561
698
  @player.draw() if @player.is_alive
562
699
  @grappling_hook.draw(@player) if @player.is_alive && @grappling_hook
@@ -602,7 +739,7 @@ class GameWindow < Gosu::Window
602
739
  @font.draw("Attack Speed: #{@player.attack_speed.round(2)}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
603
740
  @font.draw("FPS: #{Gosu.fps}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
604
741
  end
605
- @gl_background.draw(ZOrder::Background)
742
+ # @gl_background.draw(ZOrder::Background)
606
743
  reset_font_ui_y
607
744
  end
608
745
 
@@ -1,10 +1,32 @@
1
- # irb -r ./irb_requirements.rb
1
+ # pry -r ./irb_requirements.rb
2
2
 
3
3
  require 'rubygems'
4
4
  require 'gosu'
5
- require 'gl'
5
+ require 'opengl'
6
+ require 'glu'
7
+ require 'glut'
8
+ # require 'ashton'
9
+ include OpenGL
10
+ include GLUT
11
+ # include GLU
12
+ # OpenGL.load_lib()
13
+ # GLUT.load_lib()
14
+ # Ashton::ParticleEmitter
15
+ # test = Ashton::ParticleEmitter.new(1, 1, 4)
16
+
6
17
  CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
18
+ MEDIA_DIRECTORY = File.expand_path('../', __FILE__) + "/media"
19
+ VENDOR_DIRECTORY = File.expand_path('../', __FILE__) + "/../vendors/"
20
+ CONFIG_FILE = "#{CURRENT_DIRECTORY}/../config.txt"
21
+
22
+ # include OpenGL
23
+ # include GLUT
24
+ # OpenGL.load_lib()
25
+ # GLUT.load_lib()
26
+
27
+ # CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
7
28
 
8
29
  Dir["#{CURRENT_DIRECTORY}/models/*.rb"].each { |f| require f }
9
30
  Dir["#{CURRENT_DIRECTORY}/lib/*.rb"].each { |f| require f }
31
+ Dir["#{VENDOR_DIRECTORY}/lib/*.rb"].each { |f| require f }
10
32
 
@@ -1,5 +1,5 @@
1
1
  require 'fileutils'
2
-
2
+ require 'json'
3
3
  module ConfigSetting
4
4
  def self.set_setting file_location, setting_name, setting_value
5
5
  # puts "HERE: #{file_location} and #{setting_name} and #{setting_value}"
@@ -34,7 +34,7 @@ module ConfigSetting
34
34
  end
35
35
  end
36
36
 
37
- def self.get_setting file_location, setting_name, default_value
37
+ def self.get_setting file_location, setting_name, default_value = nil
38
38
  create_file_if_non_existent(file_location)
39
39
  test = File.readlines(file_location).select { |line| line =~ /^#{setting_name}: ([^;]*);$/ }
40
40
  if test && test.first
@@ -46,22 +46,132 @@ module ConfigSetting
46
46
  end
47
47
  test = test.strip
48
48
  end
49
- # test = nil
50
- # if File.readlines(file_location).grep(/#{setting_name}:/).size > 0
51
- # test =
52
- # end
53
- # puts "GETTING TEST: #{test}"
54
- # puts "test2: #{test.inspect}"
55
- # puts "test2 - #{test.nil?}"
56
- # puts "test3 - #{test.inspect}"
57
- # if test.nil? #|| test.count == 0
58
- # # puts "TEST NIL HERE"
59
- # test = default_value
60
- # end
61
- if test == [] || test.nil? || test == ''
49
+ if (test == [] || test.nil? || test == '')
62
50
  test = default_value
63
51
  end
64
- return test.gsub(';', '')
52
+ return test ? test.gsub(';', '') : test
53
+ end
54
+
55
+ def self.set_mapped_setting file_location, setting_names, setting_value
56
+ puts "set_mapped_setting".upcase
57
+ puts setting_names
58
+ puts setting_value
59
+ create_file_if_non_existent(file_location)
60
+ if setting_names.any?
61
+ # File.open('xxx.txt').each do |line|
62
+ # print "#{line_num += 1} #{line}"
63
+ # end
64
+ setting_name = setting_names.shift
65
+ text = (File.readlines(file_location).select { |line| line =~ /^#{setting_name}: ([^;]*);$/ }).first
66
+ if text
67
+ puts "FOUND TEXT"
68
+ puts text
69
+ text = text.scan(/^#{setting_name}: ([^;]*);$/).first
70
+ text = text.first if text
71
+ data = ::JSON.parse(text)
72
+ indexing_values = data
73
+ # puts "FOUND IT"
74
+ # text = File.read(file_location)
75
+ # data = JSON.parse(text.sub(/;$/, '')).with_indifferent_access
76
+ # indexer = setting_names.shift
77
+ # while setting_names.any?
78
+ # data = data[indexer]
79
+ # indexer = setting_names.shift
80
+ # end
81
+ # puts 'GOT DATA HERE'
82
+ # puts data.inspect
83
+ # data[indexer] = setting_value
84
+
85
+ indexer = setting_names.shift
86
+ while indexer
87
+ puts "indexing_values: #{indexing_values}"
88
+ puts "INDEXER - #{indexer}"
89
+ if setting_names.count == 0
90
+ indexing_values[indexer] = setting_value
91
+ else
92
+ if indexing_values[indexer]
93
+ indexing_values = indexing_values[indexer]
94
+ else
95
+ indexing_values[indexer] = {}
96
+ indexing_values = indexing_values[indexer]
97
+ end
98
+ # indexing_values ||= {}
99
+ end
100
+ # puts data
101
+ indexer = setting_names.shift
102
+ indexer = indexer.to_s if indexer
103
+ end
104
+ puts 'PUTTING IN DATA: '
105
+ puts data
106
+ puts "SUBBING IN SETTING NAME: #{setting_name}"
107
+ puts "WITH"
108
+ puts "#{setting_name}: #{data.to_json};"
109
+ full_text = File.read(file_location)
110
+ File.open(file_location, 'w+'){|f| f << full_text.sub(/^#{setting_name}: ([^;]*);$/, "#{setting_name}: #{data.to_json};") }
111
+ return data
112
+
113
+ # File.open(file_location, 'w+'){|f| f << text.sub(/^#{setting_name}: ([^;]*);$/, "#{setting_name}: #{setting_value};") }
114
+ else
115
+ puts "DIDIT FIND IT- setting_name: #{setting_name}"
116
+ root_values = {}
117
+ values = root_values
118
+ indexer = setting_names.shift
119
+ while setting_names.any?
120
+ values[indexer] ||= {}
121
+ values = values[indexer]
122
+ indexer = setting_names.shift
123
+ indexer = indexer.to_s if indexer
124
+ end
125
+ values[indexer] = setting_value
126
+
127
+ # {"front_hardpoint_locations":{},"1":"launcher"}
128
+
129
+ File.open(file_location, 'a') do |f|
130
+ f << "\n#{setting_name}: #{root_values.to_json};"
131
+ end
132
+ end
133
+
134
+ # setting_name = setting_names.shift
135
+ # test = File.readlines(file_location).select { |line| line =~ /^#{setting_name}: ([^;]*);$/ }
136
+ # puts "TEST HERE"
137
+ # puts test.inspect
138
+ # data = JSON.parse(test)
139
+ # puts "DATA"
140
+ # puts data
141
+ # data = data.with_indifferent_access
142
+ # indexer = setting_names.shift
143
+ # while setting_names.any?
144
+ # data = data[indexer]
145
+ # indexer = setting_names.shift
146
+ # end
147
+ # puts "FOUND DATA: #{data}"
148
+ end
149
+ end
150
+
151
+ def self.get_mapped_setting file_location, setting_names = [], default_value = nil
152
+ create_file_if_non_existent(file_location)
153
+ setting_name = setting_names.shift
154
+ text = (File.readlines(file_location).select { |line| line =~ /^#{setting_name}: ([^;]*);$/ }).first
155
+ puts "TEST HERE"
156
+ puts text.inspect
157
+ if text
158
+ text = text.scan(/^#{setting_name}: ([^;]*);$/).first
159
+ text = text.first if text
160
+ data = ::JSON.parse(text)
161
+ # data = data.with_indifferent_access
162
+ indexer = setting_names.shift
163
+ while indexer && data
164
+ puts "DATA index"
165
+ data = data[indexer]
166
+ puts data
167
+ indexer = setting_names.shift
168
+ indexer = indexer.to_s if indexer
169
+ end
170
+ puts "FOUND DATA: #{data}"
171
+ return data
172
+ else
173
+ return default_value
174
+ end
65
175
  end
66
176
 
67
177
  def self.create_file_if_non_existent file_location