line-em-up 0.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,149 @@
1
+ require_relative 'dumb_projectile.rb'
2
+ require_relative 'laser_particle.rb'
3
+ require 'opengl'
4
+ require 'glu'
5
+ require 'glut'
6
+
7
+ class Launcher < DumbProjectile
8
+ attr_accessor :x, :y, :active, :projectiles, :image_path, :test, :inited, :cooldown_wait
9
+ # DAMAGE = 0.001
10
+ COOLDOWN_DELAY = 15
11
+ # Friendly projects are + speeds
12
+ MAX_SPEED = 15
13
+
14
+ def init_projectile
15
+ raise "Override me"
16
+ end
17
+
18
+
19
+ def initialize(scale, screen_width, screen_height, object, options = {})
20
+ options[:relative_y_padding] = -(object.image_height_half)
21
+ super(scale, screen_width, screen_height, object, options)
22
+ @active = true
23
+ @projectiles = []
24
+ @image_optional = self.class.get_image#Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png")
25
+
26
+ @inited = true
27
+ @cooldown_wait = 0
28
+ # @image_angle = options[:image_angle] || 0
29
+ # puts "IMAGE ANGLE: #{@image_angle}"
30
+ # raise "STOP "
31
+ end
32
+
33
+ def get_cooldown
34
+ COOLDOWN_DELAY
35
+ end
36
+
37
+ # Used via hardpoint
38
+ def self.get_hardpoint_image
39
+ # raise "Override me"
40
+ # default
41
+ Gosu::Image.new("#{MEDIA_DIRECTORY}/laser_beam_hardpoint.png")
42
+ end
43
+
44
+ def attack pointer
45
+ if @cooldown_wait <= 0
46
+ options = {damage_increase: @damage_increase}
47
+ projectile = init_projectile(options)
48
+ @projectiles << projectile
49
+ @cooldown_wait = get_cooldown
50
+ return projectile
51
+ end
52
+ end
53
+
54
+ # Get image is called before the initialization is complete
55
+ def self.get_image
56
+ # optional image
57
+ # Gosu::Image.new("#{MEDIA_DIRECTORY}/laser-start-overlay.png")
58
+ end
59
+ # In generalobject
60
+ # def get_image
61
+ # self.class.get_image
62
+ # end
63
+
64
+ def get_hardpoint_image
65
+ # default
66
+ Gosu::Image.new("#{MEDIA_DIRECTORY}/hardpoint_empty.png")
67
+ end
68
+
69
+ def deactivate
70
+ @active = false
71
+ # @projectiles.each do |particle|
72
+ # particle.active = false
73
+ # end
74
+ end
75
+
76
+ def update mouse_x = nil, mouse_y = nil, object = nil, scroll_factor = 1
77
+ if @inited && @active
78
+ @x = object.x
79
+ @y = object.y
80
+ end
81
+ @cooldown_wait -= 1.0 if @cooldown_wait > 0.0
82
+ if !@active && @projectiles.count == 0
83
+ return false
84
+ else
85
+ # @projectiles.reject! do |particle|
86
+ # !particle.parental_update(nil, nil, nil)
87
+ # end
88
+
89
+ return true
90
+ end
91
+ end
92
+
93
+ def get_draw_ordering
94
+ ZOrder::Launcher
95
+ end
96
+
97
+ # Furthest active particle in active beam
98
+ # def get_furthest_active_particle
99
+ # last_active_particle = nil
100
+ # if @active
101
+ # @projectiles.reverse.each do |lp|
102
+ # if lp.active && lp.y_is_on_screen
103
+ # last_active_particle = lp
104
+ # else
105
+ # break
106
+ # end
107
+
108
+ # end
109
+ # end
110
+ # return last_active_particle
111
+ # end
112
+
113
+ def draw
114
+ if @inited
115
+ if @active
116
+ if @image_optional
117
+ # if @image_angle != nil
118
+ # @image_optional.draw_rot(@x - @image_width_half, @y - @image_height_half, get_draw_ordering, @image_angle, 0.5, 0.5, @scale, @scale)
119
+ # else
120
+ @image_optional.draw(@x - @image_width_half, @y - @image_height_half, get_draw_ordering, @scale, @scale)
121
+ # end
122
+ end
123
+ end
124
+
125
+ return true
126
+ else
127
+ return false
128
+ end
129
+ end
130
+
131
+ def draw_gl
132
+ # if @inited
133
+ # z = ZOrder::Projectile
134
+ # new_width1, new_height1, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x - @image_width_half/2, @y - @image_height_half/2, @screen_width , @screen_height)
135
+ # new_width2, new_height2, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x, @y + @image_height_half/2, @screen_width , @screen_height)
136
+ # new_width3, new_height3, increment_x, increment_y = LaserBeam.convert_x_and_y_to_opengl_coords(@x + @image_width_half/2, @y - @image_height_half/2, @screen_width , @screen_height)
137
+
138
+ # glEnable(GL_BLEND)
139
+ # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
140
+
141
+ # glBegin(GL_TRIANGLES)
142
+ # glColor4f(0, 1, 0, 0.2)
143
+ # glVertex3f(new_width1, new_height1, 0.0)
144
+ # glVertex3f(new_width2, new_height2, 0.0)
145
+ # glVertex3f(new_width3, new_height3, 0.0)
146
+ # glEnd
147
+ # end
148
+ end
149
+ end
@@ -1,6 +1,38 @@
1
+
1
2
  class Main < Gosu::Window
