line-em-up 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/line-em-up/game_window.rb +180 -47
  3. data/line-em-up/lib/config_setting.rb +60 -0
  4. data/line-em-up/lib/resolution_setting.rb +82 -0
  5. data/line-em-up/lib/setting.rb +4 -0
  6. data/line-em-up/media/airship1_color1.png +0 -0
  7. data/line-em-up/media/airship1_color1_reverse.png +0 -0
  8. data/line-em-up/media/bomb_original copy.png +0 -0
  9. data/line-em-up/media/bomb_pack_hud.png +0 -0
  10. data/line-em-up/media/debug_start.png +0 -0
  11. data/line-em-up/media/grappling_hook.png +0 -0
  12. data/line-em-up/media/green_health_bar_0.png +0 -0
  13. data/line-em-up/media/green_health_bar_1.png +0 -0
  14. data/line-em-up/media/green_health_bar_2.png +0 -0
  15. data/line-em-up/media/green_health_bar_3.png +0 -0
  16. data/line-em-up/media/green_health_bar_4.png +0 -0
  17. data/line-em-up/media/green_health_bar_5.png +0 -0
  18. data/line-em-up/media/green_health_bar_6.png +0 -0
  19. data/line-em-up/media/green_health_bar_7.png +0 -0
  20. data/line-em-up/media/green_health_bar_8.png +0 -0
  21. data/line-em-up/media/green_health_bar_9.png +0 -0
  22. data/line-em-up/media/health_bar_0.png +0 -0
  23. data/line-em-up/media/health_bar_1.png +0 -0
  24. data/line-em-up/media/health_bar_10.png +0 -0
  25. data/line-em-up/media/health_bar_2.png +0 -0
  26. data/line-em-up/media/health_bar_3.png +0 -0
  27. data/line-em-up/media/health_bar_4.png +0 -0
  28. data/line-em-up/media/health_bar_5.png +0 -0
  29. data/line-em-up/media/health_bar_6.png +0 -0
  30. data/line-em-up/media/health_bar_7.png +0 -0
  31. data/line-em-up/media/health_bar_8.png +0 -0
  32. data/line-em-up/media/health_bar_9.png +0 -0
  33. data/line-em-up/media/mini_missile_reverse.png +0 -0
  34. data/line-em-up/media/missile_boat.png +0 -0
  35. data/line-em-up/media/missile_boat_original.png +0 -0
  36. data/line-em-up/media/missile_boat_reverse.png +0 -0
  37. data/line-em-up/media/missile_pack_hud.png +0 -0
  38. data/line-em-up/media/missile_reverse.png +0 -0
  39. data/line-em-up/media/mothership.png +0 -0
  40. data/line-em-up/media/mothership_original.png +0 -0
  41. data/line-em-up/media/single_star.png +0 -0
  42. data/line-em-up/media/spaceship.png +0 -0
  43. data/line-em-up/media/spaceship_left-test.png +0 -0
  44. data/line-em-up/media/spaceship_left.png +0 -0
  45. data/line-em-up/media/spaceship_right.png +0 -0
  46. metadata +43 -3
  47. data/line-em-up/media/header@2x.psd +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 334ea09facdd29bc7a5f0e30da6f9e8eb364b544
4
- data.tar.gz: 5abd1abfb1b61f25be55c4613df85674d7229d19
3
+ metadata.gz: 3bd75a1c68de409e5b0e14a35334201f8187b71e
4
+ data.tar.gz: 67195a13f775a2269af0e02048b13e1c1fdbf109
5
5
  SHA512:
6
- metadata.gz: afc27313a8205af621510de30dbce563d9ba7c3c9467792c9fc80c422c73974bc3fc6d9db58f8c5477f47eb8c3e999c7792be389a098b289c14f219a951d3611
7
- data.tar.gz: dd0e11b67f3ec156d8f974df8c93bdf835bdf44aa40d76852a7ad55f290dfb095cf04b38a6327f9d8390b7460273ca1abaa32c43cd1fcd7ede0f6a00e30a30b5
6
+ metadata.gz: 43e4cacd011d38d2ea9a7ffff79710a10a121aac65b97f59b9f7def75ac33baaf5ffda8450c1bf4af69d1882d8d7df559512ada935928a40de07ec69386c3a91
7
+ data.tar.gz: 68095527adc6d54439afc6e0aeb2dedb5e4cf137b9c9cbb0d46742be9839f75a0d45b469c31336c519fa9c69030c2cd7d8ecbd443a1c03e788b36ba52f973e71
@@ -78,14 +78,14 @@ class GameWindow < Gosu::Window
78
78
  end
