cyberarm_engine 0.25.0 → 0.30.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 (118) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -8
  3. data/.rubocop.yml +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +6 -6
  6. data/Gemfile.lock +37 -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/assets/textures/ui/circle.png +0 -0
  17. data/assets/textures/ui/circle_small.png +0 -0
  18. data/assets/textures/ui/rounded.png +0 -0
  19. data/assets/textures/ui/rounded_bottom.png +0 -0
  20. data/assets/textures/ui/rounded_left.png +0 -0
  21. data/assets/textures/ui/rounded_left_bottom.png +0 -0
  22. data/assets/textures/ui/rounded_left_top.png +0 -0
  23. data/assets/textures/ui/rounded_right.png +0 -0
  24. data/assets/textures/ui/rounded_right_bottom.png +0 -0
  25. data/assets/textures/ui/rounded_right_top.png +0 -0
  26. data/assets/textures/ui/rounded_small.png +0 -0
  27. data/assets/textures/ui/rounded_tiny.png +0 -0
  28. data/assets/textures/ui/rounded_top.png +0 -0
  29. data/assets/textures/ui/square.png +0 -0
  30. data/bin/console +14 -14
  31. data/bin/setup +8 -8
  32. data/cyberarm_engine.gemspec +35 -36
  33. data/lib/cyberarm_engine/animator.rb +219 -219
  34. data/lib/cyberarm_engine/background.rb +156 -158
  35. data/lib/cyberarm_engine/background_image.rb +93 -93
  36. data/lib/cyberarm_engine/background_nine_slice.rb +182 -142
  37. data/lib/cyberarm_engine/bounding_box.rb +150 -150
  38. data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
  39. data/lib/cyberarm_engine/cache/download_manager.rb +123 -123
  40. data/lib/cyberarm_engine/cache.rb +4 -4
  41. data/lib/cyberarm_engine/common.rb +133 -131
  42. data/lib/cyberarm_engine/config_file.rb +46 -46
  43. data/lib/cyberarm_engine/console/command.rb +157 -157
  44. data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
  45. data/lib/cyberarm_engine/console/subcommand.rb +99 -99
  46. data/lib/cyberarm_engine/console.rb +248 -248
  47. data/lib/cyberarm_engine/event_bus.rb +39 -0
  48. data/lib/cyberarm_engine/game_object.rb +244 -244
  49. data/lib/cyberarm_engine/game_state.rb +134 -124
  50. data/lib/cyberarm_engine/gosu_ext/draw_arc.rb +111 -111
  51. data/lib/cyberarm_engine/gosu_ext/draw_circle.rb +30 -30
  52. data/lib/cyberarm_engine/gosu_ext/draw_path.rb +17 -17
  53. data/lib/cyberarm_engine/model/material.rb +21 -21
  54. data/lib/cyberarm_engine/model/mesh.rb +131 -131
  55. data/lib/cyberarm_engine/model/parser.rb +74 -74
  56. data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
  57. data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
  58. data/lib/cyberarm_engine/model.rb +216 -216
  59. data/lib/cyberarm_engine/model_cache.rb +31 -31
  60. data/lib/cyberarm_engine/notification.rb +82 -82
  61. data/lib/cyberarm_engine/notification_manager.rb +241 -241
  62. data/lib/cyberarm_engine/opengl/light.rb +52 -52
  63. data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
  64. data/lib/cyberarm_engine/opengl/perspective_camera.rb +41 -41
  65. data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
  66. data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +167 -167
  67. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +307 -307
  68. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +33 -33
  69. data/lib/cyberarm_engine/opengl/shader.rb +408 -408
  70. data/lib/cyberarm_engine/opengl/texture.rb +69 -69
  71. data/lib/cyberarm_engine/opengl.rb +53 -53
  72. data/lib/cyberarm_engine/pathfinding/graph.rb +64 -0
  73. data/lib/cyberarm_engine/pathfinding/graph_search.rb +6 -0
  74. data/lib/cyberarm_engine/pathfinding/graph_searches/astar_search.rb +6 -0
  75. data/lib/cyberarm_engine/pathfinding/graph_searches/breadth_first_search.rb +27 -0
  76. data/lib/cyberarm_engine/pathfinding/graph_searches/dijkstra_search.rb +6 -0
  77. data/lib/cyberarm_engine/pathfinding/graphs/grid.rb +52 -0
  78. data/lib/cyberarm_engine/ray.rb +56 -56
  79. data/lib/cyberarm_engine/result.rb +19 -0
  80. data/lib/cyberarm_engine/stats.rb +200 -200
  81. data/lib/cyberarm_engine/text.rb +288 -260
  82. data/lib/cyberarm_engine/timer.rb +27 -23
  83. data/lib/cyberarm_engine/transform.rb +296 -296
  84. data/lib/cyberarm_engine/trees/aabb_node.rb +126 -126
  85. data/lib/cyberarm_engine/trees/aabb_tree.rb +55 -55
  86. data/lib/cyberarm_engine/trees/aabb_tree_debug.rb +29 -29
  87. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  88. data/lib/cyberarm_engine/ui/dialog.rb +24 -0
  89. data/lib/cyberarm_engine/ui/dsl.rb +170 -142
  90. data/lib/cyberarm_engine/ui/element.rb +664 -662
  91. data/lib/cyberarm_engine/ui/elements/button.rb +99 -100
  92. data/lib/cyberarm_engine/ui/elements/check_box.rb +58 -54
  93. data/lib/cyberarm_engine/ui/elements/container.rb +413 -407
  94. data/lib/cyberarm_engine/ui/elements/edit_box.rb +200 -179
  95. data/lib/cyberarm_engine/ui/elements/edit_line.rb +299 -297
  96. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  97. data/lib/cyberarm_engine/ui/elements/image.rb +78 -72
  98. data/lib/cyberarm_engine/ui/elements/list_box.rb +79 -79
  99. data/lib/cyberarm_engine/ui/elements/menu.rb +27 -27
  100. data/lib/cyberarm_engine/ui/elements/menu_item.rb +6 -6
  101. data/lib/cyberarm_engine/ui/elements/progress.rb +95 -93
  102. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  103. data/lib/cyberarm_engine/ui/elements/slider.rb +111 -107
  104. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  105. data/lib/cyberarm_engine/ui/elements/text_block.rb +236 -222
  106. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +71 -67
  107. data/lib/cyberarm_engine/ui/elements/widget.rb +45 -0
  108. data/lib/cyberarm_engine/ui/event.rb +54 -54
  109. data/lib/cyberarm_engine/ui/gui_state.rb +402 -326
  110. data/lib/cyberarm_engine/ui/page.rb +39 -0
  111. data/lib/cyberarm_engine/ui/style.rb +94 -61
  112. data/lib/cyberarm_engine/ui/theme.rb +237 -225
  113. data/lib/cyberarm_engine/vector.rb +312 -312
  114. data/lib/cyberarm_engine/version.rb +4 -4
  115. data/lib/cyberarm_engine/window.rb +234 -195
  116. data/lib/cyberarm_engine.rb +88 -76
  117. data/mrbgem.rake +29 -29
  118. metadata +30 -5