2
- def initialize
3
- @width, @height = ResolutionSetting::RESOLUTIONS[0].split('x').collect{|s| s.to_i}
3
+ CURRENT_DIRECTORY = File.expand_path('../', __FILE__)
4
+ CONFIG_FILE = "#{CURRENT_DIRECTORY}/../../config.txt"
5
+ require "#{CURRENT_DIRECTORY}/../game_window.rb"
6
+ require "#{CURRENT_DIRECTORY}/../loadout_window.rb"
7
+
8
+
9
+ def initialize config_path = nil
10
+ config_path = CONFIG_FILE if config_path.nil?
11
+
12
+
13
+ # @width, @height = ResolutionSetting::SELECTION[0].split('x').collect{|s| s.to_i}
14
+ value = ConfigSetting.get_setting(config_path, 'resolution', ResolutionSetting::SELECTION[0])
15
+ raise "DID NOT GET A RESOLUTION FROM CONFIG" if value.nil?
16
+ width, height = value.split('x')
17
+ @width, @height = [width.to_i, height.to_i]
18
+
19
+ default_width, default_height = ResolutionSetting::SELECTION[0].split('x')
20
+ # default_width, default_height = default_value.split('x')
21
+ default_width, default_height = [default_width.to_i, default_height.to_i]
22
+
23
+
24
+ # Need to just pull from config file.. and then do scaling.
25
+ # index = GameWindow.find_index_of_current_resolution(self.width, self.height)
26
+ if @width == default_width && @height == @default_height
27
+ @scale = 1
28
+ else
29
+ # original_width, original_height = RESOLUTIONS[0]
30
+ width_scale = @width / default_width.to_f
31
+ height_scale = @height / default_height.to_f
32
+ @scale = (width_scale + height_scale) / 2
33
+ end
34
+
35
+
4
36
  super(@width, @height, false)
5
37
  @cursor = Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/cursor.png", false)
6
38
  @gl_background = GLBackground.new
@@ -17,26 +49,78 @@ class Main < Gosu::Window
17
49
  # @menu.add_item(Gosu::Image.new(self, "#{MEDIA_DIRECTORY}/item.png", false), x, y, 1, lambda { })
18
50
  # y += lineHeight
19
51
  # }, lambda {}]
20
- @menu = Menu.new(self)
21
- # for i in (0..items.size - 1)
22
- # @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))
23
- # y += lineHeight
24
- # end
25
- exit_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/exit.png")
26
- # puts "WIDTH HERE: #{exit_image.width}"
27
- # 8
28
- @menu.add_item(exit_image, ((@width / 2) - (exit_image.width / 2)), get_center_font_ui_y, 1, lambda { self.close }, exit_image)
52
+
53
+ # exit_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/exit.png")
54
+
55
+
56
+ # @menu.add_item(exit_image, @, @menu.y_offset, 1, lambda { self.close }, exit_image)
57
+
58
+
29
59
  window_height = Gosu.screen_height
30
- @resolution_menu = ResolutionSetting.new(window_height, @width, @height, get_center_font_ui_y, CONFIG_FILE)
60
+ @window = self
61
+ @resolution_menu = ResolutionSetting.new(@window, window_height, @width, @height, get_center_font_ui_y, config_path)
31
62
 
