cyberarm_engine 0.25.0 → 0.25.1

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +8 -8
  3. data/.rubocop.yml +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +6 -6
  6. data/Gemfile.lock +25 -25
  7. data/LICENSE.txt +21 -21
  8. data/README.md +74 -74
  9. data/Rakefile +10 -10
  10. data/assets/shaders/fragment/g_buffer.glsl +30 -30
  11. data/assets/shaders/fragment/lighting.glsl +115 -115
  12. data/assets/shaders/include/light_struct.glsl +11 -11
  13. data/assets/shaders/include/material_struct.glsl +16 -16
  14. data/assets/shaders/vertex/g_buffer.glsl +28 -28
  15. data/assets/shaders/vertex/lighting.glsl +24 -24
  16. data/bin/console +14 -14
  17. data/bin/setup +8 -8
  18. data/cyberarm_engine.gemspec +36 -36
  19. data/lib/cyberarm_engine/animator.rb +219 -219
  20. data/lib/cyberarm_engine/background.rb +158 -158
  21. data/lib/cyberarm_engine/background_image.rb +93 -93
  22. data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
  23. data/lib/cyberarm_engine/bounding_box.rb +150 -150
  24. data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
  25. data/lib/cyberarm_engine/cache/download_manager.rb +123 -123
  26. data/lib/cyberarm_engine/cache.rb +4 -4
  27. data/lib/cyberarm_engine/common.rb +131 -131
  28. data/lib/cyberarm_engine/config_file.rb +46 -46
  29. data/lib/cyberarm_engine/console/command.rb +157 -157
  30. data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
  31. data/lib/cyberarm_engine/console/subcommand.rb +99 -99
  32. data/lib/cyberarm_engine/console.rb +248 -248
  33. data/lib/cyberarm_engine/game_object.rb +244 -244
  34. data/lib/cyberarm_engine/game_state.rb +124 -124
  35. data/lib/cyberarm_engine/gosu_ext/draw_arc.rb +111 -111
  36. data/lib/cyberarm_engine/gosu_ext/draw_circle.rb +30 -30
  37. data/lib/cyberarm_engine/gosu_ext/draw_path.rb +17 -17
  38. data/lib/cyberarm_engine/model/material.rb +21 -21
  39. data/lib/cyberarm_engine/model/mesh.rb +131 -131
  40. data/lib/cyberarm_engine/model/parser.rb +74 -74
  41. data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
  42. data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
  43. data/lib/cyberarm_engine/model.rb +216 -216
  44. data/lib/cyberarm_engine/model_cache.rb +31 -31
  45. data/lib/cyberarm_engine/notification.rb +82 -82
  46. data/lib/cyberarm_engine/notification_manager.rb +241 -241
  47. data/lib/cyberarm_engine/opengl/light.rb +52 -52
  48. data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
  49. data/lib/cyberarm_engine/opengl/perspective_camera.rb +41 -41
  50. data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
  51. data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +167 -167
  52. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +307 -307
  53. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +33 -33
  54. data/lib/cyberarm_engine/opengl/shader.rb +408 -408
  55. data/lib/cyberarm_engine/opengl/texture.rb +69 -69
  56. data/lib/cyberarm_engine/opengl.rb +53 -53
  57. data/lib/cyberarm_engine/ray.rb +56 -56
  58. data/lib/cyberarm_engine/result.rb +20 -0
  59. data/lib/cyberarm_engine/stats.rb +200 -200
  60. data/lib/cyberarm_engine/text.rb +260 -260
  61. data/lib/cyberarm_engine/timer.rb +23 -23
  62. data/lib/cyberarm_engine/transform.rb +296 -296
  63. data/lib/cyberarm_engine/trees/aabb_node.rb +126 -126
  64. data/lib/cyberarm_engine/trees/aabb_tree.rb +55 -55
  65. data/lib/cyberarm_engine/trees/aabb_tree_debug.rb +29 -29
  66. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  67. data/lib/cyberarm_engine/ui/dsl.rb +142 -142
  68. data/lib/cyberarm_engine/ui/element.rb +662 -662
  69. data/lib/cyberarm_engine/ui/elements/button.rb +100 -100
  70. data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
  71. data/lib/cyberarm_engine/ui/elements/container.rb +407 -407
  72. data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
  73. data/lib/cyberarm_engine/ui/elements/edit_line.rb +297 -297
  74. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  75. data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
  76. data/lib/cyberarm_engine/ui/elements/list_box.rb +79 -79
  77. data/lib/cyberarm_engine/ui/elements/menu.rb +27 -27
  78. data/lib/cyberarm_engine/ui/elements/menu_item.rb +6 -6
  79. data/lib/cyberarm_engine/ui/elements/progress.rb +93 -93
  80. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  81. data/lib/cyberarm_engine/ui/elements/slider.rb +107 -107
  82. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  83. data/lib/cyberarm_engine/ui/elements/text_block.rb +222 -222
  84. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +67 -67
  85. data/lib/cyberarm_engine/ui/event.rb +54 -54
  86. data/lib/cyberarm_engine/ui/gui_state.rb +326 -326
  87. data/lib/cyberarm_engine/ui/style.rb +61 -61
  88. data/lib/cyberarm_engine/ui/theme.rb +225 -225
  89. data/lib/cyberarm_engine/vector.rb +312 -312
  90. data/lib/cyberarm_engine/version.rb +4 -4
  91. data/lib/cyberarm_engine/window.rb +195 -195
  92. data/lib/cyberarm_engine.rb +77 -76
  93. data/mrbgem.rake +29 -29
  94. metadata +4 -3
