dxopal 1.5.1 → 1.6.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/DEVELOPMENT.md +4 -4
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +23 -25
  6. data/README.md +7 -3
  7. data/Rakefile +8 -15
  8. data/build/dxopal.js +57670 -40007
  9. data/build/dxopal.min.js +1 -1
  10. data/config.ru +1 -1
  11. data/doc/api/DXOpal/Constants/Colors.html +172 -0
  12. data/doc/api/DXOpal/Constants.html +115 -0
  13. data/doc/api/DXOpal/Font.html +72 -18
  14. data/doc/api/DXOpal/Image.html +902 -409
  15. data/doc/api/DXOpal/Input/KeyCodes.html +986 -0
  16. data/doc/api/DXOpal/Input/MouseCodes.html +8 -8
  17. data/doc/api/DXOpal/Input/Touch.html +834 -0
  18. data/doc/api/DXOpal/Input.html +833 -104
  19. data/doc/api/DXOpal/RemoteResource.html +170 -41
  20. data/doc/api/DXOpal/Sound.html +33 -27
  21. data/doc/api/DXOpal/SoundEffect/WaveTypes.html +8 -8
  22. data/doc/api/DXOpal/SoundEffect.html +13 -15
  23. data/doc/api/DXOpal/Sprite/CollisionArea/Base.html +649 -0
  24. data/doc/api/DXOpal/Sprite/CollisionArea/Circle.html +656 -0
  25. data/doc/api/DXOpal/Sprite/CollisionArea/Point.html +448 -0
  26. data/doc/api/DXOpal/Sprite/CollisionArea/Rect.html +549 -0
  27. data/doc/api/DXOpal/Sprite/CollisionArea/Triangle.html +423 -0
  28. data/doc/api/DXOpal/Sprite/CollisionArea.html +126 -0
  29. data/doc/api/DXOpal/Sprite/CollisionCheck/ClassMethods.html +268 -0
  30. data/doc/api/DXOpal/Sprite/CollisionCheck.html +926 -0
  31. data/doc/api/DXOpal/Sprite/Physics.html +426 -0
  32. data/doc/api/DXOpal/Sprite.html +522 -45
  33. data/doc/api/DXOpal/Window.html +245 -156
  34. data/doc/api/DXOpal.html +11 -11
  35. data/doc/api/Kernel.html +131 -0
  36. data/doc/api/_index.html +277 -5
  37. data/doc/api/class_list.html +1 -1
  38. data/doc/api/css/style.css +1 -0
  39. data/doc/api/file.README.html +23 -22
  40. data/doc/api/frames.html +10 -5
  41. data/doc/api/index.html +23 -22
  42. data/doc/api/method_list.html +1608 -0
  43. data/doc/api/top-level-namespace.html +155 -4
  44. data/lib/dxopal/input.rb +9 -4
  45. data/lib/dxopal/remote_resource.rb +33 -1
  46. data/lib/dxopal/sound.rb +5 -2
  47. data/lib/dxopal/version.rb +1 -1
  48. data/lib/dxopal/window.rb +6 -3
  49. data/lib/dxopal.rb +1 -0
  50. metadata +21 -8
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.24
9
+ &mdash; Documentation by YARD 0.9.36
10
10
 
11
11
  </title>
12
12
 
@@ -78,21 +78,172 @@
78
78
 
79
79
  </div>
80
80
 
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="DXOpal.html" title="DXOpal (module)">DXOpal</a></span>, <span class='object_link'><a href="Kernel.html" title="Kernel (module)">Kernel</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <h2>
100
+ Instance Method Summary
101
+ <small><a href="#" class="summary_toggle">collapse</a></small>
102
+ </h2>
103
+
104
+ <ul class="summary">
105
+
106
+ <li class="public ">
107
+ <span class="summary_signature">
108
+
109
+ <a href="top-level-namespace.html#require-instance_method" title="#require (instance method)">#<strong>require</strong>(*args) &#x21d2; Object </a>
110
+
111
+
112
+
113
+ </span>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <span class="summary_desc"><div class='inline'></div></span>
124
+
125
+ </li>
126
+
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="top-level-namespace.html#require_remote-instance_method" title="#require_remote (instance method)">#<strong>require_remote</strong>(url) &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'></div></span>
146
+
147
+ </li>
148
+
149
+
150
+ </ul>
151
+
81
152
 