32
63
  @difficulty = nil
33
- @difficulty_menu = DifficultySetting.new(@width, @height, get_center_font_ui_y, CONFIG_FILE)
64
+ @difficulty_menu = DifficultySetting.new(@window, window_height, @width, @height, get_center_font_ui_y, config_path)
65
+ @menu = Menu.new(self, @width / 2, get_center_font_ui_y, ZOrder::UI, @scale)
66
+ # Just move everything else above the menu
67
+ # increase_center_font_ui_y(@menu.current_height)
68
+
69
+ # start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/menu/start.png")
70
+ # @game_window_width, @game_window_height, @full_screen = [nil, nil, nil]
71
+ # @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)
72
+
73
+ button_key = :start_game
74
+ @menu.add_item(
75
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Start", 0, 1),
76
+ 0,
77
+ 0,
78
+ lambda {|window, id| self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true, difficulty: @difficulty}) },
79
+ # lambda {|window, id| self.close },
80
+ nil,
81
+ {is_button: true, key: button_key}
82
+ )
83
+
84
+
85
+
86
+
87
+ # loadout_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/menu/loadout.png")
88
+ # @menu.add_item(loadout_image, (@width / 2) - (loadout_image.width / 2), get_center_font_ui_y, 1, lambda {self.close; LoadoutWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true}) }, loadout_image)
89
+ button_key = :loadout
90
+ @menu.add_item(
91
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Loadout", 0, 1),
92
+ 0,
93
+ 0,
94
+ lambda {|window, id| self.close; LoadoutWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true}) },
95
+ nil,
96
+ {is_button: true, key: button_key}
97
+ )
98
+
99
+ # debug_start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/debug_start.png")
100
+ # @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}) }, debug_start_image)
101
+
102
+ button_key = :debug_start
103
+ @menu.add_item(
104
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Debug Start", 0, 1),
105
+ 0,
106
+ 0,
107
+ lambda {|window, id| self.close; GameWindow.start(@game_window_width, @game_window_height, dynamic_get_resolution_fs, {block_controls_until_button_up: true, debug: true, difficulty: @difficulty}) },
108
+ nil,
109
+ {is_button: true, key: button_key}
110
+ )
111
+ button_key = :exit
112
+ @menu.add_item(
113
+ LUIT::Button.new(@menu.local_window, button_key, @menu.x, @menu.y + @menu.current_height, "Exit", 0, 1),
114
+ 0,
115
+ 0,
116
+ lambda {|window, id| self.close },
117
+ nil,
118
+ {is_button: true, key: button_key}
119
+ )
120
+
121
+
122
+
34
123
 
35
- start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/start.png")
36
- @game_window_width, @game_window_height, @full_screen = [nil, nil, nil]
37
- @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)
38
- debug_start_image = Gosu::Image.new("#{MEDIA_DIRECTORY}/debug_start.png")
39
- @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}) }, debug_start_image)
40
124
  # @font.draw("<", width + 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
41
125
  # @font.draw("Resolution", width / 2, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
42
126
  # @font.draw(">", width - 15, get_center_font_ui_y, 1, 1.0, 1.0, 0xff_ffff00)
@@ -52,13 +136,13 @@ class Main < Gosu::Window
52
136
  @resolution_menu.update(self.mouse_x, self.mouse_y)
53
137
  @difficulty_menu.update(self.mouse_x, self.mouse_y)
54
138
 
55
- @game_window_width, @game_window_height, @fullscreen = @resolution_menu.get_resolution
56
- @difficulty = @difficulty_menu.get_difficulty
139
+ @game_window_width, @game_window_height, @fullscreen = @resolution_menu.get_values
140
+ @difficulty = @difficulty_menu.get_values
57
141
  @gl_background.scroll
58
142
  end
59
143
 
60
144
  def draw
61
- @cursor.draw(self.mouse_x, self.mouse_y, 2)
145
+ @cursor.draw(self.mouse_x, self.mouse_y, ZOrder::Cursor)
62
146
  # @back.draw(0,0,0)
63
147
  reset_center_font_ui_y
64
148
  @menu.draw
@@ -75,18 +159,27 @@ class Main < Gosu::Window
75
159
  end
76
160
  end
77
161
 
162
+ def increase_center_font_ui_y amount
163
+ @center_ui_y += amount
164
+ end
165
+
78
166
  def get_center_font_ui_y
