cyberarm_engine 0.24.5 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) 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 -24
  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 -180
  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 -128
  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 -98
  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/stats.rb +200 -200
  59. data/lib/cyberarm_engine/text.rb +260 -260
  60. data/lib/cyberarm_engine/timer.rb +23 -23
  61. data/lib/cyberarm_engine/transform.rb +296 -296
  62. data/lib/cyberarm_engine/trees/aabb_node.rb +126 -126
  63. data/lib/cyberarm_engine/trees/aabb_tree.rb +55 -55
  64. data/lib/cyberarm_engine/trees/aabb_tree_debug.rb +29 -29
  65. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  66. data/lib/cyberarm_engine/ui/dsl.rb +142 -142
  67. data/lib/cyberarm_engine/ui/element.rb +662 -662
  68. data/lib/cyberarm_engine/ui/elements/button.rb +100 -100
  69. data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
  70. data/lib/cyberarm_engine/ui/elements/container.rb +407 -404
  71. data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
  72. data/lib/cyberarm_engine/ui/elements/edit_line.rb +297 -297
  73. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  74. data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
  75. data/lib/cyberarm_engine/ui/elements/list_box.rb +79 -79
  76. data/lib/cyberarm_engine/ui/elements/menu.rb +27 -27
  77. data/lib/cyberarm_engine/ui/elements/menu_item.rb +6 -6
  78. data/lib/cyberarm_engine/ui/elements/progress.rb +93 -93
  79. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  80. data/lib/cyberarm_engine/ui/elements/slider.rb +107 -107
  81. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  82. data/lib/cyberarm_engine/ui/elements/text_block.rb +222 -216
  83. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +67 -67
  84. data/lib/cyberarm_engine/ui/event.rb +54 -54
  85. data/lib/cyberarm_engine/ui/gui_state.rb +326 -321
  86. data/lib/cyberarm_engine/ui/style.rb +61 -50
  87. data/lib/cyberarm_engine/ui/theme.rb +225 -225
  88. data/lib/cyberarm_engine/vector.rb +312 -312
  89. data/lib/cyberarm_engine/version.rb +4 -4
  90. data/lib/cyberarm_engine/window.rb +195 -195
  91. data/lib/cyberarm_engine.rb +76 -70
  92. data/mrbgem.rake +29 -29
  93. metadata +3 -3