79
79
  end
80
80
 
81
- def self.reset(window)
82
- window = GameWindow.new.show
81
+ def self.reset(window, options = {})
82
+ window = GameWindow.new(window.width, window.height, window.fullscreen?, {block_controls_until_button_up: true, debug: options[:debug]}).show
83
83
  end
84
84
 
85
85
 
86
- def self.start width = nil, height = nil, options = {}
86
+ def self.start width = nil, height = nil, fullscreen = false, options = {}
87
87
  # window = GameWindow.new.show
88
- GameWindow.new(width, height, options).show
88
+ GameWindow.new(width, height, fullscreen, options).show
89
89
  end
90
90
 
91
91
  # When fullscreen, try to match window with screen resolution
@@ -143,9 +143,11 @@ class GameWindow < Gosu::Window
143
143
  end
144
144
  end
145
145
 
146
- def initialize width = nil, height = nil, options = {}
146
+ def initialize width = nil, height = nil, fullscreen = false, options = {}
147
147
  @block_all_controls = !options[:block_controls_until_button_up].nil? && options[:block_controls_until_button_up] == true ? true : false
148
-
148
+ @debug = options[:debug]
149
+ # GameWindow.fullscreen(self) if fullscreen
150
+ @start_fullscreen = fullscreen
149
151
  @center_ui_y = 0
150
152
  @center_ui_x = 0
151
153
 
@@ -186,25 +188,40 @@ class GameWindow < Gosu::Window
186
188
  @buildings = Array.new
187
189
  @projectiles = Array.new
188
190
  @enemy_projectiles = Array.new
191
+ @enemy_destructable_projectiles = Array.new
189
192
  @pickups = Array.new
190
193
 
191
194
  @enemies = Array.new
192
195
  @enemies_random_spawn_timer = 100
196
+ # @enemies_random_spawn_timer = 5
193
197
  @enemies_spawner_counter = 0
198
+ # @enemies_spawner_counter = 5
199
+
200
+ @max_enemy_count = 30
201
+ @enemies_killed = 0
194
202
 
195
203
  @font = Gosu::Font.new(20)
196
204
  @max_enemies = 4
197
205
 
198
206
  @pointer = Cursor.new(@scale)
199
207
  @ui_y = 0
208
+ @footer_bar = FooterBar.new(@scale, @width, @height)
200
209
  reset_font_ui_y
210
+
211
+ # @boss_active_at_enemies_killed = 500
212
+ @boss_active_at_enemies_killed = 750
213
+ @boss_active_at_level = 4
214
+ @boss_active = false
215
+ @boss = nil
216
+ @boss_killed = false
201
217
  end
202
218
 
203
219
  def button_up id
204
220
  @block_all_controls = false
205
- if (id == Gosu::MS_RIGHT) && @player.is_alive
206
- @grappling_hook.deactivate if @grappling_hook
207
- end
221
+ # Grappling hook always active
222
+ # if (id == Gosu::MS_RIGHT) && @player.is_alive
223
+ # @grappling_hook.deactivate if @grappling_hook
224
+ # end
208
225
 
209
226
  if (id == Gosu::KB_P)
210
227
  @can_pause = true
@@ -243,6 +260,10 @@ class GameWindow < Gosu::Window
243
260
  end
244
261
 
245
262
  def update
263
+ if @start_fullscreen
264
+ @start_fullscreen = false
265
+ GameWindow.fullscreen(self)
266
+ end
246
267
  reset_center_font_ui_y
247
268
  @menu.update if @menu
248
269
  if !@block_all_controls
@@ -255,7 +276,7 @@ class GameWindow < Gosu::Window
255
276
  # close!
256
277
  end
257
278
  if Gosu.button_down?(Gosu::KB_M)
258
- GameWindow.reset(self)
279
+ GameWindow.reset(self, {debug: @debug})
259
280
  end
260
281
 
261
282
  if Gosu.button_down?(Gosu::KB_RIGHT_META) && Gosu.button_down?(Gosu::KB_RETURN) && @can_toggle_fullscreen_a && @can_toggle_fullscreen_b