79
- return_value = @center_ui_y
80
- @center_ui_y += 50
81
- return return_value
167
+ increase_center_font_ui_y(50)
82
168
  end
83
169
 
170
+
171
+ # def get_center_font_ui_y
172
+ # return_value = @center_ui_y
173
+ # @center_ui_y += 50
174
+ # return return_value
175
+ # end
176
+
84
177
  def get_center_font_ui_x
85
178
  return @center_ui_x
86
179
  end
87
180
 
88
181
  def reset_center_font_ui_y
89
- @center_ui_y = self.height / 2 - 100
90
- @center_ui_x = self.width / 2 - 100
182
+ @center_ui_y = -(self.height / 2) + self.height / 1.5
183
+ @center_ui_x = self.width / 2
91
184
  end
92
185
  end
@@ -1,12 +1,40 @@
1
1
  require_relative 'menu_item.rb'
2
2
  class Menu
3
- def initialize (window)
3
+ attr_accessor :local_window, :current_height, :x, :y
4
+ def initialize(window, x, y, z = ZOrder::UI, scale = 1)
5
+ @scale = scale
4
6
  @window = window
7
+ @x = x
8
+ @y = y
9
+ @z = z
10
+ @cell_padding = 10 * @scale
11
+ # @offset_y = 0
12
+ @local_window = self
13
+ LUIT.config({window: @window, z: z})
5
14
  @items = Array.new
15
+ @current_height = 0
16
+ # Add to it while the buttons are being added, in add_item
17
+ @button_id_mapping = {}
6
18
  end
7
19
 
8
- def add_item (object, x, y, z, callback, hover_image = nil, options = {})
9
- item = MenuItem.new(@window, object, x, y, z, callback, hover_image, options)
20
+ # For external use
21
+ def increase_y_offset amount
22
+ @current_height = @current_height + amount
23
+ end
24
+
25
+ def add_item(object, x, y, callback, hover_image = nil, options = {})
26
+ if options[:key]
27
+ @button_id_mapping[options[:key]] = callback
28
+ end
29
+ if options[:is_button]
30
+
31
+ end
32
+ item = MenuItem.new(@window, object, x, y, @z, callback, hover_image, options)
33
+ if options[:is_button]
34
+ @current_height = @current_height + object.h + @cell_padding
35
+ else
36
+ @current_height = @current_height + object.height + @cell_padding
37
+ end
10
38
  @items << item
11
39
  self
12
40
  end
@@ -28,4 +56,16 @@ class Menu
28
56
  i.clicked
29
57
  end
30
58
  end
59
+
60
+ def onClick element_id
61
+ # puts "LOADOUT WINDOW ONCLICK"
62
+ button_clicked_exists = @button_id_mapping.key?(element_id)
63
+ if button_clicked_exists
64
+ @button_id_mapping[element_id].call(@local_window, element_id)
65
+ else
66
+ puts "Clicked button that is not mapped: #{element_id}"
67
+ end
68
+ end
69
+
70
+
31
71
  end
@@ -10,6 +10,8 @@ class MenuItem
10
10
  @callback = callback
11
11
  # Can also be a font object!
12
12
  @active_image = @main_image
13
+ @is_button = options[:is_button]
14
+ @y_offset = options[:y_offset] || 0
13
15
  # @text = options[:text]
14
16
  # @value = options[:value]
15
17
  # @settings_name = options[:settings_name]
@@ -18,26 +20,33 @@ class MenuItem
18
20
  end
19
21
 
20
22
  def draw
21
- if @text
23
+ if @text && !@is_button
22
24
  @active_image.draw(@text, @x, @y, 1, 1.0, 1.0, 0xff_ffff00)
23
- else
25
+ elsif !@is_button
24
26
  @active_image.draw(@x, @y, @z)
27
+ elsif @is_button
28
+ @main_image.draw(-(@main_image.w / 2), -(@y_offset - @main_image.h / 2))
29
+ # @main_image.draw(0, 0)
25
30
  end
26
31
  end
27
32
 
28
33
  def update
29
34
  # @text = @get_value_callback.call(@config_file, @settings_name) if @get_value_callback && @config_file && @settings_name
30
- if is_mouse_hovering
31
- if !@hover_image.nil? then
32
- @active_image = @hover_image
33
- end
35
+ if !@is_button
36
+ if is_mouse_hovering
37
+ if !@hover_image.nil? then
38
+ @active_image = @hover_image
39
+ end
34
40
 