@@ -1,124 +1,134 @@
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, :timers
7
+
8
+ def initialize(options = {})
9
+ @options = options
10
+ @game_objects = []
11
+ @timers = []
12
+ @global_pause = false
13
+ window.text_input = nil unless options[:preserve_text_input]
14
+
15
+ @down_keys = {}
16
+ end
17
+
18
+ def setup
19
+ end
20
+
21
+ # Called immediately after setup returns.
22
+ # GuiState uses this to set current_theme for ToolTip
23
+ def post_setup
24
+ end
25
+
26
+ def draw
27
+ @game_objects.each(&:draw)
28
+ end
29
+
30
+ def update
31
+ @game_objects.each(&:update)
32
+ @timers.each(&:update)
33
+ @timers.delete_if(&:dead?)
34
+ end
35
+
36
+ def fixed_update(dt)
37
+ end
38
+
39
+ def needs_redraw?
40
+ true
41
+ end
42
+
43
+ def needs_repaint?
44
+ true
45
+ end
46
+
47
+ def drop(filename)
48
+ end
49
+
50
+ def gamepad_connected(index)
51
+ end
52
+
53
+ def gamepad_disconnected(index)
54
+ end
55
+
56
+ def gain_focus
57
+ end
58
+
59
+ def lose_focus
60
+ end
61
+
62
+ def button_down(id)
63
+ @down_keys[id] = true
64
+
65
+ @game_objects.each do |o|
66
+ o.button_down(id)
67
+ end
68
+ end
69
+
70
+ def button_up(id)
71
+ @down_keys.delete(id)
72
+
73
+ @game_objects.each do |o|
74
+ o.button_up(id)
75
+ end
76
+ end
77
+
78
+ def close
79
+ window.close!
80
+ end
81
+
82
+ def draw_bounding_box(box)
83
+ x = box.x
84
+ y = box.y
85
+ max_x = box.max_x
86
+ max_y = box.max_y
87
+
88
+ color = Gosu::Color.rgba(255, 127, 64, 240)
89
+
90
+ # pipe = 4
91
+ # Gosu.draw_rect(x-width, y-height, x+(width*2), y+(height*2), color, Float::INFINITY)
92
+ # puts "BB render: #{x}:#{y} w:#{x.abs+width} h:#{y.abs+height}"
93
+ # Gosu.draw_rect(x, y, x.abs+width, y.abs+height, color, Float::INFINITY)
94
+
95
+ # TOP LEFT to BOTTOM LEFT
96
+ Gosu.draw_line(
97
+ x, y, color,
98
+ x, max_y, color,
99
+ Float::INFINITY
100
+ )
101
+ # BOTTOM LEFT to BOTTOM RIGHT
102
+ Gosu.draw_line(
103
+ x, max_y, color,
104
+ max_x, max_y, color,
105
+ Float::INFINITY
106
+ )
107
+ # BOTTOM RIGHT to TOP RIGHT
108
+ Gosu.draw_line(
109
+ max_x, max_y, color,
110
+ max_x, y, color,
111
+ Float::INFINITY
112
+ )
113
+ # TOP RIGHT to TOP LEFT
114
+ Gosu.draw_line(
115
+ max_x, y, color,
116
+ x, y, color,
117
+ Float::INFINITY
118
+ )
119
+ end
120
+
121
+ def destroy
122
+ @options.clear
123
+ @game_objects.clear
124
+ end
125
+
126
+ def add_game_object(object)
127
+ @game_objects << object
128
+ end
129
+
130
+ def add_timer(timer)
131
+ @timers << timer
132
+ end
133
+ end
134
+ end
@@ -1,111 +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
- 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
+ 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