@@ -298,8 +319,8 @@ class GameWindow < Gosu::Window
298
319
  @player.brake(@height) if Gosu.button_down?(Gosu::KB_DOWN) || Gosu.button_down?(Gosu::GP_DOWN) || Gosu.button_down?(Gosu::KB_S)
299
320
 
300
321
  if Gosu.button_down?(Gosu::MS_RIGHT)
301
- if @grappling_hook == nil
302
- @grappling_hook = GrapplingHook.new(@scale, @player)
322
+ if @grappling_hook == nil && @player.grapple_hook_cooldown_wait <= 0
323
+ @grappling_hook = GrapplingHook.new(@scale, @player, self.mouse_x, self.mouse_y)
303
324
  end
304
325
  end
305
326
 
@@ -326,6 +347,9 @@ class GameWindow < Gosu::Window
326
347
  @enemy_projectiles.each do |projectile|
327
348
  projectile.hit_object(@player)
328
349
  end
350
+ @enemy_destructable_projectiles.each do |projectile|
351
+ projectile.hit_object(@player)
352
+ end
329
353
 
330
354
 
331
355
  @grappling_hook.collect_pickups(@player, @pickups) if @grappling_hook && @grappling_hook.active
@@ -334,9 +358,11 @@ class GameWindow < Gosu::Window
334
358
  if !@game_pause && !@menu_open
335
359
 
336
360
  @projectiles.each do |projectile|
337
- results = projectile.hit_objects([@enemies, @buildings])
361
+ results = projectile.hit_objects([@enemies, @buildings, @enemy_destructable_projectiles, [@boss]])
362
+
338
363
  @pickups = @pickups + results[:drops]
339
364
  @player.score += results[:point_value]
365
+ @enemies_killed += results[:killed]
340
366
  end
341
367
 
342
368
 
@@ -345,7 +371,7 @@ class GameWindow < Gosu::Window
345
371
  @buildings.reject! { |building| !building.update(@width, @height) }
346
372
 
347
373
  if @player.is_alive && @grappling_hook
348
- grap_result = @grappling_hook.update(@width, @height, self.mouse_x, self.mouse_y, @player)
374
+ grap_result = @grappling_hook.update(@width, @height, @player)
349
375
  @grappling_hook = nil if !grap_result
350
376
  end
351
377
 
@@ -354,79 +380,186 @@ class GameWindow < Gosu::Window
354
380
  @projectiles.reject! { |projectile| !projectile.update(@width, @height, self.mouse_x, self.mouse_y) }
355
381
 
356
382
  @enemy_projectiles.reject! { |projectile| !projectile.update(@width, @height, self.mouse_x, self.mouse_y) }
383
+ @enemy_destructable_projectiles.reject! { |projectile| !projectile.update(@width, @height, self.mouse_x, self.mouse_y) }
357
384
  @enemies.reject! { |enemy| !enemy.update(@width, @height, nil, nil, @player) }
358
385
 
386
+ if @boss
387
+ result = @boss.update(@width, @height, nil, nil, @player)
388
+ if !result
389
+ @boss_killed = true
390
+ @boss = nil
391
+ @enemy_projectiles = []
392
+ @enemy_destructable_projectiles = []
393
+ end
394
+ end
395
+
359
396
 
360
397
  @gl_background.scroll
361
398
 
362
- @buildings.push(Building.new(@scale)) if rand(100) == 0
363
399
 
400
+ if !@boss_killed && !@boss_active
401
+ @buildings.push(Building.new(@scale)) if rand(100) == 0
402
+ end
403
+
404
+ # Temp
405
+ # @enemies.push(MissileBoat.new(@scale, @width, @height)) if rand(10) == 0
406
+ if !@boss_active && !@boss && !@boss_killed
364
407
 