35
- @x = @original_x + HOVER_OFFSET
36
- @y = @original_y + HOVER_OFFSET
37
- else
38
- @active_image = @main_image
39
- @x = @original_x
40
- @y = @original_y
41
+ @x = @original_x + HOVER_OFFSET
42
+ @y = @original_y + HOVER_OFFSET
43
+ else
44
+ @active_image = @main_image
45
+ @x = @original_x
46
+ @y = @original_y
47
+ end
48
+ else
49
+ @main_image.update(-(@main_image.w / 2), -(@y_offset - @main_image.h / 2))
41
50
  end
42
51
  end
43
52
 
@@ -60,8 +69,10 @@ class MenuItem
60
69
  # if is_mouse_hovering && @callback && @value && @config_file && @settings_name
61
70
  # return_value = @callback.call(@config_file, @settings_name, @value)
62
71
  # end
63
- if is_mouse_hovering && @callback
64
- @callback.call
72
+ if !@is_button
73
+ if is_mouse_hovering && @callback
74
+ @callback.call
75
+ end
65
76
  end
66
77
  # if return_value
67
78
  # @text = return_value
@@ -24,6 +24,7 @@ class MissileBoat < GeneralObject
24
24
  @health = 10
25
25
  @armor = 0
26
26
  @current_speed = (rand(5) * @scale).round + 1
27
+ @damage_factor = options[:damage_increase] || 0.5
27
28
  end
28
29
 
29
30
  def get_points
@@ -44,9 +45,9 @@ class MissileBoat < GeneralObject
44
45
  x_padding_2 = -(5 * @scale)
45
46
  return {
46
47
  projectiles: [
47
- SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 2}),
48
- SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 12, x_homing_padding: x_padding_1}),
49
- SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 18, x_homing_padding: x_padding_2})
48
+ SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 2, damage_increase: @damage_factor}),
49
+ SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 12, x_homing_padding: x_padding_1, damage_increase: @damage_factor}),
50
+ SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, MISSILE_LAUNCHER_MIN_ANGLE, MISSILE_LAUNCHER_MAX_ANGLE, MISSILE_LAUNCHER_INIT_ANGLE, {custom_initial_delay: 18, x_homing_padding: x_padding_2, damage_increase: @damage_factor})
50
51
  ],
51
52
  cooldown: SemiGuidedMissile::COOLDOWN_DELAY
52
53
  }
@@ -69,7 +70,7 @@ class MissileBoat < GeneralObject
69
70
 
70
71
  # end
71
72
 
72
- def update mouse_x = nil, mouse_y = nil, player = nil
73
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
73
74
  @cooldown_wait -= 1 if @cooldown_wait > 0
74
75
  if is_alive
75
76
  # Stay above the player
@@ -28,6 +28,7 @@ class Mite < GeneralObject
28
28
  @current_speed = self.class.get_max_speed * @scale
29
29
  @x_direction = x_direction
30
30
  @switched_directions = false
31
+ @damage_factor = options[:damage_increase] || 0.3
31
32
  end
32
33
 
33
34
  def get_points
@@ -46,7 +47,7 @@ class Mite < GeneralObject
46
47
  def attack player
47
48
  return {
48
49
  projectiles: [
49
- SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player)
50
+ SemiGuidedMissile.new(@scale, @screen_width, @screen_height, self, player, nil, nil, nil, {damage_increase: @damage_factor})
50
51
  ],
51
52
  cooldown: SemiGuidedMissile::COOLDOWN_DELAY * MAX_ATTACK_SPEED
52
53
  }
@@ -67,7 +68,7 @@ class Mite < GeneralObject
67
68
  # raise "HERE"
68
69
  # end
69
70
 
70
- def update mouse_x = nil, mouse_y = nil, player = nil
71
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
71
72
  @cooldown_wait -= 1 if @cooldown_wait > 0
72
73
  @time_alive += 1
73
74
  if is_alive