82
153
 
83
154
 
155
+ <div id="instance_method_details" class="method_details_list">
156
+ <h2>Instance Method Details</h2>
157
+
158
+
159
+ <div class="method_details first">
160
+ <h3 class="signature first" id="require-instance_method">
161
+
162
+ #<strong>require</strong>(*args) &#x21d2; <tt>Object</tt>
163
+
84
164
 
165
+
85
166
 
167
+
168
+ </h3><table class="source_code">
169
+ <tr>
170
+ <td>
171
+ <pre class="lines">
86
172
 
87
173
 
174
+ 24
175
+ 25
176
+ 26
177
+ 27
178
+ 28
179
+ 29
180
+ 30</pre>
181
+ </td>
182
+ <td>
183
+ <pre class="code"><span class="info file"># File 'lib/dxopal/patches/require_dxopal.rb', line 24</span>
88
184
 
185
+ <span class='kw'>def</span> <span class='id identifier rubyid_require'>require</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
186
+ <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span> <span class='op'>==</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>dxopal</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span>
187
+ <span class='comment'># Do nothing, because DXOpal is already loaded and you don&#39;t need to find it
188
+ </span> <span class='kw'>else</span>
189
+ <span class='id identifier rubyid_dxopal_orig_require'>dxopal_orig_require</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
190
+ <span class='kw'>end</span>
191
+ <span class='kw'>end</span></pre>
192
+ </td>
193
+ </tr>
194
+ </table>
195
+ </div>
196
+
197
+ <div class="method_details ">
198
+ <h3 class="signature " id="require_remote-instance_method">
199
+
200
+ #<strong>require_remote</strong>(url) &#x21d2; <tt>Object</tt>
201
+
202
+
203
+
204
+
205
+
206
+ </h3><table class="source_code">
207
+ <tr>
208
+ <td>
209
+ <pre class="lines">
210
+
211
+
212
+ 2
213
+ 3
214
+ 4
215
+ 5
216
+ 6
217
+ 7
218
+ 8
219
+ 9
220
+ 10</pre>
221
+ </td>
222
+ <td>
223
+ <pre class="code"><span class="info file"># File 'lib/dxopal/patches/require_remote.rb', line 2</span>
224
+
225
+ <span class='kw'>def</span> <span class='id identifier rubyid_require_remote'>require_remote</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
226
+ <span class='backtick'>%x{</span><span class='tstring_content'>
227
+ var r = new XMLHttpRequest();
228
+ r.overrideMimeType(&quot;text/plain&quot;); // https://github.com/yhara/dxopal/issues/12
229
+ r.open(&quot;GET&quot;, url, false);
230
+ r.send(&#39;&#39;);
231
+ </span><span class='tstring_end'>}</span></span>
232
+ <span class='id identifier rubyid_eval'>eval</span> <span class='backtick'>`</span><span class='tstring_content'>r.responseText</span><span class='tstring_end'>`</span></span>
233
+ <span class='kw'>end</span></pre>
234
+ </td>
235
+ </tr>
236
+ </table>
237
+ </div>
238
+
239
+ </div>
89
240
 
90
241
  </div>
91
242
 
92
243
  <div id="footer">
93
- Generated on Sat Feb 1 01:00:35 2020 by
94
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
95
- 0.9.24 (ruby-2.5.5).
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).
96
247
  </div>
97
248
 
