cyberarm_engine 0.24.4 → 0.24.5
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.
- checksums.yaml +4 -4
- data/.gitignore +8 -8
- data/.rubocop.yml +7 -7
- data/.travis.yml +5 -5
- data/Gemfile +6 -6
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +21 -21
- data/README.md +74 -74
- data/Rakefile +10 -10
- data/assets/shaders/fragment/g_buffer.glsl +30 -30
- data/assets/shaders/fragment/lighting.glsl +115 -69
- data/assets/shaders/include/light_struct.glsl +11 -11
- data/assets/shaders/include/material_struct.glsl +16 -16
- data/assets/shaders/vertex/g_buffer.glsl +28 -28
- data/assets/shaders/vertex/lighting.glsl +24 -24
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/cyberarm_engine.gemspec +36 -36
- data/lib/cyberarm_engine/animator.rb +219 -219
- data/lib/cyberarm_engine/background.rb +180 -179
- data/lib/cyberarm_engine/background_image.rb +93 -93
- data/lib/cyberarm_engine/background_nine_slice.rb +142 -142
- data/lib/cyberarm_engine/bounding_box.rb +150 -150
- data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
- data/lib/cyberarm_engine/cache/download_manager.rb +123 -123
- data/lib/cyberarm_engine/cache.rb +4 -4
- data/lib/cyberarm_engine/common.rb +128 -128
- data/lib/cyberarm_engine/config_file.rb +46 -46
- data/lib/cyberarm_engine/console/command.rb +157 -157
- data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
- data/lib/cyberarm_engine/console/subcommand.rb +99 -99
- data/lib/cyberarm_engine/console.rb +248 -248
- data/lib/cyberarm_engine/game_object.rb +244 -244
- data/lib/cyberarm_engine/game_state.rb +124 -124
- data/lib/cyberarm_engine/gosu_ext/draw_arc.rb +97 -97
- data/lib/cyberarm_engine/gosu_ext/draw_circle.rb +30 -30
- data/lib/cyberarm_engine/gosu_ext/draw_path.rb +17 -17
- data/lib/cyberarm_engine/model/material.rb +21 -21
- data/lib/cyberarm_engine/model/{model_object.rb → mesh.rb} +131 -131
- data/lib/cyberarm_engine/model/parser.rb +74 -74
- data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
- data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
- data/lib/cyberarm_engine/model.rb +216 -213
- data/lib/cyberarm_engine/model_cache.rb +31 -31
- data/lib/cyberarm_engine/notification.rb +82 -82
- data/lib/cyberarm_engine/notification_manager.rb +241 -241
- data/lib/cyberarm_engine/opengl/light.rb +52 -50
- data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
- data/lib/cyberarm_engine/opengl/perspective_camera.rb +41 -38
- data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
- data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +167 -165
- data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +307 -304
- data/lib/cyberarm_engine/opengl/renderer/renderer.rb +33 -33
- data/lib/cyberarm_engine/opengl/shader.rb +408 -406
- data/lib/cyberarm_engine/opengl/texture.rb +69 -69
- data/lib/cyberarm_engine/opengl.rb +53 -40
- data/lib/cyberarm_engine/ray.rb +56 -56
- data/lib/cyberarm_engine/stats.rb +200 -200
- data/lib/cyberarm_engine/text.rb +260 -260
- data/lib/cyberarm_engine/timer.rb +23 -23
- data/lib/cyberarm_engine/transform.rb +296 -296
- data/lib/cyberarm_engine/trees/aabb_node.rb +126 -0
- data/lib/cyberarm_engine/trees/aabb_tree.rb +55 -0
- data/lib/cyberarm_engine/trees/aabb_tree_debug.rb +29 -0
- data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
- data/lib/cyberarm_engine/ui/dsl.rb +142 -142
- data/lib/cyberarm_engine/ui/element.rb +662 -662
- data/lib/cyberarm_engine/ui/elements/button.rb +100 -100
- data/lib/cyberarm_engine/ui/elements/check_box.rb +54 -54
- data/lib/cyberarm_engine/ui/elements/container.rb +404 -404
- data/lib/cyberarm_engine/ui/elements/edit_box.rb +179 -179
- data/lib/cyberarm_engine/ui/elements/edit_line.rb +297 -297
- data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
- data/lib/cyberarm_engine/ui/elements/image.rb +72 -72
- data/lib/cyberarm_engine/ui/elements/list_box.rb +79 -79
- data/lib/cyberarm_engine/ui/elements/menu.rb +27 -27
- data/lib/cyberarm_engine/ui/elements/menu_item.rb +6 -6
- data/lib/cyberarm_engine/ui/elements/progress.rb +93 -93
- data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
- data/lib/cyberarm_engine/ui/elements/slider.rb +107 -107
- data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
- data/lib/cyberarm_engine/ui/elements/text_block.rb +216 -216
- data/lib/cyberarm_engine/ui/elements/toggle_button.rb +67 -67
- data/lib/cyberarm_engine/ui/event.rb +54 -54
- data/lib/cyberarm_engine/ui/gui_state.rb +321 -321
- data/lib/cyberarm_engine/ui/style.rb +50 -50
- data/lib/cyberarm_engine/ui/theme.rb +225 -225
- data/lib/cyberarm_engine/vector.rb +312 -312
- data/lib/cyberarm_engine/version.rb +4 -4
- data/lib/cyberarm_engine/window.rb +195 -195
- data/lib/cyberarm_engine.rb +70 -78
- data/mrbgem.rake +29 -29
- metadata +8 -7
@@ -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,98 @@
|
|
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
|
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
98
|
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
|