365
- if @player.is_alive && rand(@enemies_random_spawn_timer) == 0 && @enemies.count <= @max_enemies
366
- (0..@enemies_spawner_counter).each do |count|
367
- @enemies.push(EnemyPlayer.new(@scale, @width, @height))
408
+ if @player.is_alive && rand(@enemies_random_spawn_timer) == 0 && @enemies.count <= @max_enemies
409
+ (0..(@enemies_spawner_counter / 2).round).each do |count|
410
+ @enemies.push(EnemyPlayer.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
411
+ end
412
+ end
413
+ if @player.time_alive % 500 == 0
414
+ @max_enemies += 1
415
+ end
416
+ if @player.time_alive % 1000 == 0 && @enemies_random_spawn_timer > 5
417
+ @enemies_random_spawn_timer -= 5
418
+ end
419
+ # temp
420
+ if @player.time_alive % 200 == 0
421
+ (0..(@enemies_spawner_counter / 4).round).each do |count|
422
+ @enemies.push(MissileBoat.new(@scale, @width, @height)) if @enemies.count <= @max_enemy_count
423
+ end
424
+ end
425
+ if @player.time_alive % 5000 == 0
426
+ @enemies_spawner_counter += 1
427
+ end
428
+
429
+ if @player.time_alive % 1000 == 0 && @player.time_alive > 0
430
+ @player.score += 100
368
431
  end
369
432
  end
370
- if @player.time_alive % 500 == 0
371
- @max_enemies += 1
372
- end
373
- if @player.time_alive % 1000 == 0 && @enemies_random_spawn_timer > 5
374
- @enemies_random_spawn_timer -= 5
375
- end
376
- if @player.time_alive % 5000 == 0
377
- @enemies_spawner_counter += 1
433
+ if @boss_active_at_enemies_killed <= @enemies_killed || @boss_active_at_level <= @enemies_spawner_counter
434
+ # puts "HEREaagL #{@boss_active_at_enemies_killed} amd #{@enemies_killed} and #{@boss_active_at_level} and #{ @enemies_spawner_counter}"
435
+ @boss_active = true
378
436
  end
379
437
 
380
- if @player.time_alive % 1000 == 0 && @player.time_alive > 0
381
- @player.score += 100
438
+ if @boss_active && @boss.nil? && @enemies.count == 0 && @boss_killed == false
439
+ @boss_active = false
440
+ # Activate Boss
441
+ @boss = Mothership.new(@scale, @width, @height)
442
+ # @enemies.push(@boss)
382
443
  end
383
444
 
384
-
385
445
  # Move to enemy mehtods
386
446
  @enemies.each do |enemy|
387
- enemy.cooldown_wait -= 1 if enemy.cooldown_wait > 0
388
447
  if enemy.cooldown_wait <= 0
389
- results = enemy.attack(@width, @height)
448
+ results = enemy.attack(@width, @height, @player)
449
+
390
450
  projectiles = results[:projectiles]
391
451
  cooldown = results[:cooldown]
392
452
  enemy.cooldown_wait = cooldown.to_f.fdiv(enemy.attack_speed)
393
453
 
394
454
  projectiles.each do |projectile|
395
- @enemy_projectiles.push(projectile)
455
+ if projectile.destructable?
456
+ @enemy_destructable_projectiles.push(projectile)
457
+ else
458
+ @enemy_projectiles.push(projectile)
459
+ end
396
460
  end
397
461
  end
398
462
  end
463
+
464
+ if @boss
465
+ if @boss.cooldown_wait <= 0
466
+ results = @boss.attack(@width, @height, @player)
467
+ projectiles = results[:projectiles]
468
+ cooldown = results[:cooldown]
469
+ @boss.cooldown_wait = cooldown.to_f.fdiv(@boss.attack_speed)
470
+ projectiles.each do |projectile|
471
+ if projectile.destructable?
472
+ @enemy_destructable_projectiles.push(projectile)
473
+ else
474
+ @enemy_projectiles.push(projectile)
475
+ end
476
+ end
477
+ end
478
+ if @boss.secondary_cooldown_wait <= 0
479
+ results = @boss.secondary_attack(@width, @height, @player)
480
+
481
+ projectiles = results[:projectiles]
482
+ cooldown = results[:cooldown]
483
+ @boss.secondary_cooldown_wait = cooldown.to_f.fdiv(@boss.attack_speed)
484
+ projectiles.each do |projectile|
485
+ if projectile.destructable?
486
+ @enemy_destructable_projectiles.push(projectile)
487
+ else
488
+ @enemy_projectiles.push(projectile)
489
+ end
490
+ end
491
+ end
492
+
493
+ if @boss.tertiary_cooldown_wait <= 0
494
+ results = @boss.tertiary_attack(@width, @height, @player)
495
+
496
+ projectiles = results[:projectiles]
497
+ cooldown = results[:cooldown]
498
+ @boss.tertiary_cooldown_wait = cooldown.to_f.fdiv(@boss.attack_speed)
499
+ projectiles.each do |projectile|
500
+ if projectile.destructable?
501
+ @enemy_destructable_projectiles.push(projectile)
502
+ else
503
+ @enemy_projectiles.push(projectile)
504
+ end
505
+ end
506
+ end
507
+
508
+ end
509
+
510
+
399
511
  end
400
- end
401
- end
512
+ end # END if !@block_all_controls
513
+ end # END UPDATE FUNCTION
402
514
 
403
515
  def draw
404
516
  @menu.draw if @menu
405
- @pointer.draw(self.mouse_x, self.mouse_y) if @grappling_hook.nil? || !@grappling_hook.active
517
+ @footer_bar.draw(@player)
518
+ @boss.draw if @boss
519
+ # @pointer.draw(self.mouse_x, self.mouse_y) if @grappling_hook.nil? || !@grappling_hook.active
520
+ @pointer.draw(self.mouse_x, self.mouse_y)# if @grappling_hook.nil? || !@grappling_hook.active
406
521
 
407
522
  @player.draw() if @player.is_alive
408
523
  @grappling_hook.draw(@player) if @player.is_alive && @grappling_hook
409
- @font.draw("You are dead!", @width / 2 - 50, @height / 2 - 55, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
410
- @font.draw("Press ESC to quit", @width / 2 - 50, @height / 2 - 40, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
411
- @font.draw("Press M to Restart", @width / 2 - 50, @height / 2 - 25, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if !@player.is_alive
524
+ if !@menu && !@player.is_alive
525
+ @font.draw("You are dead!", @width / 2 - 50, @height / 2 - 55, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
526
+ @font.draw("Press ESC to quit", @width / 2 - 50, @height / 2 - 40, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
527
+ @font.draw("Press M to Restart", @width / 2 - 50, @height / 2 - 25, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
528
+ end
529
+ if @boss_killed
530
+ @font.draw("You won! Your score: #{@player.score}", @width / 2 - 50, @height / 2 - 55, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
531
+ end
412
532
  @font.draw("Paused", @width / 2 - 50, @height / 2 - 25, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @game_pause
413
533
  @enemies.each { |enemy| enemy.draw() }
414
534
  @projectiles.each { |projectile| projectile.draw() }
415
535
  @enemy_projectiles.each { |projectile| projectile.draw() }
536
+ @enemy_destructable_projectiles.each { |projectile| projectile.draw() }
416
537
  # @stars.each { |star| star.draw }
417
538
  @pickups.each { |pickup| pickup.draw() }
418
539
  @buildings.each { |building| building.draw() }
419
540
  @font.draw("Score: #{@player.score}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
420
- # @font.draw("Attack Speed: #{@player.attack_speed.round(2)}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
421
- @font.draw("Health: #{@player.health}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
422
- @font.draw("Armor: #{@player.armor}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
423
- # @font.draw("Rockets: #{@player.rockets}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'missile'
424
- # @font.draw("Bombs: #{@player.bombs}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'bomb'
425
- @font.draw("Weapon: #{@player.get_secondary_name}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
426
- @font.draw("Rockets: #{@player.rockets}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
427
- @font.draw("Bombs: #{@player.bombs}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.bombs > 0
428
- @font.draw("Time Alive: #{@player.time_alive}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
429
541
  @font.draw("Level: #{@enemies_spawner_counter + 1}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
542
+ @font.draw("Enemies Killed: #{@enemies_killed}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
543
+ @font.draw("Boss Health: #{@boss.health}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @boss
544
+ if @debug
545
+ # @font.draw("Attack Speed: #{@player.attack_speed.round(2)}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
546
+ @font.draw("Health: #{@player.health}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
547
+ @font.draw("Armor: #{@player.armor}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
548
+ # @font.draw("Rockets: #{@player.rockets}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'missile'
549
+ # @font.draw("Bombs: #{@player.bombs}", 10, 70, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.secondary_weapon == 'bomb'
550
+ @font.draw("Weapon: #{@player.get_secondary_name}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
551
+ @font.draw("Rockets: #{@player.rockets}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
552
+ @font.draw("Bombs: #{@player.bombs}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00) if @player.bombs > 0
553
+ @font.draw("Time Alive: #{@player.time_alive}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
554
+ @font.draw("Enemy count: #{@enemies.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
555
+ @font.draw("enemy_projectiles: #{@enemy_projectiles.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
556
+ @font.draw("projectiles count: #{@projectiles.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
557
+ @font.draw("destructable_proj: #{@enemy_destructable_projectiles.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
558
+ @font.draw("pickups count: #{@pickups.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
559
+ @font.draw("buildings count: #{@buildings.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
560
+ @font.draw("Object count: #{@enemies.count + @enemy_projectiles.count + @projectiles.count + @enemy_destructable_projectiles.count + @pickups.count + @buildings.count}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
561
+ @font.draw("FPS: #{Gosu.fps}", 10, get_font_ui_y, ZOrder::UI, 1.0, 1.0, 0xff_ffff00)
562
+ end
430
563
  @gl_background.draw(ZOrder::Background)
431
564
  reset_font_ui_y
432
565
  end
@@ -0,0 +1,60 @@
1
+ require 'fileutils'
2
+
3
+ module ConfigSetting
4
+ def self.set_setting file_location, setting_name, setting_value
5
+ # puts "HERE: #{file_location} and #{setting_name} and #{setting_value}"
6
+ create_file_if_non_existent(file_location)
7
+ if setting_value
8
+ if File.readlines(file_location).grep(/#{setting_name}:/).size > 0
9
+ # puts "FOUND SETTING"
10
+ text = File.read(file_location)
11
+ # puts "FOUDN IN FILE: #{text.inspect}"
12
+ replace = text.gsub(/^#{setting_name}: ([^$]*)$/, setting_value)
13
+ # replace = replace.gsub(/bbb/, "Replace bbb with 222")
14
+ File.open(file_location, "w") {|file| file.puts "#{setting_name}: #{replace}"}
15
+ else
16
+ # puts "COULDNT FIND SETTING"
17
+ File.open(file_location, 'a') do |f|
18
+ f << "#{setting_name}: #{setting_value}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ def self.get_setting file_location, setting_name, default_value
25
+ create_file_if_non_existent(file_location)
26
+ test = File.readlines(file_location).select { |line| line =~ /^#{setting_name}: ([^$]*)$/ }
27
+ if test && test.first
28
+ # puts "BEFORE SCAN: #{test}"
29
+ # So many firstsss
30
+ test = test.first.scan(/^#{setting_name}: ([^$]*)$/).first
31
+ if test
32
+ test = test.first
33
+ end
34
+ test = test.strip
35
+ end
36
+ # test = nil
37
+ # if File.readlines(file_location).grep(/#{setting_name}:/).size > 0
38
+ # test =
39
+ # end
40
+ # puts "GETTING TEST: #{test}"
41
+ # puts "test2: #{test.inspect}"
42
+ # puts "test2 - #{test.nil?}"
43
+ # puts "test3 - #{test.inspect}"
44
+ # if test.nil? #|| test.count == 0
45
+ # # puts "TEST NIL HERE"
46
+ # test = default_value
47
+ # end
48
+ if test == [] || test.nil? || test == ''
49
+ test = default_value
50
+ end
51
+ return test
52
+ end
53
+
54
+ def self.create_file_if_non_existent file_location
55
+ # puts "CREATING FILE AT LOCATION: #{file_location}"
56
+ if !File.exists?(file_location)
57
+ FileUtils.touch(file_location)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,82 @@
1
+ require_relative 'setting.rb'
2
+ # require_relative "config_settings.rb"
3
+
4
+ class ResolutionSetting < Setting
5
+ FULLSCREEN_NAME = "fullscreen"
6
+ RESOLUTIONS = ["640x480", "800x600", "960x720", "1024x768", "1280x960", "1400x1050", "1440x1080", "1600x1200", "1856x1392", "1920x1440", "2048x1536", FULLSCREEN_NAME]
7
+ attr_accessor :x, :y, :font, :max_width, :max_height
8
+
9
+
10
+ def initialize fullscreen_height, max_width, max_height, height, config_file_path
11
+ # puts "INNITING #{config_file_path}"
12
+ @font = Gosu::Font.new(20)
13
+ # @x = width
14
+ @y = height
15
+ @max_width = max_width
16
+ @max_height = max_height
17
+ @next_x = 15
18
+ @prev_x = @max_width - 15 - @font.text_width('>')
19
+ @config_file_path = config_file_path
20
+ @name = 'resolution'
21
+ @value = ConfigSetting.get_setting(@config_file_path, @name, RESOLUTIONS[0])
22
+ @fullscreen = false
23
+ @fullscreen_height = fullscreen_height
24
+ end
25
+
26
+ def get_resolution
27
+ if @value == FULLSCREEN_NAME
28
+ height = @fullscreen_height
29
+ width = (@fullscreen_height / 3) * 4
30
+ [width, height, true]
31
+ elsif @value
32
+ @value.split('x').collect{|s| s.to_i }
33
+ end
34
+ end
35
+
36
+ def draw
37
+ @font.draw("<", @next_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
38
+ @font.draw(@value, ((@max_width / 2) - @font.text_width(@value) / 2), @y, 1, 1.0, 1.0, 0xff_ffff00)
39
+ @font.draw(">", @prev_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
40
+ end
41
+
42
+ def update mouse_x, mouse_y
43
+ end
44
+
45
+ def clicked mx, my
46
+ if is_mouse_hovering_next(mx, my)
47
+ index = RESOLUTIONS.index(@value)
48
+ value = @value
49
+ if index == 0
50
+ value = RESOLUTIONS[RESOLUTIONS.count - 1]
51
+ else
52
+ value = RESOLUTIONS[index - 1]
53
+ end
54
+ ConfigSetting.set_setting(@config_file_path, @name, value)
55
+ @value = value
56
+ elsif is_mouse_hovering_prev(mx, my)
57
+ index = RESOLUTIONS.index(@value)
58
+ value = @value
59
+ if index == RESOLUTIONS.count - 1
60
+ value = RESOLUTIONS[0]
61
+ else
62
+ value = RESOLUTIONS[index + 1]
63
+ end
64
+ ConfigSetting.set_setting(@config_file_path, @name, value)
65
+ @value = value
66
+ end
67
+ end
68
+ def is_mouse_hovering_next mx, my
69
+ local_width = @font.text_width('>')
70
+ local_height = @font.height
71
+
72
+ (mx >= @next_x and my >= @y) and (mx <= @next_x + local_width) and (my <= @y + local_height)
73
+ end
74
+ def is_mouse_hovering_prev mx, my
75
+ local_width = @font.text_width('<')
76
+ local_height = @font.height
77
+
78
+ (mx >= @prev_x and my >= @y) and (mx <= @prev_x + local_width) and (my <= @y + local_height)
79
+ end
80
+
81
+
82
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "config_setting.rb"
2
+
3
+ class Setting
4
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-em-up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Dana
@@ -62,6 +62,9 @@ files:
62
62
  - bin/line-em-up.sh
63
63
  - line-em-up/game_window.rb
64
64
  - line-em-up/irb_requirements.rb
65
+ - line-em-up/lib/config_setting.rb
66
+ - line-em-up/lib/resolution_setting.rb
67
+ - line-em-up/lib/setting.rb
65
68
  - line-em-up/lib/z_order.rb
66
69
  - line-em-up/media/BrokenPNG.png
67
70
  - line-em-up/media/Cursor.png
@@ -75,6 +78,8 @@ files:
75
78
  - line-em-up/media/WhiteAlpha.png
76
79
  - line-em-up/media/additem.png
77
80
  - line-em-up/media/additem_hover.png
81
+ - line-em-up/media/airship1_color1.png
82
+ - line-em-up/media/airship1_color1_reverse.png
78
83
  - line-em-up/media/audio_formats/aiff_32bit_float.aiff
79
84
  - line-em-up/media/audio_formats/au_16bit_pcm.au
80
85
  - line-em-up/media/audio_formats/caf_be_16bit_44khz.caf
@@ -91,8 +96,10 @@ files:
91
96
  - line-em-up/media/back.png
92
97
  - line-em-up/media/beep.wav
93
98
  - line-em-up/media/bomb.png
99
+ - line-em-up/media/bomb_original copy.png
94
100
  - line-em-up/media/bomb_original.png
95
101
  - line-em-up/media/bomb_pack.png
102
+ - line-em-up/media/bomb_pack_hud.png
96
103
  - line-em-up/media/building.png
97
104
  - line-em-up/media/building_original.png
98
105
  - line-em-up/media/bullet-mini-reverse.png
@@ -104,6 +111,7 @@ files:
104
111
  - line-em-up/media/cptn_ruby_map.txt
105
112
  - line-em-up/media/crosshair.png
106
113
  - line-em-up/media/cursor 2.png
114
+ - line-em-up/media/debug_start.png
107
115
  - line-em-up/media/earth.png
108
116
  - line-em-up/media/exit.png
109
117
  - line-em-up/media/exit_hover.png
@@ -111,7 +119,27 @@ files:
111
119
  - line-em-up/media/gem.png
112
120
  - line-em-up/media/grappling_hook.png
113
121
  - line-em-up/media/grappling_hook_original.png
114
- - line-em-up/media/header@2x.psd
122
+ - line-em-up/media/green_health_bar_0.png
123
+ - line-em-up/media/green_health_bar_1.png
124
+ - line-em-up/media/green_health_bar_2.png
125
+ - line-em-up/media/green_health_bar_3.png
126
+ - line-em-up/media/green_health_bar_4.png
127
+ - line-em-up/media/green_health_bar_5.png
128
+ - line-em-up/media/green_health_bar_6.png
129
+ - line-em-up/media/green_health_bar_7.png
130
+ - line-em-up/media/green_health_bar_8.png
131
+ - line-em-up/media/green_health_bar_9.png
132
+ - line-em-up/media/health_bar_0.png
133
+ - line-em-up/media/health_bar_1.png
134
+ - line-em-up/media/health_bar_10.png
135
+ - line-em-up/media/health_bar_2.png
136
+ - line-em-up/media/health_bar_3.png
137
+ - line-em-up/media/health_bar_4.png
138
+ - line-em-up/media/health_bar_5.png
139
+ - line-em-up/media/health_bar_6.png
140
+ - line-em-up/media/health_bar_7.png
141
+ - line-em-up/media/health_bar_8.png
142
+ - line-em-up/media/health_bar_9.png
115
143
  - line-em-up/media/health_original.png
116
144
  - line-em-up/media/health_pack_0.png
117
145
  - line-em-up/media/health_pack_1.png
@@ -132,18 +160,30 @@ files:
132
160
  - line-em-up/media/item_hover.png
133
161
  - line-em-up/media/landscape.svg
134
162
  - line-em-up/media/large_star.png
163
+ - line-em-up/media/mini_missile_reverse.png
135
164
  - line-em-up/media/missile.png
165
+ - line-em-up/media/missile_boat.png
166
+ - line-em-up/media/missile_boat_original.png
167
+ - line-em-up/media/missile_boat_reverse.png
136
168
  - line-em-up/media/missile_original.png
137
169
  - line-em-up/media/missile_pack.png
170
+ - line-em-up/media/missile_pack_hud.png
138
171
  - line-em-up/media/missile_pack_original.png
172
+ - line-em-up/media/missile_reverse.png
173
+ - line-em-up/media/mothership.png
174
+ - line-em-up/media/mothership_original.png
139
175
  - line-em-up/media/question.png
140
176
  - line-em-up/media/question_original.png
141
177
  - line-em-up/media/resume.png
178
+ - line-em-up/media/single_star.png
142
179
  - line-em-up/media/smoke.png
143
180
  - line-em-up/media/soldier.png
144
181
  - line-em-up/media/space.png
145
182
  - line-em-up/media/spaceship.png
183
+ - line-em-up/media/spaceship_left-test.png
184
+ - line-em-up/media/spaceship_left.png
146
185
  - line-em-up/media/spaceship_original.png
186
+ - line-em-up/media/spaceship_right.png
147
187
  - line-em-up/media/star.png
148
188
  - line-em-up/media/starfighter.bmp
149
189
  - line-em-up/media/starfighterv2.bmp
@@ -171,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
211
  version: '0'
172
212
  requirements: []
173
213
  rubyforge_project:
174
- rubygems_version: 2.4.8
214
+ rubygems_version: 2.6.14.1
175
215
  signing_key:
176
216
  specification_version: 4
177
217
  summary: Vertical Scrolling Shooter
Binary file