98
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 @@keyevent_target
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; @@keyevent_target; end
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
@@ -135,9 +138,11 @@ module DXOpal
135
138
  document.addEventListener('mouseup', function(ev){
136
139
  #{@@mouse_info}.x = ev.pageX - #{@@canvas_x};
137
140
  #{@@mouse_info}.y = ev.pageY - #{@@canvas_y};
141
+ // ev.button => ev.buttons
142
+ table = { 0: 1, 1: 4, 2: 2, 3: 8, 4: 16 };
138
143
  for (var k=1; k<=16; k<<=1) {
139
- if ((ev.buttons & k) == 0 && #{@@pressing_mouse_buttons}[k]) {
140
- #{@@pressing_mouse_buttons}[k] = -#{@@tick};
144
+ if (#{@@pressing_mouse_buttons}[k]) {
145
+ #{@@pressing_mouse_buttons}[table[ev.button]] = -#{@@tick};
141
146
  }
142
147
  }
143
148
  });
@@ -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
- @@promises[klass_name][name] = promise
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 once
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
  }
@@ -1,3 +1,3 @@
1
1
  module DXOpal
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
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
- `window`.JS.requestAnimationFrame{|time| _loop(time) }
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
- `window`.JS.requestAnimationFrame{|time| _loop(time) }
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
- `window`.JS.requestAnimationFrame{|time| _loop(time) }
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
@@ -1,3 +1,4 @@
1
+ # backtick_javascript: true
1
2
  require 'opal'
2
3
  require 'console'; def console; $console; end
3
4
 
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.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yutaka HARA
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-31 00:00:00.000000000 Z
11
+ date: 2024-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
- description:
41
+ description:
42
42
  email:
43
43
  - yutaka.hara+github@gmail.com
44
44
  executables:
@@ -61,16 +61,30 @@ files:
61
61
  - build/dxopal.min.js
62
62
  - config.ru
63
63
  - doc/api/DXOpal.html
64
+ - doc/api/DXOpal/Constants.html
65
+ - doc/api/DXOpal/Constants/Colors.html
64
66
  - doc/api/DXOpal/Font.html
65
67
  - doc/api/DXOpal/Image.html
66
68
  - doc/api/DXOpal/Input.html
69
+ - doc/api/DXOpal/Input/KeyCodes.html
67
70
  - doc/api/DXOpal/Input/MouseCodes.html
71
+ - doc/api/DXOpal/Input/Touch.html
68
72
  - doc/api/DXOpal/RemoteResource.html
69
73
  - doc/api/DXOpal/Sound.html
70
74
  - doc/api/DXOpal/SoundEffect.html
71
75
  - doc/api/DXOpal/SoundEffect/WaveTypes.html
72
76
  - doc/api/DXOpal/Sprite.html
77
+ - doc/api/DXOpal/Sprite/CollisionArea.html
78
+ - doc/api/DXOpal/Sprite/CollisionArea/Base.html
79
+ - doc/api/DXOpal/Sprite/CollisionArea/Circle.html
80
+ - doc/api/DXOpal/Sprite/CollisionArea/Point.html
81
+ - doc/api/DXOpal/Sprite/CollisionArea/Rect.html
82
+ - doc/api/DXOpal/Sprite/CollisionArea/Triangle.html
83
+ - doc/api/DXOpal/Sprite/CollisionCheck.html
84
+ - doc/api/DXOpal/Sprite/CollisionCheck/ClassMethods.html
85
+ - doc/api/DXOpal/Sprite/Physics.html
73
86
  - doc/api/DXOpal/Window.html
87
+ - doc/api/Kernel.html
74
88
  - doc/api/_index.html
75
89
  - doc/api/class_list.html
76
90
  - doc/api/css/common.css
@@ -116,7 +130,7 @@ licenses:
116
130
  - MIT
117
131
  metadata:
118
132
  source_code_uri: https://github.com/yhara/dxopal
119
- post_install_message:
133
+ post_install_message:
120
134
  rdoc_options: []
121
135
  require_paths:
122
136
  - lib
@@ -131,9 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
145
  - !ruby/object:Gem::Version
132
146
  version: '0'
133
147
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.7.6.2
136
- signing_key:
148
+ rubygems_version: 3.4.10
149
+ signing_key:
137
150
  specification_version: 4
138
151
  summary: Game development framework for Opal
139
152
  test_files: []