dxopal 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/DEVELOPMENT.md +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +22 -24
- data/README.md +4 -0
- data/Rakefile +6 -1
- data/build/dxopal.js +48950 -38847
- data/build/dxopal.min.js +1 -1
- data/config.ru +1 -1
- data/doc/api/DXOpal/Constants/Colors.html +4 -4
- data/doc/api/DXOpal/Constants.html +4 -4
- data/doc/api/DXOpal/Font.html +4 -4
- data/doc/api/DXOpal/Image.html +19 -19
- data/doc/api/DXOpal/Input/KeyCodes.html +6 -6
- data/doc/api/DXOpal/Input/MouseCodes.html +4 -4
- data/doc/api/DXOpal/Input/Touch.html +47 -47
- data/doc/api/DXOpal/Input.html +87 -81
- data/doc/api/DXOpal/RemoteResource.html +164 -33
- data/doc/api/DXOpal/Sound.html +22 -16
- data/doc/api/DXOpal/SoundEffect/WaveTypes.html +4 -4
- data/doc/api/DXOpal/SoundEffect.html +6 -6
- data/doc/api/DXOpal/Sprite/CollisionArea/Base.html +5 -5
- data/doc/api/DXOpal/Sprite/CollisionArea/Circle.html +4 -4
- data/doc/api/DXOpal/Sprite/CollisionArea/Point.html +4 -4
- data/doc/api/DXOpal/Sprite/CollisionArea/Rect.html +4 -4
- data/doc/api/DXOpal/Sprite/CollisionArea/Triangle.html +4 -4
- data/doc/api/DXOpal/Sprite/CollisionArea.html +4 -4
- data/doc/api/DXOpal/Sprite/CollisionCheck/ClassMethods.html +7 -7
- data/doc/api/DXOpal/Sprite/CollisionCheck.html +8 -8
- data/doc/api/DXOpal/Sprite/Physics.html +4 -4
- data/doc/api/DXOpal/Sprite.html +10 -10
- data/doc/api/DXOpal/Window.html +120 -114
- data/doc/api/DXOpal.html +5 -5
- data/doc/api/Kernel.html +4 -4
- data/doc/api/_index.html +5 -5
- data/doc/api/file.README.html +23 -20
- data/doc/api/frames.html +10 -5
- data/doc/api/index.html +23 -20
- data/doc/api/method_list.html +214 -206
- data/doc/api/top-level-namespace.html +4 -4
- data/lib/dxopal/input.rb +5 -2
- data/lib/dxopal/remote_resource.rb +33 -1
- data/lib/dxopal/sound.rb +5 -2
- data/lib/dxopal/version.rb +1 -1
- data/lib/dxopal/window.rb +6 -3
- data/lib/dxopal.rb +1 -0
- metadata +3 -3
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.36
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -241,9 +241,9 @@
|
|
241
241
|
</div>
|
242
242
|
|
243
243
|
<div id="footer">
|
244
|
-
Generated on Tue
|
245
|
-
<a href="
|
246
|
-
0.9.
|
244
|
+
Generated on Tue Jul 9 22:42:33 2024 by
|
245
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
246
|
+
0.9.36 (ruby-3.2.2).
|
247
247
|
</div>
|
248
248
|
|
249
249
|
</div>
|
data/lib/dxopal/input.rb
CHANGED
@@ -93,7 +93,7 @@ module DXOpal
|
|
93
93
|
# stolen by DXOpal.) If canvas element is set to this, only key events
|
94
94
|
# happend on canvas are processed by DXOpal.
|
95
95
|
def self.keyevent_target=(target)
|
96
|
-
if
|
96
|
+
if keyevent_target
|
97
97
|
%x{
|
98
98
|
#{@@keyevent_target}.removeEventListener('keydown', #{ON_KEYDOWN_});
|
99
99
|
#{@@keyevent_target}.removeEventListener('keyup', #{ON_KEYUP_});
|
@@ -110,7 +110,10 @@ module DXOpal
|
|
110
110
|
end
|
111
111
|
|
112
112
|
# Return DOM element set by `keyevent_target=`
|
113
|
-
def self.keyevent_target
|
113
|
+
def self.keyevent_target
|
114
|
+
return nil unless class_variable_defined?(:@@keyevent_target)
|
115
|
+
@@keyevent_target
|
116
|
+
end
|
114
117
|
|
115
118
|
#
|
116
119
|
# Mouse
|
@@ -11,6 +11,8 @@ module DXOpal
|
|
11
11
|
@@promises = Hash.new{|h,k| h[k] = {}}
|
12
12
|
# Contains instances of Image, Sound
|
13
13
|
@@instances = Hash.new{|h,k| h[k] = {}}
|
14
|
+
# `true` if the resource is loaded
|
15
|
+
@@loaded = Hash.new{|h,k| h[k] = {}}
|
14
16
|
|
15
17
|
# Subclasses of RemoteResource
|
16
18
|
@@klasses = {}
|
@@ -41,7 +43,11 @@ module DXOpal
|
|
41
43
|
if !@@promises[klass_name][name]
|
42
44
|
instance, promise = klass._load(*args, &block2)
|
43
45
|
@@instances[klass_name][name] = instance
|
44
|
-
@@
|
46
|
+
@@loaded[klass_name][name] = false
|
47
|
+
@@promises[klass_name][name] = promise.JS.then{
|
48
|
+
@@loaded[klass_name][name] = true
|
49
|
+
RemoteResource._update_loading_status
|
50
|
+
}
|
45
51
|
end
|
46
52
|
end
|
47
53
|
end
|
@@ -63,5 +69,31 @@ module DXOpal
|
|
63
69
|
def self._klass_name
|
64
70
|
return self.name.split(/::/).last
|
65
71
|
end
|
72
|
+
|
73
|
+
# Update loading status if `dxopal-loading` is defined.
|
74
|
+
def self._update_loading_status
|
75
|
+
done = true
|
76
|
+
report = "DXOpal loading...\n" +
|
77
|
+
@@promises.map{|klass_name, promises|
|
78
|
+
n_total = @@resources[klass_name].count
|
79
|
+
n_loaded = @@loaded[klass_name].values.count(true)
|
80
|
+
done = false if n_loaded < n_total
|
81
|
+
"#{klass_name}: #{n_loaded}/#{n_total}\n"
|
82
|
+
}.join
|
83
|
+
div = `document.getElementById('dxopal-loading')`
|
84
|
+
if `div`
|
85
|
+
%x{
|
86
|
+
let pre = div.firstChild;
|
87
|
+
if (!pre) {
|
88
|
+
pre = document.createElement('pre');
|
89
|
+
div.appendChild(pre);
|
90
|
+
}
|
91
|
+
pre.textContent = #{report};
|
92
|
+
if (#{done}) {
|
93
|
+
div.style.display = 'none';
|
94
|
+
}
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
66
98
|
end
|
67
99
|
end
|
data/lib/dxopal/sound.rb
CHANGED
@@ -38,14 +38,17 @@ module DXOpal
|
|
38
38
|
end
|
39
39
|
attr_accessor :decoded
|
40
40
|
|
41
|
-
# Play this sound
|
42
|
-
def play
|
41
|
+
# Play this sound
|
42
|
+
def play(loop_ = false)
|
43
43
|
raise "Sound #{path_or_url} is not loaded yet" unless @decoded
|
44
44
|
source = nil
|
45
45
|
%x{
|
46
46
|
var context = #{Sound.audio_context};
|
47
47
|
source = context.createBufferSource();
|
48
48
|
source.buffer = #{@decoded};
|
49
|
+
if (#{loop_}) {
|
50
|
+
source.loop = true;
|
51
|
+
}
|
49
52
|
source.connect(context.destination);
|
50
53
|
source.start(0);
|
51
54
|
}
|
data/lib/dxopal/version.rb
CHANGED
data/lib/dxopal/window.rb
CHANGED
@@ -29,7 +29,8 @@ module DXOpal
|
|
29
29
|
already_running = !!@@block
|
30
30
|
@@block = block
|
31
31
|
return if already_running
|
32
|
-
|
32
|
+
self_ = self
|
33
|
+
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
|
33
34
|
end
|
34
35
|
|
35
36
|
# (DXOpal original) Pause & resume
|
@@ -61,7 +62,8 @@ module DXOpal
|
|
61
62
|
if @@fps_ct >= frame_msec
|
62
63
|
@@fps_ct -= frame_msec
|
63
64
|
else
|
64
|
-
|
65
|
+
self_ = self
|
66
|
+
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
|
65
67
|
return
|
66
68
|
end
|
67
69
|
|
@@ -110,7 +112,8 @@ module DXOpal
|
|
110
112
|
end
|
111
113
|
end
|
112
114
|
|
113
|
-
|
115
|
+
self_ = self
|
116
|
+
`window`.JS.requestAnimationFrame{|time| self_._loop(time) }
|
114
117
|
end
|
115
118
|
|
116
119
|
def self._init
|
data/lib/dxopal.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dxopal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yutaka HARA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
- !ruby/object:Gem::Version
|
146
146
|
version: '0'
|
147
147
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
148
|
+
rubygems_version: 3.4.10
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: Game development framework for Opal
|