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.
- checksums.yaml +4 -4
- data/line-em-up/game_window.rb +189 -52
- data/line-em-up/irb_requirements.rb +24 -2
- data/line-em-up/lib/config_setting.rb +126 -16
- data/line-em-up/lib/difficulty_setting.rb +64 -64
- data/line-em-up/lib/lighting.rb +143 -0
- data/line-em-up/lib/resolution_setting.rb +58 -58
- data/line-em-up/lib/setting.rb +104 -0
- data/line-em-up/lib/ship_loadout_setting.rb +476 -0
- data/line-em-up/lib/ship_setting.rb +98 -0
- data/line-em-up/lib/z_order.rb +1 -1
- data/line-em-up/loadout_window.rb +253 -0
- data/line-em-up/media/bullet_launcher_hardpoint.png +0 -0
- data/line-em-up/media/hardpoint_empty.png +0 -0
- data/line-em-up/media/header@2x.psd +0 -0
- data/line-em-up/media/laser-end-background-half.png +0 -0
- data/line-em-up/media/laser-end-background.png +0 -0
- data/line-em-up/media/laser-end-overlay-half.png +0 -0
- data/line-em-up/media/laser-end-overlay.png +0 -0
- data/line-em-up/media/laser-middle-background-half.png +0 -0
- data/line-em-up/media/laser-middle-background.png +0 -0
- data/line-em-up/media/laser-middle-overlay-half.png +0 -0
- data/line-em-up/media/laser-middle-overlay-short.png +0 -0
- data/line-em-up/media/laser-middle-overlay.png +0 -0
- data/line-em-up/media/laser-overlay-half.png +0 -0
- data/line-em-up/media/laser-overlay.png +0 -0
- data/line-em-up/media/laser-start-background-half.png +0 -0
- data/line-em-up/media/laser-start-background.png +0 -0
- data/line-em-up/media/laser-start-overlay-half.png +0 -0
- data/line-em-up/media/laser-start-overlay.png +0 -0
- data/line-em-up/media/laser_beam_hardpoint copy.png +0 -0
- data/line-em-up/media/laser_beam_hardpoint.png +0 -0
- data/line-em-up/media/line-em-up-resolution.png +0 -0
- data/line-em-up/media/menu/loadout.png +0 -0
- data/line-em-up/media/{start.png → menu/start.png} +0 -0
- data/line-em-up/media/missile_launcher.png +0 -0
- data/line-em-up/media/{spaceship.png → pilotable_ships/basic_ship/default.png} +0 -0
- data/line-em-up/media/{spaceship_original.png → pilotable_ships/basic_ship/large.png} +0 -0
- data/line-em-up/media/{spaceship_left.png → pilotable_ships/basic_ship/left.png} +0 -0
- data/line-em-up/media/pilotable_ships/basic_ship/left_broadside.png +0 -0
- data/line-em-up/media/pilotable_ships/basic_ship/original.png +0 -0
- data/line-em-up/media/{spaceship_right.png → pilotable_ships/basic_ship/right.png} +0 -0
- data/line-em-up/media/pilotable_ships/basic_ship/right_broadside.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/default.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/large.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/left.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/left_broadside.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/original.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/right.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship/right_broadside.png +0 -0
- data/line-em-up/media/pilotable_ships/mite_ship.zip +0 -0
- data/line-em-up/models/basic_ship.rb +94 -0
- data/line-em-up/models/bomb.rb +1 -1
- data/line-em-up/models/building.rb +2 -2
- data/line-em-up/models/bullet.rb +127 -74
- data/line-em-up/models/bullet_launcher.rb +23 -0
- data/line-em-up/models/cursor.rb +37 -1
- data/line-em-up/models/dumb_missile_launcher.rb +40 -0
- data/line-em-up/models/dumb_projectile.rb +9 -2
- data/line-em-up/models/enemy_bomb.rb +1 -1
- data/line-em-up/models/enemy_bullet.rb +55 -0
- data/line-em-up/models/enemy_player.rb +1 -1
- data/line-em-up/models/execute_open_gl.rb +80 -0
- data/line-em-up/models/general_object.rb +82 -9
- data/line-em-up/models/gl_background.rb +103 -30
- data/line-em-up/models/grappling_hook.rb +1 -1
- data/line-em-up/models/hardpoint.rb +120 -0
- data/line-em-up/models/laser_launcher.rb +192 -0
- data/line-em-up/models/laser_particle.rb +133 -0
- data/line-em-up/models/launcher.rb +149 -0
- data/line-em-up/models/main.rb +119 -26
- data/line-em-up/models/menu.rb +43 -3
- data/line-em-up/models/menu_item.rb +25 -14
- data/line-em-up/models/missile_boat.rb +5 -4
- data/line-em-up/models/mite.rb +3 -2
- data/line-em-up/models/mite_ship.rb +61 -0
- data/line-em-up/models/mothership.rb +1 -1
- data/line-em-up/models/pickup.rb +2 -2
- data/line-em-up/models/pilotable_ship.rb +599 -0
- data/line-em-up/models/player.rb +207 -150
- data/line-em-up/models/projectile.rb +3 -24
- data/line-em-up/models/semi_guided_missile.rb +1 -1
- data/line-em-up/models/small_explosion.rb +2 -2
- data/line-em-up/models/star.rb +7 -2
- data/menu_launcher.rb +10 -6
- metadata +113 -10
- data/line-em-up/media/spaceship_left-test.png +0 -0
@@ -2,77 +2,77 @@ require_relative 'setting.rb'
|
|
2
2
|
# require_relative "config_settings.rb"
|
3
3
|
|
4
4
|
class DifficultySetting < Setting
|
5
|
-
|
6
|
-
|
5
|
+
SELECTION = ["easy", "medium", "hard"]
|
6
|
+
NAME = "difficulty"
|
7
|
+
# attr_accessor :x, :y, :font, :max_width, :max_height
|
7
8
|
|
9
|
+
# def initialize max_width, max_height, height, config_file_path
|
10
|
+
# # puts "INNITING #{config_file_path}"
|
11
|
+
# @font = Gosu::Font.new(20)
|
12
|
+
# # @x = width
|
13
|
+
# @y = height
|
14
|
+
# @max_width = max_width
|
15
|
+
# @max_height = max_height
|
16
|
+
# @next_x = 15
|
17
|
+
# @prev_x = @max_width - 15 - @font.text_width('>')
|
18
|
+
# @config_file_path = config_file_path
|
19
|
+
# @name = 'difficulty'
|
20
|
+
# @value = ConfigSetting.get_setting(@config_file_path, @name, SELECTION[0])
|
21
|
+
# end
|
8
22
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@max_height = max_height
|
16
|
-
@next_x = 15
|
17
|
-
@prev_x = @max_width - 15 - @font.text_width('>')
|
18
|
-
@config_file_path = config_file_path
|
19
|
-
@name = 'difficulty'
|
20
|
-
@value = ConfigSetting.get_setting(@config_file_path, @name, DIFFICULTIES[0])
|
21
|
-
end
|
23
|
+
# def get_values
|
24
|
+
# # puts "GETTING DIFFICULTY: #{@value}"
|
25
|
+
# if @value
|
26
|
+
# @value
|
27
|
+
# end
|
28
|
+
# end
|
22
29
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
30
|
+
# def draw
|
31
|
+
# @font.draw("<", @next_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
32
|
+
# @font.draw(@value, ((@max_width / 2) - @font.text_width(@value) / 2), @y, 1, 1.0, 1.0, 0xff_ffff00)
|
33
|
+
# @font.draw(">", @prev_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
34
|
+
# end
|
29
35
|
|
30
|
-
def
|
31
|
-
|
32
|
-
@font.draw(@value, ((@max_width / 2) - @font.text_width(@value) / 2), @y, 1, 1.0, 1.0, 0xff_ffff00)
|
33
|
-
@font.draw(">", @prev_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
34
|
-
end
|
36
|
+
# def update mouse_x, mouse_y
|
37
|
+
# end
|
35
38
|
|
36
|
-
def
|
37
|
-
|
39
|
+
# def clicked mx, my
|
40
|
+
# if is_mouse_hovering_next(mx, my)
|
41
|
+
# puts "NEXT!!"
|
42
|
+
# index = SELECTION.index(@value)
|
43
|
+
# value = @value
|
44
|
+
# if index == 0
|
45
|
+
# value = SELECTION[SELECTION.count - 1]
|
46
|
+
# else
|
47
|
+
# value = SELECTION[index - 1]
|
48
|
+
# end
|
49
|
+
# ConfigSetting.set_setting(@config_file_path, @name, value)
|
50
|
+
# @value = value
|
51
|
+
# elsif is_mouse_hovering_prev(mx, my)
|
52
|
+
# puts "PREVV!!!!"
|
53
|
+
# index = SELECTION.index(@value)
|
54
|
+
# value = @value
|
55
|
+
# if index == SELECTION.count - 1
|
56
|
+
# value = SELECTION[0]
|
57
|
+
# else
|
58
|
+
# value = SELECTION[index + 1]
|
59
|
+
# end
|
60
|
+
# ConfigSetting.set_setting(@config_file_path, @name, value)
|
61
|
+
# @value = value
|
62
|
+
# end
|
63
|
+
# end
|
38
64
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
index = DIFFICULTIES.index(@value)
|
43
|
-
value = @value
|
44
|
-
if index == 0
|
45
|
-
value = DIFFICULTIES[DIFFICULTIES.count - 1]
|
46
|
-
else
|
47
|
-
value = DIFFICULTIES[index - 1]
|
48
|
-
end
|
49
|
-
ConfigSetting.set_setting(@config_file_path, @name, value)
|
50
|
-
@value = value
|
51
|
-
elsif is_mouse_hovering_prev(mx, my)
|
52
|
-
puts "PREVV!!!!"
|
53
|
-
index = DIFFICULTIES.index(@value)
|
54
|
-
value = @value
|
55
|
-
if index == DIFFICULTIES.count - 1
|
56
|
-
value = DIFFICULTIES[0]
|
57
|
-
else
|
58
|
-
value = DIFFICULTIES[index + 1]
|
59
|
-
end
|
60
|
-
ConfigSetting.set_setting(@config_file_path, @name, value)
|
61
|
-
@value = value
|
62
|
-
end
|
63
|
-
end
|
64
|
-
def is_mouse_hovering_next mx, my
|
65
|
-
local_width = @font.text_width('>')
|
66
|
-
local_height = @font.height
|
65
|
+
# def is_mouse_hovering_next mx, my
|
66
|
+
# local_width = @font.text_width('>')
|
67
|
+
# local_height = @font.height
|
67
68
|
|
68
|
-
|
69
|
-
end
|
70
|
-
def is_mouse_hovering_prev mx, my
|
71
|
-
local_width = @font.text_width('<')
|
72
|
-
local_height = @font.height
|
73
|
-
|
74
|
-
(mx >= @prev_x and my >= @y) and (mx <= @prev_x + local_width) and (my <= @y + local_height)
|
75
|
-
end
|
69
|
+
# (mx >= @next_x and my >= @y) and (mx <= @next_x + local_width) and (my <= @y + local_height)
|
70
|
+
# end
|
76
71
|
|
72
|
+
# def is_mouse_hovering_prev mx, my
|
73
|
+
# local_width = @font.text_width('<')
|
74
|
+
# local_height = @font.height
|
77
75
|
|
76
|
+
# (mx >= @prev_x and my >= @y) and (mx <= @prev_x + local_width) and (my <= @y + local_height)
|
77
|
+
# end
|
78
78
|
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# require 'gosu'
|
2
|
+
# require 'glfw'
|
3
|
+
# require 'opengl'
|
4
|
+
|
5
|
+
# OpenGL.load_dll
|
6
|
+
# GLFW.load_dll
|
7
|
+
|
8
|
+
# include OpenGL
|
9
|
+
# include GLFW
|
10
|
+
|
11
|
+
# SHADOW_LENGTH = 20000
|
12
|
+
|
13
|
+
# module GosuLighting
|
14
|
+
# class Source
|
15
|
+
# attr_accessor :x, :y, :radius
|
16
|
+
|
17
|
+
# def initialize window, x, y, radius, att_sprite = nil
|
18
|
+
# @att_sprite = att_sprite || Gosu::Image.new(window, 'light.png', true)
|
19
|
+
# @window = window
|
20
|
+
# @x = x
|
21
|
+
# @y = y
|
22
|
+
# @radius = radius
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def shadow_circle circle, depth = 1
|
26
|
+
# dist = Gosu::distance @x, @y, circle.x, circle.y
|
27
|
+
# depth = depth + 1.0 - dist / SHADOW_LENGTH
|
28
|
+
|
29
|
+
# bx1, by1, bx2, by2 = endpoints_facing circle.x, circle.y, @x, @y, circle.radius
|
30
|
+
|
31
|
+
# nx1, ny1 = normal @x, @y, bx1, by1
|
32
|
+
# nx2, ny2 = normal @x, @y, bx2, by2
|
33
|
+
|
34
|
+
# sx1 = bx1 + nx1 * SHADOW_LENGTH
|
35
|
+
# sy1 = by1 + ny1 * SHADOW_LENGTH
|
36
|
+
# sx2 = bx2 + nx2 * SHADOW_LENGTH
|
37
|
+
# sy2 = by2 + ny2 * SHADOW_LENGTH
|
38
|
+
|
39
|
+
# @window.gl depth do
|
40
|
+
# gl_draw_shadow bx1, by1, sx1, sy1, sx2, sy2, bx2, by2, 0.5
|
41
|
+
# end
|
42
|
+
|
43
|
+
# return depth
|
44
|
+
# end
|
45
|
+
|
46
|
+
# def shadow_rectangle rect, depth = 2
|
47
|
+
# dist = Gosu::distance @x, @y, rect.center_x, rect.center_y
|
48
|
+
# depth = depth + 1.0 - dist / SHADOW_LENGTH
|
49
|
+
|
50
|
+
# cx1 = cx2 = rect.x
|
51
|
+
# cy1 = cy2 = rect.y
|
52
|
+
# if @x < rect.x
|
53
|
+
# cy1 += rect.height
|
54
|
+
# elsif @x < rect.x + rect.width
|
55
|
+
# cy1 += rect.height if @y > rect.center_y
|
56
|
+
# cy2 = cy1
|
57
|
+
# else
|
58
|
+
# cy2 += rect.height
|
59
|
+
# end
|
60
|
+
|
61
|
+
# if @y < rect.y
|
62
|
+
# cx2 += rect.width
|
63
|
+
# elsif @y < rect.y + rect.height
|
64
|
+
# cx1 += rect.width if @x > rect.center_x
|
65
|
+
# cx2 = cx1
|
66
|
+
# else
|
67
|
+
# cx1 += rect.width
|
68
|
+
# end
|
69
|
+
|
70
|
+
# nx1, ny1 = normal @x, @y, cx1, cy1
|
71
|
+
# nx2, ny2 = normal @x, @y, cx2, cy2
|
72
|
+
|
73
|
+
# sx1 = cx1 + nx1 * SHADOW_LENGTH
|
74
|
+
# sy1 = cy1 + ny1 * SHADOW_LENGTH
|
75
|
+
# sx2 = cx2 + nx2 * SHADOW_LENGTH
|
76
|
+
# sy2 = cy2 + ny2 * SHADOW_LENGTH
|
77
|
+
|
78
|
+
# @window.gl depth do
|
79
|
+
# gl_draw_shadow cx1, cy1, sx1, sy1, sx2, sy2, cx2, cy2, 1.0
|
80
|
+
# end
|
81
|
+
|
82
|
+
# return depth
|
83
|
+
# end
|
84
|
+
|
85
|
+
# def draw_attenuation depth
|
86
|
+
# draw_as_rect @att_sprite, *clip_rect, depth, 0xff999999, :multiply
|
87
|
+
# end
|
88
|
+
|
89
|
+
# def draw
|
90
|
+
# @window.clip_to(*clip_rect) do
|
91
|
+
# yield self
|
92
|
+
# end
|
93
|
+
# end
|
94
|
+
|
95
|
+
# private
|
96
|
+
# def endpoints_facing x1, y1, x2, y2, r
|
97
|
+
# a = Gosu::angle x1, y1, x2, y2
|
98
|
+
# x3 = x1 + Gosu::offset_x(a + 90, r)
|
99
|
+
# y3 = y1 + Gosu::offset_y(a + 90, r)
|
100
|
+
|
101
|
+
# x4 = x1 + Gosu::offset_x(a - 90, r)
|
102
|
+
# y4 = y1 + Gosu::offset_y(a - 90, r)
|
103
|
+
|
104
|
+
# [x3, y3, x4, y4]
|
105
|
+
# end
|
106
|
+
|
107
|
+
# def vector x1, y1, x2, y2
|
108
|
+
# dy = y2 - y1
|
109
|
+
# dx = x2 - x1
|
110
|
+
# [dx, dy]
|
111
|
+
# end
|
112
|
+
|
113
|
+
# def normal x1, y1, x2, y2
|
114
|
+
# d = Gosu::distance x1, y1, x2, y2
|
115
|
+
# x, y = vector x1, y1, x2, y2
|
116
|
+
|
117
|
+
# [x/d, y/d]
|
118
|
+
# end
|
119
|
+
|
120
|
+
# def clip_rect
|
121
|
+
# [(@x - @radius).to_i, (@y - @radius).to_i, (@radius*2.0).to_i, (@radius*2.0).to_i]
|
122
|
+
# end
|
123
|
+
|
124
|
+
# def draw_as_rect sprite, x, y, w, h, z, color, mode
|
125
|
+
# sprite.draw_as_quad x, y, color, x+w, y, color, x+w, y+h, color, x, y+h, color, z, mode
|
126
|
+
# end
|
127
|
+
|
128
|
+
# def gl_draw_shadow x1, y1, x2, y2, x3, y3, x4, y4, alpha = 0.9
|
129
|
+
# glDisable GL_DEPTH_TEST
|
130
|
+
# glEnable GL_BLEND
|
131
|
+
# glBlendEquationSeparate GL_FUNC_ADD, GL_FUNC_ADD
|
132
|
+
# glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO
|
133
|
+
|
134
|
+
# glBegin GL_QUADS
|
135
|
+
# glColor4f 0, 0, 0, alpha
|
136
|
+
# glVertex3f x1, y1, 0
|
137
|
+
# glVertex3f x2, y2, 0
|
138
|
+
# glVertex3f x3, y3, 0
|
139
|
+
# glVertex3f x4, y4, 0
|
140
|
+
# glEnd
|
141
|
+
# end
|
142
|
+
# end
|
143
|
+
# end
|
@@ -3,26 +3,26 @@ require_relative 'setting.rb'
|
|
3
3
|
|
4
4
|
class ResolutionSetting < Setting
|
5
5
|
FULLSCREEN_NAME = "fullscreen"
|
6
|
-
|
7
|
-
|
6
|
+
NAME = "resolution"
|
7
|
+
SELECTION = ["480x480", "640x480", "800x600", "960x720", "1024x768", "1280x960", "1400x1050", "1440x1080", "1600x1200", "1856x1392", "1920x1440", "2048x1536", FULLSCREEN_NAME]
|
8
|
+
# 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
|
+
# @font = Gosu::Font.new(20)
|
12
|
+
# # @x = width
|
13
|
+
# @y = height
|
14
|
+
# @max_width = max_width
|
15
|
+
# @max_height = max_height
|
16
|
+
# @next_x = 15
|
17
|
+
# @prev_x = @max_width - 15 - @font.text_width('>')
|
18
|
+
# @config_file_path = config_file_path
|
19
|
+
# @name = get_name
|
20
|
+
# @value = ConfigSetting.get_setting(@config_file_path, @name, SELECTION[0])
|
21
|
+
# @fullscreen = false
|
22
|
+
# @fullscreen_height = fullscreen_height
|
23
|
+
# end
|
9
24
|
|
10
|
-
def
|
11
|
-
@font = Gosu::Font.new(20)
|
12
|
-
# @x = width
|
13
|
-
@y = height
|
14
|
-
@max_width = max_width
|
15
|
-
@max_height = max_height
|
16
|
-
@next_x = 15
|
17
|
-
@prev_x = @max_width - 15 - @font.text_width('>')
|
18
|
-
@config_file_path = config_file_path
|
19
|
-
@name = 'resolution'
|
20
|
-
@value = ConfigSetting.get_setting(@config_file_path, @name, RESOLUTIONS[0])
|
21
|
-
@fullscreen = false
|
22
|
-
@fullscreen_height = fullscreen_height
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_resolution
|
25
|
+
def get_values
|
26
26
|
if @value == FULLSCREEN_NAME
|
27
27
|
height = @fullscreen_height
|
28
28
|
width = (@fullscreen_height / 3) * 4
|
@@ -32,50 +32,50 @@ class ResolutionSetting < Setting
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def draw
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
35
|
+
# def draw
|
36
|
+
# @font.draw("<", @next_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
37
|
+
# @font.draw(@value, ((@max_width / 2) - @font.text_width(@value) / 2), @y, 1, 1.0, 1.0, 0xff_ffff00)
|
38
|
+
# @font.draw(">", @prev_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
39
|
+
# end
|
40
40
|
|
41
|
-
def update mouse_x, mouse_y
|
42
|
-
end
|
41
|
+
# def update mouse_x, mouse_y
|
42
|
+
# end
|
43
43
|
|
44
|
-
def clicked mx, my
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
def is_mouse_hovering_next mx, my
|
68
|
-
|
69
|
-
|
44
|
+
# def clicked mx, my
|
45
|
+
# if is_mouse_hovering_next(mx, my)
|
46
|
+
# index = SELECTION.index(@value)
|
47
|
+
# value = @value
|
48
|
+
# if index == 0
|
49
|
+
# value = SELECTION[SELECTION.count - 1]
|
50
|
+
# else
|
51
|
+
# value = SELECTION[index - 1]
|
52
|
+
# end
|
53
|
+
# ConfigSetting.set_setting(@config_file_path, @name, value)
|
54
|
+
# @value = value
|
55
|
+
# elsif is_mouse_hovering_prev(mx, my)
|
56
|
+
# index = SELECTION.index(@value)
|
57
|
+
# value = @value
|
58
|
+
# if index == SELECTION.count - 1
|
59
|
+
# value = SELECTION[0]
|
60
|
+
# else
|
61
|
+
# value = SELECTION[index + 1]
|
62
|
+
# end
|
63
|
+
# ConfigSetting.set_setting(@config_file_path, @name, value)
|
64
|
+
# @value = value
|
65
|
+
# end
|
66
|
+
# end
|
67
|
+
# def is_mouse_hovering_next mx, my
|
68
|
+
# local_width = @font.text_width('>')
|
69
|
+
# local_height = @font.height
|
70
70
|
|
71
|
-
|
72
|
-
end
|
73
|
-
def is_mouse_hovering_prev mx, my
|
74
|
-
|
75
|
-
|
71
|
+
# (mx >= @next_x and my >= @y) and (mx <= @next_x + local_width) and (my <= @y + local_height)
|
72
|
+
# end
|
73
|
+
# def is_mouse_hovering_prev mx, my
|
74
|
+
# local_width = @font.text_width('<')
|
75
|
+
# local_height = @font.height
|
76
76
|
|
77
|
-
|
78
|
-
end
|
77
|
+
# (mx >= @prev_x and my >= @y) and (mx <= @prev_x + local_width) and (my <= @y + local_height)
|
78
|
+
# end
|
79
79
|
|
80
80
|
|
81
81
|
end
|
data/line-em-up/lib/setting.rb
CHANGED
@@ -1,4 +1,108 @@
|
|
1
1
|
require_relative "config_setting.rb"
|
2
2
|
|
3
3
|
class Setting
|
4
|
+
SELECTION = []
|
5
|
+
NAME = "OverrideMe"
|
6
|
+
|
7
|
+
attr_accessor :x, :y, :font, :max_width, :max_height, :selection, :value, :window
|
8
|
+
def initialize window, fullscreen_height, max_width, max_height, current_height, config_file_path
|
9
|
+
@window = window
|
10
|
+
@selection = self.class::SELECTION
|
11
|
+
# puts "INNITING #{config_file_path}"
|
12
|
+
@font = Gosu::Font.new(20)
|
13
|
+
# @x = width
|
14
|
+
@y = current_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 = self.class::NAME
|
21
|
+
@value = ConfigSetting.get_setting(@config_file_path, @name, @selection[0])
|
22
|
+
@fullscreen_height = fullscreen_height
|
23
|
+
@button_id_mapping = self.class.get_id_button_mapping
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_id_button_mapping
|
27
|
+
{
|
28
|
+
next: lambda { |setting, id| setting.next_clicked }
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_values
|
33
|
+
# puts "GETTING DIFFICULTY: #{@value}"
|
34
|
+
if @value
|
35
|
+
@value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw
|
40
|
+
@font.draw("<", @next_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
41
|
+
@font.draw(@value, ((@max_width / 2) - @font.text_width(@value) / 2), @y, 1, 1.0, 1.0, 0xff_ffff00)
|
42
|
+
@font.draw(">", @prev_x, @y, 1, 1.0, 1.0, 0xff_ffff00)
|
43
|
+
end
|
44
|
+
|
45
|
+
def update mouse_x, mouse_y
|
46
|
+
return @value
|
47
|
+
end
|
48
|
+
|
49
|
+
# required for LUIT objects, passes id of element
|
50
|
+
def onClick element_id
|
51
|
+
# puts "ONCLICK mappuing"
|
52
|
+
puts @button_id_mapping
|
53
|
+
button_clicked_exists = @button_id_mapping.key?(element_id)
|
54
|
+
if button_clicked_exists
|
55
|
+
@button_id_mapping[element_id].call(self, element_id)
|
56
|
+
else
|
57
|
+
puts "Clicked button that is not mapped: #{element_id}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def previous_clicked
|
62
|
+
index = @selection.index(@value)
|
63
|
+
value = @value
|
64
|
+
if index == 0
|
65
|
+
value = @selection[@selection.count - 1]
|
66
|
+
else
|
67
|
+
value = @selection[index - 1]
|
68
|
+
end
|
69
|
+
ConfigSetting.set_setting(@config_file_path, @name, value)
|
70
|
+
@value = value
|
71
|
+
end
|
72
|
+
|
73
|
+
def next_clicked
|
74
|
+
index = @selection.index(@value)
|
75
|
+
value = @value
|
76
|
+
if index == @selection.count - 1
|
77
|
+
value = @selection[0]
|
78
|
+
else
|
79
|
+
value = @selection[index + 1]
|
80
|
+
end
|
81
|
+
ConfigSetting.set_setting(@config_file_path, @name, value)
|
82
|
+
@value = value
|
83
|
+
end
|
84
|
+
|
85
|
+
# Deprecating, using Liut
|
86
|
+
def clicked mx, my
|
87
|
+
if is_mouse_hovering_next(mx, my)
|
88
|
+
previous_clicked
|
89
|
+
elsif is_mouse_hovering_prev(mx, my)
|
90
|
+
next_clicked
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def is_mouse_hovering_next mx, my
|
95
|
+
local_width = @font.text_width('>')
|
96
|
+
local_height = @font.height
|
97
|
+
|
98
|
+
(mx >= @next_x and my >= @y) and (mx <= @next_x + local_width) and (my <= @y + local_height)
|
99
|
+
end
|
100
|
+
|
101
|
+
def is_mouse_hovering_prev mx, my
|
102
|
+
local_width = @font.text_width('<')
|
103
|
+
local_height = @font.height
|
104
|
+
|
105
|
+
(mx >= @prev_x and my >= @y) and (mx <= @prev_x + local_width) and (my <= @y + local_height)
|
106
|
+
end
|
107
|
+
|
4
108
|
end
|