@@ -1,124 +1,124 @@
1
- module CyberarmEngine
2
- class GameState
3
- include Common
4
-
5
- attr_accessor :options, :global_pause
6
- attr_reader :game_objects
7
-
8
- def initialize(options = {})
9
- @options = options
10
- @game_objects = []
11
- @global_pause = false
12
- window.text_input = nil unless options[:preserve_text_input]
13
-
14
- @down_keys = {}
15
- end
16
-
17
- def setup
18
- end
19
-
20
- # Called immediately after setup returns.
21
- # GuiState uses this to set current_theme for ToolTip
22
- def post_setup
23
- end
24
-
25
- def draw
26
- @game_objects.each(&:draw)
27
- end
28
-
29
- def update
30
- @game_objects.each(&:update)
31
- end
32
-
33
- def needs_redraw?
34
- true
35
- end
36
-
37
- def needs_repaint?
38
- true
39
- end
40
-
41
- def drop(filename)
42
- end
43
-
44
- def gamepad_connected(index)
45
- end
46
-
47
- def gamepad_disconnected(index)
48
- end
49
-
50
- def gain_focus
51
- end
52
-
53
- def lose_focus
54
- end
55
-
56
- def button_down(id)
57
- @down_keys[id] = true
58
-
59
- @game_objects.each do |o|
60
- o.button_down(id)
61
- end
62
- end
63
-
64
- def button_up(id)
65
- @down_keys.delete(id)
66
-
67
- @game_objects.each do |o|
68
- o.button_up(id)
69
- end
70
- end
71
-
72
- def close
73
- window.close!
74
- end
75
-
76
- def draw_bounding_box(box)
77
- x = box.x
78
- y = box.y
79
- max_x = box.max_x
80
- max_y = box.max_y
81
-
82
- color = Gosu::Color.rgba(255, 127, 64, 240)
83
-
84
- # pipe = 4
85
- # Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
86
- # puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
87
- # Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)
88
-
89
- # TOP LEFT to BOTTOM LEFT
90
- Gosu.draw_line(
91
- x, y, color,
92
- x, max_y, color,
93
- Float::INFINITY
94
- )
95
- # BOTTOM LEFT to BOTTOM RIGHT
96
- Gosu.draw_line(
97
- x, max_y, color,
98
- max_x, max_y, color,
99
- Float::INFINITY
100
- )
101
- # BOTTOM RIGHT to TOP RIGHT
102
- Gosu.draw_line(
103
- max_x, max_y, color,
104
- max_x, y, color,
105
- Float::INFINITY
106
- )
107
- # TOP RIGHT to TOP LEFT
108
- Gosu.draw_line(
109
- max_x, y, color,
110
- x, y, color,
111
- Float::INFINITY
112
- )
113
- end
114
-
115
- def destroy
116
- @options.clear
117
- @game_objects.clear
118
- end
119
-
120
- def add_game_object(object)
121
- @game_objects << object
122
- end
123
- end
124
- end
1
+ module CyberarmEngine
2
+ class GameState
3
+ include Common
4
+
5
+ attr_accessor :options, :global_pause
6
+ attr_reader :game_objects
7
+
8
+ def initialize(options = {})
9
+ @options = options
10
+ @game_objects = []
11
+ @global_pause = false
12
+ window.text_input = nil unless options[:preserve_text_input]
13
+
14
+ @down_keys = {}
15
+ end
16
+
17
+ def setup
18
+ end
19
+
20
+ # Called immediately after setup returns.
21
+ # GuiState uses this to set current_theme for ToolTip
22
+ def post_setup
23
+ end
24
+
25
+ def draw
26
+ @game_objects.each(&:draw)
27
+ end
28
+
29
+ def update
30
+ @game_objects.each(&:update)
31
+ end
32
+
33
+ def needs_redraw?
34
+ true
35
+ end
36
+
37
+ def needs_repaint?
38
+ true
39
+ end
40
+
41
+ def drop(filename)
42
+ end
43
+
44
+ def gamepad_connected(index)
45
+ end
46
+
47
+ def gamepad_disconnected(index)
48
+ end
49
+
50
+ def gain_focus
51
+ end
52
+
53
+ def lose_focus
54
+ end
55
+
56
+ def button_down(id)
57
+ @down_keys[id] = true
58
+
59
+ @game_objects.each do |o|
60
+ o.button_down(id)
61
+ end
62
+ end
63
+
64
+ def button_up(id)
65
+ @down_keys.delete(id)
66
+
67
+ @game_objects.each do |o|
68
+ o.button_up(id)
69
+ end
70
+ end
71
+
72
+ def close
73
+ window.close!
74
+ end
75
+
76
+ def draw_bounding_box(box)
77
+ x = box.x
78
+ y = box.y
79
+ max_x = box.max_x
80
+ max_y = box.max_y
81
+
82
+ color = Gosu::Color.rgba(255, 127, 64, 240)
83
+
84
+ # pipe = 4
85
+ # Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
86
+ # puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
87
+ # Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)
88
+
89
+ # TOP LEFT to BOTTOM LEFT
90
+ Gosu.draw_line(
91
+ x, y, color,
92
+ x, max_y, color,
93
+ Float::INFINITY
94
+ )
95
+ # BOTTOM LEFT to BOTTOM RIGHT
96
+ Gosu.draw_line(
97
+ x, max_y, color,
98
+ max_x, max_y, color,
99
+ Float::INFINITY
100
+ )
101
+ # BOTTOM RIGHT to TOP RIGHT
102
+ Gosu.draw_line(
103
+ max_x, max_y, color,
104
+ max_x, y, color,
105
+ Float::INFINITY
106
+ )
107
+ # TOP RIGHT to TOP LEFT
108
+ Gosu.draw_line(
109
+ max_x, y, color,
110
+ x, y, color,
111
+ Float::INFINITY
112
+ )
113
+ end
114
+
115
+ def destroy
116
+ @options.clear
117
+ @game_objects.clear
118
+ end
119
+
120
+ def add_game_object(object)
121
+ @game_objects << object
122
+ end
123
+ end
124
+ end
@@ -1,98 +1,111 @@
1
- module Gosu
2
- # Draw an arc around the point x and y.
3
- #
4
- # Color accepts the following: *Gosu::Color*, *Array* (with 2 colors), or a *Hash* with keys: _from:_ and _to:_ both colors.
5
- #
6
- # With a *Gosu::Color* the arc will be painted with color
7
- #
8
- # With an *Array* the first *Gosu::Color* with be the innermost color and the last *Gosu::Color* with be the outermost color
9
- #
10
- # With a *Hash* the arc will smoothly transition from the start of the arc to the end
11
- # @example
12
- # # Using a Hash
13
- # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, {from: Gosu::Color::BLUE, to: Gosu::Color::GREEN}, 0, :default)
14
- #
15
- # # Using an Array
16
- # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, [Gosu::Color::BLUE, Gosu::Color::GREEN], 0, :default)
17
- #
18
- # # Using a Gosu::Color
19
- # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, Gosu::Color::BLUE, 0, :default)
20
- #
21
- #
22
- # @param x X position.
23
- # @param y Y position.
24
- # @param radius radius of arc, in pixels.
25
- # @param percentage how complete the segment is, _0.0_ is 0% and _1.0_ is 100%.
26
- # @param segments how many segments for arc, more will appear smoother, less will appear jagged.
27
- # @param thickness how thick arc will be.
28
- # @param color [Gosu::Color, Array<Gosu::Color, Gosu::Color>, Hash{from: start_color, to: end_color}] color or colors to draw the arc with.
29
- # @param z Z position.
30
- # @param mode blend mode.
31
- #
32
- # @note _thickness_ is subtracted from radius, meaning that the arc will grow towards the origin, not away from it.
33
- #
34
- # @return [void]
35
- def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default)
36
- segments = 360.0 / segments
37
-
38
- return if percentage == 0.0
39
-
40
- 0.step((359 * percentage), percentage > 0 ? segments : -segments) do |angle|
41
- angle2 = angle + segments
42
-
43
- point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
44
- point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
45
-
46
- point_a_right_x = x + Gosu.offset_x(angle2, radius - thickness)
47
- point_a_right_y = y + Gosu.offset_y(angle2, radius - thickness)
48
-
49
- point_b_left_x = x + Gosu.offset_x(angle, radius)
50
- point_b_left_y = y + Gosu.offset_y(angle, radius)
51
-
52
- point_b_right_x = x + Gosu.offset_x(angle2, radius)
53
- point_b_right_y = y + Gosu.offset_y(angle2, radius)
54
-
55
- if color.is_a?(Array)
56
- Gosu.draw_quad(
57
- point_a_left_x, point_a_left_y, color.first,
58
- point_b_left_x, point_b_left_y, color.last,
59
- point_a_right_x, point_a_right_y, color.first,
60
- point_b_right_x, point_b_right_y, color.last,
61
- z, mode
62
- )
63
- elsif color.is_a?(Hash)
64
- start_color = color[:from]
65
- end_color = color[:to]
66
-
67
- color_a = Gosu::Color.rgba(
68
- (end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
69
- (end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
70
- (end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
71
- (end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
72
- )
73
- color_b = Gosu::Color.rgba(
74
- (end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
75
- (end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
76
- (end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
77
- (end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
78
- )
79
-
80
- Gosu.draw_quad(
81
- point_a_left_x, point_a_left_y, color_a,
82
- point_b_left_x, point_b_left_y, color_a,
83
- point_a_right_x, point_a_right_y, color_b,
84
- point_b_right_x, point_b_right_y, color_b,
85
- z, mode
86
- )
87
- else
88
- Gosu.draw_quad(
89
- point_a_left_x, point_a_left_y, color,
90
- point_b_left_x, point_b_left_y, color,
91
- point_a_right_x, point_a_right_y, color,
92
- point_b_right_x, point_b_right_y, color,
93
- z, mode
94
- )
95
- end
96
- end
97
- end
98
- end
1
+ module Gosu
2
+ # Draw an arc around the point x and y.
3
+ #
4
+ # Color accepts the following: *Gosu::Color*, *Array* (with 2 colors), or a *Hash* with keys: _from:_ and _to:_ both colors.
5
+ #
6
+ # With a *Gosu::Color* the arc will be painted with color
7
+ #
8
+ # With an *Array* the first *Gosu::Color* with be the innermost color and the last *Gosu::Color* with be the outermost color
9
+ #
10
+ # With a *Hash* the arc will smoothly transition from the start of the arc to the end
11
+ # @example
12
+ # # Using a Hash
13
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, {from: Gosu::Color::BLUE, to: Gosu::Color::GREEN}, 0, :default)
14
+ #
15
+ # # Using an Array
16
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, [Gosu::Color::BLUE, Gosu::Color::GREEN], 0, :default)
17
+ #
18
+ # # Using a Gosu::Color
19
+ # Gosu.draw_arc(100, 100, 50, 0.5, 128, 4, Gosu::Color::BLUE, 0, :default)
20
+ #
21
+ #
22
+ # @param x X position.
23
+ # @param y Y position.
24
+ # @param radius radius of arc, in pixels.
25
+ # @param percentage how complete the segment is, _0.0_ is 0% and _1.0_ is 100%.
26
+ # @param segments how many segments for arc, more will appear smoother, less will appear jagged.
27
+ # @param thickness how thick arc will be.
28
+ # @param color [Gosu::Color, Array<Gosu::Color, Gosu::Color>, Hash{from: start_color, to: end_color}] color or colors to draw the arc with.
29
+ # @param z Z position.
30
+ # @param mode blend mode.
31
+ #
32
+ # @note _thickness_ is subtracted from radius, meaning that the arc will grow towards the origin, not away from it.
33
+ #
34
+ # @return [void]
35
+ def self.draw_arc(x, y, radius, percentage = 1.0, segments = 128, thickness = 4, color = Gosu::Color::WHITE, z = 0, mode = :default)
36
+ return if percentage == 0.0
37
+
38
+ angle_per_segment = 360.0 / segments
39
+ arc_completion = 360 * percentage
40
+ next_segment_angle = angle_per_segment
41
+
42
+ angle = 0
43
+ loop do
44
+ break if angle >= arc_completion
45
+
46
+ if angle + angle_per_segment > arc_completion
47
+ next_segment_angle = arc_completion - angle
48
+ else
49
+ next_segment_angle = angle_per_segment
50
+ end
51
+
52
+ angle2 = angle + next_segment_angle
53
+
54
+ point_a_left_x = x + Gosu.offset_x(angle, radius - thickness)
55
+ point_a_left_y = y + Gosu.offset_y(angle, radius - thickness)
56
+
57
+ point_a_right_x = x + Gosu.offset_x(angle2, radius - thickness)
58
+ point_a_right_y = y + Gosu.offset_y(angle2, radius - thickness)
59
+
60
+ point_b_left_x = x + Gosu.offset_x(angle, radius)
61
+ point_b_left_y = y + Gosu.offset_y(angle, radius)
62
+
63
+ point_b_right_x = x + Gosu.offset_x(angle2, radius)
64
+ point_b_right_y = y + Gosu.offset_y(angle2, radius)
65
+
66
+ if color.is_a?(Array)
67
+ Gosu.draw_quad(
68
+ point_a_left_x, point_a_left_y, color.first,
69
+ point_b_left_x, point_b_left_y, color.last,
70
+ point_a_right_x, point_a_right_y, color.first,
71
+ point_b_right_x, point_b_right_y, color.last,
72
+ z, mode
73
+ )
74
+ elsif color.is_a?(Hash)
75
+ start_color = color[:from]
76
+ end_color = color[:to]
77
+
78
+ color_a = Gosu::Color.rgba(
79
+ (end_color.red - start_color.red) * (angle / 360.0) + start_color.red,
80
+ (end_color.green - start_color.green) * (angle / 360.0) + start_color.green,
81
+ (end_color.blue - start_color.blue) * (angle / 360.0) + start_color.blue,
82
+ (end_color.alpha - start_color.alpha) * (angle / 360.0) + start_color.alpha,
83
+ )
84
+ color_b = Gosu::Color.rgba(
85
+ (end_color.red - start_color.red) * (angle2 / 360.0) + start_color.red,
86
+ (end_color.green - start_color.green) * (angle2 / 360.0) + start_color.green,
87
+ (end_color.blue - start_color.blue) * (angle2 / 360.0) + start_color.blue,
88
+ (end_color.alpha - start_color.alpha) * (angle2 / 360.0) + start_color.alpha,
89
+ )
90
+
91
+ Gosu.draw_quad(
92
+ point_a_left_x, point_a_left_y, color_a,
93
+ point_b_left_x, point_b_left_y, color_a,
94
+ point_a_right_x, point_a_right_y, color_b,
95
+ point_b_right_x, point_b_right_y, color_b,
96
+ z, mode
97
+ )
98
+ else
99
+ Gosu.draw_quad(
100
+ point_a_left_x, point_a_left_y, color,
101
+ point_b_left_x, point_b_left_y, color,
102
+ point_a_right_x, point_a_right_y, color,
103
+ point_b_right_x, point_b_right_y, color,
104
+ z, mode
105
+ )
106
+ end
107
+
108
+ angle += next_segment_angle
109
+ end
110
+ end
111
+ end
@@ -1,31 +1,31 @@
1
- module Gosu
2
- ##
3
- # Draw a filled circled around point X and Y.
4
- #
5
- # @param x X position.
6
- # @param y Y position.
7
- # @param radius radius of circle, in pixels.
8
- # @param step_size resolution of circle, more steps will apear smoother, less will appear jagged.
9
- # @param color color to draw circle with.
10
- # @param mode blend mode.
11
- #
12
- # @return [void]
13
- def self.draw_circle(x, y, radius, step_size = 36, color = Gosu::Color::WHITE, z = 0, mode = :default)
14
- step_size = (360.0 / step_size).floor
15
-
16
- 0.step(359, step_size) do |angle|
17
- angle2 = angle + step_size
18
-
19
- point_lx = x + Gosu.offset_x(angle, radius)
20
- point_ly = y + Gosu.offset_y(angle, radius)
21
- point_rx = x + Gosu.offset_x(angle2, radius)
22
- point_ry = y + Gosu.offset_y(angle2, radius)
23
-
24
- Gosu.draw_triangle(
25
- point_lx, point_ly, color,
26
- point_rx, point_ry, color,
27
- x, y, color, z, mode
28
- )
29
- end
30
- end
1
+ module Gosu
2
+ ##
3
+ # Draw a filled circled around point X and Y.
4
+ #
5
+ # @param x X position.
6
+ # @param y Y position.
7
+ # @param radius radius of circle, in pixels.
8
+ # @param step_size resolution of circle, more steps will apear smoother, less will appear jagged.
9
+ # @param color color to draw circle with.
10
+ # @param mode blend mode.
11
+ #
12
+ # @return [void]
13
+ def self.draw_circle(x, y, radius, step_size = 36, color = Gosu::Color::WHITE, z = 0, mode = :default)
14
+ step_size = (360.0 / step_size).floor
15
+
16
+ 0.step(359, step_size) do |angle|
17
+ angle2 = angle + step_size
18
+
19
+ point_lx = x + Gosu.offset_x(angle, radius)
20
+ point_ly = y + Gosu.offset_y(angle, radius)
21
+ point_rx = x + Gosu.offset_x(angle2, radius)
22
+ point_ry = y + Gosu.offset_y(angle2, radius)
23
+
24
+ Gosu.draw_triangle(
25
+ point_lx, point_ly, color,
26
+ point_rx, point_ry, color,
27
+ x, y, color, z, mode
28
+ )
29
+ end
30
+ end
31
31
  end
@@ -1,17 +1,17 @@
1
- module Gosu
2
- PathNode = Struct.new(:x, :y)
3
-
4
- def self.draw_path(nodes, color = Gosu::Color::WHITE, z = 0, mode = :default)
5
- last_node = nodes.first
6
-
7
- nodes[1..nodes.size - 1].each do |current_node|
8
- Gosu.draw_line(
9
- last_node.x, last_node.y, color,
10
- current_node.x, current_node.y, color,
11
- z, mode
12
- )
13
-
14
- last_node = current_node
15
- end
16
- end
17
- end
1
+ module Gosu
2
+ PathNode = Struct.new(:x, :y)
3
+
4
+ def self.draw_path(nodes, color = Gosu::Color::WHITE, z = 0, mode = :default)
5
+ last_node = nodes.first
6
+
7
+ nodes[1..nodes.size - 1].each do |current_node|
8
+ Gosu.draw_line(
9
+ last_node.x, last_node.y, color,
10
+ current_node.x, current_node.y, color,
11
+ z, mode
12
+ )
13
+
14
+ last_node = current_node
15
+ end
16
+ end
17
+ end
@@ -1,21 +1,21 @@
1
- module CyberarmEngine
2
- class Model
3
- class Material
4
- attr_accessor :name, :ambient, :diffuse, :specular
5
- attr_reader :texture_id
6
-
7
- def initialize(name)
8
- @name = name
9
- @ambient = Color.new(1, 1, 1, 1)
10
- @diffuse = Color.new(1, 1, 1, 1)
11
- @specular = Color.new(1, 1, 1, 1)
12
- @texture = nil
13
- @texture_id = nil
14
- end
15
-
16
- def set_texture(texture_path)
17
- @texture_id = Texture.new(path: texture_path).id
18
- end
19
- end
20
- end
21
- end
1
+ module CyberarmEngine
2
+ class Model
3
+ class Material
4
+ attr_accessor :name, :ambient, :diffuse, :specular
5
+ attr_reader :texture_id
6
+
7
+ def initialize(name)
8
+ @name = name
9
+ @ambient = Color.new(1, 1, 1, 1)
10
+ @diffuse = Color.new(1, 1, 1, 1)
11
+ @specular = Color.new(1, 1, 1, 1)
12
+ @texture = nil
13
+ @texture_id = nil
14
+ end
15
+
16
+ def set_texture(texture_path)
17
+ @texture_id = Texture.new(path: texture_path).id
18
+ end
19
+ end
20
+ end
21
+ end