@@ -1,158 +1,158 @@
1
- module CyberarmEngine
2
- class Background
3
- attr_accessor :x, :y, :z, :width, :height, :angle, :debug
4
- attr_reader :background
5
-
6
- def initialize(x: 0, y: 0, z: 0, width: 0, height: 0, background: Gosu::Color::BLACK, angle: 0, debug: false)
7
- @x = x
8
- @y = y
9
- @z = z
10
- @width = width
11
- @height = height
12
- @debug = debug
13
-
14
- @paint = Paint.new(background)
15
- @angle = angle
16
-
17
- @top_left = Vector.new(@x, @y)
18
- @top_right = Vector.new(@x + @width, @y)
19
- @bottom_left = Vector.new(@x, @y + @height)
20
- @bottom_right = Vector.new(@x + @width, @y + @height)
21
- end
22
-
23
- def draw
24
- Gosu.clip_to(@x, @y, @width, @height) do
25
- Gosu.draw_quad(
26
- @top_left.x, @top_left.y, @paint.top_left,
27
- @top_right.x, @top_right.y, @paint.top_right,
28
- @bottom_right.x, @bottom_right.y, @paint.bottom_right,
29
- @bottom_left.x, @bottom_left.y, @paint.bottom_left,
30
- @z
31
- )
32
- end
33
-
34
- debug_outline if @debug
35
- end
36
-
37
- def update
38
- @top_left.x = @x
39
- @top_left.y = @y
40
- @top_right.x = @x + @width
41
- @top_right.y = @y
42
- @bottom_left.x = @x
43
- @bottom_left.y = @y + @height
44
- @bottom_right.x = @x + @width
45
- @bottom_right.y = @y + @height
46
- end
47
-
48
- def shortest_distance(point, la, lb)
49
- a = la.x - lb.x
50
- b = la.y - lb.y
51
- c = Gosu.distance(la.x, la.y, lb.x, lb.y)
52
- p a, b, c
53
- d = (a * point.x + b * point.y + c).abs / Math.sqrt(a * a + b * b)
54
- puts "Distance: #{d}"
55
- exit!
56
- d
57
- end
58
-
59
- def debug_outline
60
- # Top
61
- Gosu.draw_line(
62
- @x, @y, Gosu::Color::RED,
63
- @x + @width, @y, Gosu::Color::RED,
64
- @z
65
- )
66
-
67
- # Right
68
- Gosu.draw_line(
69
- @x + @width, @y, Gosu::Color::RED,
70
- @x + @width, @y + @height, Gosu::Color::RED,
71
- @z
72
- )
73
-
74
- # Bottom
75
- Gosu.draw_line(
76
- @x + @width, @y + @height, Gosu::Color::RED,
77
- @x, @y + @height, Gosu::Color::RED,
78
- @z
79
- )
80
-
81
- # Left
82
- Gosu.draw_line(
83
- @x, @y + @height, Gosu::Color::RED,
84
- @x, @y, Gosu::Color::RED,
85
- @z
86
- )
87
- end
88
-
89
- def background=(_background)
90
- @paint.set(_background)
91
- update
92
- end
93
-
94
- def angle=(n)
95
- @angle = n
96
- update
97
- end
98
- end
99
-
100
- class Paint
101
- attr_accessor :top_left, :top_right, :bottom_left, :bottom_right
102
-
103
- def initialize(background)
104
- set(background)
105
- end
106
-
107
- def set(background)
108
- @background = background
109
-
110
- if background.is_a?(Numeric)
111
- @top_left = background
112
- @top_right = background
113
- @bottom_left = background
114
- @bottom_right = background
115
- elsif background.is_a?(Gosu::Color)
116
- @top_left = background
117
- @top_right = background
118
- @bottom_left = background
119
- @bottom_right = background
120
- elsif background.is_a?(Array)
121
- if background.size == 1
122
- set(background.first)
123
- elsif background.size == 2
124
- @top_left = background.first
125
- @top_right = background.last
126
- @bottom_left = background.first
127
- @bottom_right = background.last
128
- elsif background.size == 4
129
- @top_left = background[0]
130
- @top_right = background[1]
131
- @bottom_left = background[2]
132
- @bottom_right = background[3]
133
- else
134
- raise ArgumentError, "background array was empty or had wrong number of elements (expected 2 or 4 elements)"
135
- end
136
- elsif background.is_a?(Hash)
137
- @top_left = background[:top_left]
138
- @top_right = background[:top_right]
139
- @bottom_left = background[:bottom_left]
140
- @bottom_right = background[:bottom_right]
141
- elsif background.is_a?(Range)
142
- set([background.begin, background.begin, background.end, background.end])
143
- else
144
- raise ArgumentError, "background '#{background.inspect}' of type '#{background.class}' was not able to be processed"
145
- end
146
- end
147
- end
148
- end
149
-
150
- # Add <=> method to support Range based gradients
151
- # NOTE: Disabled, causes stack overflow 🙃
152
- # module Gosu
153
- # class Color
154
- # def <=>(_other)
155
- # self
156
- # end
157
- # end
158
- # end
1
+ module CyberarmEngine
2
+ class Background
3
+ attr_accessor :x, :y, :z, :width, :height, :angle, :debug
4
+ attr_reader :background
5
+
6
+ def initialize(x: 0, y: 0, z: 0, width: 0, height: 0, background: Gosu::Color::BLACK, angle: 0, debug: false)
7
+ @x = x
8
+ @y = y
9
+ @z = z
10
+ @width = width
11
+ @height = height
12
+ @debug = debug
13
+
14
+ @paint = Paint.new(background)
15
+ @angle = angle
16
+
17
+ @top_left = Vector.new(@x, @y)
18
+ @top_right = Vector.new(@x + @width, @y)
19
+ @bottom_left = Vector.new(@x, @y + @height)
20
+ @bottom_right = Vector.new(@x + @width, @y + @height)
21
+ end
22
+
23
+ def draw
24
+ Gosu.clip_to(@x, @y, @width, @height) do
25
+ Gosu.draw_quad(
26
+ @top_left.x, @top_left.y, @paint.top_left,
27
+ @top_right.x, @top_right.y, @paint.top_right,
28
+ @bottom_right.x, @bottom_right.y, @paint.bottom_right,
29
+ @bottom_left.x, @bottom_left.y, @paint.bottom_left,
30
+ @z
31
+ )
32
+ end
33
+
34
+ debug_outline if @debug
35
+ end
36
+
37
+ def update
38
+ @top_left.x = @x
39
+ @top_left.y = @y
40
+ @top_right.x = @x + @width
41
+ @top_right.y = @y
42
+ @bottom_left.x = @x
43
+ @bottom_left.y = @y + @height
44
+ @bottom_right.x = @x + @width
45
+ @bottom_right.y = @y + @height
46
+ end
47
+
48
+ def shortest_distance(point, la, lb)
49
+ a = la.x - lb.x
50
+ b = la.y - lb.y
51
+ c = Gosu.distance(la.x, la.y, lb.x, lb.y)
52
+ p a, b, c
53
+ d = (a * point.x + b * point.y + c).abs / Math.sqrt(a * a + b * b)
54
+ puts "Distance: #{d}"
55
+ exit!
56
+ d
57
+ end
58
+
59
+ def debug_outline
60
+ # Top
61
+ Gosu.draw_line(
62
+ @x, @y, Gosu::Color::RED,
63
+ @x + @width, @y, Gosu::Color::RED,
64
+ @z
65
+ )
66
+
67
+ # Right
68
+ Gosu.draw_line(
69
+ @x + @width, @y, Gosu::Color::RED,
70
+ @x + @width, @y + @height, Gosu::Color::RED,
71
+ @z
72
+ )
73
+
74
+ # Bottom
75
+ Gosu.draw_line(
76
+ @x + @width, @y + @height, Gosu::Color::RED,
77
+ @x, @y + @height, Gosu::Color::RED,
78
+ @z
79
+ )
80
+
81
+ # Left
82
+ Gosu.draw_line(
83
+ @x, @y + @height, Gosu::Color::RED,
84
+ @x, @y, Gosu::Color::RED,
85
+ @z
86
+ )
87
+ end
88
+
89
+ def background=(_background)
90
+ @paint.set(_background)
91
+ update
92
+ end
93
+
94
+ def angle=(n)
95
+ @angle = n
96
+ update
97
+ end
98
+ end
99
+
100
+ class Paint
101
+ attr_accessor :top_left, :top_right, :bottom_left, :bottom_right
102
+
103
+ def initialize(background)
104
+ set(background)
105
+ end
106
+
107
+ def set(background)
108
+ @background = background
109
+
110
+ if background.is_a?(Numeric)
111
+ @top_left = background
112
+ @top_right = background
113
+ @bottom_left = background
114
+ @bottom_right = background
115
+ elsif background.is_a?(Gosu::Color)
116
+ @top_left = background
117
+ @top_right = background
118
+ @bottom_left = background
119
+ @bottom_right = background
120
+ elsif background.is_a?(Array)
121
+ if background.size == 1
122
+ set(background.first)
123
+ elsif background.size == 2
124
+ @top_left = background.first
125
+ @top_right = background.last
126
+ @bottom_left = background.first
127
+ @bottom_right = background.last
128
+ elsif background.size == 4
129
+ @top_left = background[0]
130
+ @top_right = background[1]
131
+ @bottom_left = background[2]
132
+ @bottom_right = background[3]
133
+ else
134
+ raise ArgumentError, "background array was empty or had wrong number of elements (expected 2 or 4 elements)"
135
+ end
136
+ elsif background.is_a?(Hash)
137
+ @top_left = background[:top_left]
138
+ @top_right = background[:top_right]
139
+ @bottom_left = background[:bottom_left]
140
+ @bottom_right = background[:bottom_right]
141
+ elsif background.is_a?(Range)
142
+ set([background.begin, background.begin, background.end, background.end])
143
+ else
144
+ raise ArgumentError, "background '#{background.inspect}' of type '#{background.class}' was not able to be processed"
145
+ end
146
+ end
147
+ end
148
+ end
149
+
150
+ # Add <=> method to support Range based gradients
151
+ # NOTE: Disabled, causes stack overflow 🙃
152
+ # module Gosu
153
+ # class Color
154
+ # def <=>(_other)
155
+ # self
156
+ # end
157
+ # end
158
+ # end
@@ -1,93 +1,93 @@
1
- module CyberarmEngine
2
- class BackgroundImage
3
- include CyberarmEngine::Common
4
- attr_accessor :x, :y, :z, :mode
5
- attr_reader :image, :width, :height, :color
6
-
7
- def initialize(image_path: nil, x: 0, y: 0, z: 0, width: 0, height: 0, mode: :fill, color: Gosu::Color::WHITE)
8
- @image_path = image_path
9
- @image = get_image(image_path) if image_path
10
-
11
- @x = x
12
- @y = y
13
- @z = z
14
- @width = width
15
- @height = height
16
-
17
- @mode = mode
18
-
19
- @color = color
20
-
21
- @cached_tiling = nil
22
- end
23
-
24
- def image=(image_path)
25
- @cached_tiling = nil if image_path != @image_path
26
- @image_path = image_path
27
- @image = image_path ? get_image(image_path) : image_path
28
- end
29
-
30
- def width=(n)
31
- @cached_tiling = nil if @width != n
32
- @width = n
33
- end
34
-
35
- def height=(n)
36
- @cached_tiling = nil if @height != n
37
- @height = n
38
- end
39
-
40
- def color=(c)
41
- @cached_tiling = nil if @color != c
42
- @color = c
43
- end
44
-
45
- def width_scale
46
- (@width.to_f / @image.width).abs
47
- end
48
-
49
- def height_scale
50
- (@height.to_f / @image.height).abs
51
- end
52
-
53
- def draw
54
- return unless @image
55
-
56
- Gosu.clip_to(@x, @y, @width, @height) do
57
- send(:"draw_#{mode}")
58
- end
59
- end
60
-
61
- def draw_stretch
62
- @image.draw(@x, @y, @z, width_scale, height_scale, @color)
63
- end
64
-
65
- def draw_tiled
66
- @cached_tiling ||= Gosu.record(@width, @height) do
67
- height_scale.ceil.times do |y|
68
- width_scale.ceil.times do |x|
69
- @image.draw(x * @image.width, y * @image.height, @z, 1, 1, @color)
70
- end
71
- end
72
- end
73
-
74
- @cached_tiling.draw(@x, @y, @z)
75
- end
76
-
77
- def draw_fill
78
- if (@image.width * width_scale) >= @width && (@image.height * width_scale) >= @height
79
- draw_fill_width
80
- else
81
- draw_fill_height
82
- end
83
- end
84
-
85
- def draw_fill_width
86
- @image.draw(@x, @y, @z, width_scale, width_scale, @color)
87
- end
88
-
89
- def draw_fill_height
90
- @image.draw(@x, @y, @z, height_scale, height_scale, @color)
91
- end
92
- end
93
- end
1
+ module CyberarmEngine
2
+ class BackgroundImage
3
+ include CyberarmEngine::Common
4
+ attr_accessor :x, :y, :z, :mode
5
+ attr_reader :image, :width, :height, :color
6
+
7
+ def initialize(image_path: nil, x: 0, y: 0, z: 0, width: 0, height: 0, mode: :fill, color: Gosu::Color::WHITE)
8
+ @image_path = image_path
9
+ @image = get_image(image_path) if image_path
10
+
11
+ @x = x
12
+ @y = y
13
+ @z = z
14
+ @width = width
15
+ @height = height
16
+
17
+ @mode = mode
18
+
19
+ @color = color
20
+
21
+ @cached_tiling = nil
22
+ end
23
+
24
+ def image=(image_path)
25
+ @cached_tiling = nil if image_path != @image_path
26
+ @image_path = image_path
27
+ @image = image_path ? get_image(image_path) : image_path
28
+ end
29
+
30
+ def width=(n)
31
+ @cached_tiling = nil if @width != n
32
+ @width = n
33
+ end
34
+
35
+ def height=(n)
36
+ @cached_tiling = nil if @height != n
37
+ @height = n
38
+ end
39
+
40
+ def color=(c)
41
+ @cached_tiling = nil if @color != c
42
+ @color = c
43
+ end
44
+
45
+ def width_scale
46
+ (@width.to_f / @image.width).abs
47
+ end
48
+
49
+ def height_scale
50
+ (@height.to_f / @image.height).abs
51
+ end
52
+
53
+ def draw
54
+ return unless @image
55
+
56
+ Gosu.clip_to(@x, @y, @width, @height) do
57
+ send(:"draw_#{mode}")
58
+ end
59
+ end
60
+
61
+ def draw_stretch
62
+ @image.draw(@x, @y, @z, width_scale, height_scale, @color)
63
+ end
64
+
65
+ def draw_tiled
66
+ @cached_tiling ||= Gosu.record(@width, @height) do
67
+ height_scale.ceil.times do |y|
68
+ width_scale.ceil.times do |x|
69
+ @image.draw(x * @image.width, y * @image.height, @z, 1, 1, @color)
70
+ end
71
+ end
72
+ end
73
+
74
+ @cached_tiling.draw(@x, @y, @z)
75
+ end
76
+
77
+ def draw_fill
78
+ if (@image.width * width_scale) >= @width && (@image.height * width_scale) >= @height
79
+ draw_fill_width
80
+ else
81
+ draw_fill_height
82
+ end
83
+ end
84
+
85
+ def draw_fill_width
86
+ @image.draw(@x, @y, @z, width_scale, width_scale, @color)
87
+ end
88
+
89
+ def draw_fill_height
90
+ @image.draw(@x, @y, @z, height_scale, height_scale, @color)
91
+ end
92
+ end
93
+ end