@@ -0,0 +1,61 @@
1
+ require_relative 'general_object.rb'
2
+ require_relative 'rocket_launcher_pickup.rb'
3
+ require_relative 'pilotable_ship.rb'
4
+ require 'gosu'
5
+
6
+ require 'opengl'
7
+ require 'glut'
8
+
9
+
10
+ include OpenGL
11
+ include GLUT
12
+
13
+ class MiteShip < PilotableShip
14
+ SHIP_MEDIA_DIRECTORY = "#{MEDIA_DIRECTORY}/pilotable_ships/mite_ship"
15
+ SPEED = 8
16
+ MAX_ATTACK_SPEED = 3.0
17
+ attr_accessor :cooldown_wait, :secondary_cooldown_wait, :attack_speed, :health, :armor, :x, :y, :rockets, :score, :time_alive
18
+
19
+ attr_accessor :bombs, :secondary_weapon, :grapple_hook_cooldown_wait, :damage_reduction, :boost_increase, :damage_increase, :kill_count
20
+ attr_accessor :special_attack, :main_weapon, :drawable_items_near_self, :broadside_mode, :front_hard_points, :broadside_hard_points
21
+ MAX_HEALTH = 100
22
+
23
+ # SECONDARY_WEAPONS = [RocketLauncherPickup::NAME] + %w[bomb]
24
+ # Range goes clockwise around the 0-360 angle
25
+ # MISSILE_LAUNCHER_MIN_ANGLE = 75
26
+ # MISSILE_LAUNCHER_MAX_ANGLE = 105
27
+ # MISSILE_LAUNCHER_INIT_ANGLE = 90
28
+
29
+ # SPECIAL_POWER = 'laser'
30
+ # SPECIAL_POWER_KILL_MAX = 50
31
+
32
+ # FRONT_HARDPOINT_LOCATIONS = [{x_offset: 0, y_offset: -get_image.height}]
33
+ # RIGHT_BROADSIDE_HARDPOINT_LOCATIONS = [{x_offset: get_image.width / 2, y_offset: -(get_image.height * 0.9)}, {x_offset: get_image.width, y_offset: -(get_image.height * 0.8)}, {x_offset: -(get_image.width / 2), y_offset: -(get_image.height * 0.8)}]
34
+ FRONT_HARDPOINT_LOCATIONS = [{x_offset: lambda { |image, scale| 0 }, y_offset: lambda { |image, scale| -(image.height * scale / 2) } }]
35
+ RIGHT_BROADSIDE_HARDPOINT_LOCATIONS = [
36
+ {x_offset: lambda { |image, scale| image.width * scale / 2 }, y_offset: lambda { |image, scale| -(image.height * scale / 2)} },
37
+ {x_offset: lambda { |image, scale| -(image.width * scale / 2) } , y_offset: lambda { |image, scale| -(image.height * scale / 2)} }
38
+ ]
39
+ LEFT_BROADSIDE_HARDPOINT_LOCATIONS = []
40
+
41
+
42
+ # Rocket Launcher, Rocket launcher, yannon, Cannon, Bomb Launcher
43
+ # FRONT_HARD_POINTS_MAX = 1
44
+ # BROADSIDE_HARD_POINTS = 2
45
+
46
+ # def self.get_broadside_image
47
+ # Gosu::Image.new("#{MEDIA_DIRECTORY}/mite.png")
48
+ # end
49
+
50
+ # def self.get_image
51
+ # Gosu::Image.new("#{MEDIA_DIRECTORY}/mite.png")
52
+ # end
53
+
54
+
55
+ # def get_image_path
56
+ # "#{MEDIA_DIRECTORY}/spaceship.png"
57
+ # end
58
+
59
+
60
+
61
+ end
@@ -99,7 +99,7 @@ class Mothership < GeneralObject
99
99
 
100
100
  # end
101
101
 
102
- def update mouse_x = nil, mouse_y = nil, player = nil
102
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
103
103
  @cooldown_wait -= 1 if @cooldown_wait > 0
104
104
  @secondary_cooldown_wait -= 1 if @secondary_cooldown_wait > 0
105
105
  @tertiary_cooldown_wait -= 1 if @tertiary_cooldown_wait > 0
@@ -19,8 +19,8 @@ class Pickup < GeneralObject
19
19
  end
20
20
 
21
21
 
22
- def update mouse_x = nil, mouse_y = nil, player = nil
23
- @y += @current_speed
22
+ def update mouse_x = nil, mouse_y = nil, player = nil, scroll_factor = 1
23
+ @y += @current_speed * scroll_factor
24
24
 
25
25
  super(mouse_x, mouse_y)
26
26
  end