dxopal 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile +2 -1
  4. data/Gemfile.lock +20 -20
  5. data/README.md +3 -3
  6. data/Rakefile +2 -14
  7. data/build/dxopal.js +26114 -18554
  8. data/build/dxopal.min.js +1 -1
  9. data/doc/api/DXOpal.html +10 -10
  10. data/doc/api/DXOpal/Constants.html +115 -0
  11. data/doc/api/DXOpal/Constants/Colors.html +172 -0
  12. data/doc/api/DXOpal/Font.html +71 -17
  13. data/doc/api/DXOpal/Image.html +891 -398
  14. data/doc/api/DXOpal/Input.html +814 -91
  15. data/doc/api/DXOpal/Input/KeyCodes.html +986 -0
  16. data/doc/api/DXOpal/Input/MouseCodes.html +7 -7
  17. data/doc/api/DXOpal/Input/Touch.html +834 -0
  18. data/doc/api/DXOpal/RemoteResource.html +16 -18
  19. data/doc/api/DXOpal/Sound.html +15 -15
  20. data/doc/api/DXOpal/SoundEffect.html +11 -13
  21. data/doc/api/DXOpal/SoundEffect/WaveTypes.html +7 -7
  22. data/doc/api/DXOpal/Sprite.html +517 -40
  23. data/doc/api/DXOpal/Sprite/CollisionArea.html +126 -0
  24. data/doc/api/DXOpal/Sprite/CollisionArea/Base.html +649 -0
  25. data/doc/api/DXOpal/Sprite/CollisionArea/Circle.html +656 -0
  26. data/doc/api/DXOpal/Sprite/CollisionArea/Point.html +448 -0
  27. data/doc/api/DXOpal/Sprite/CollisionArea/Rect.html +549 -0
  28. data/doc/api/DXOpal/Sprite/CollisionArea/Triangle.html +423 -0
  29. data/doc/api/DXOpal/Sprite/CollisionCheck.html +926 -0
  30. data/doc/api/DXOpal/Sprite/CollisionCheck/ClassMethods.html +268 -0
  31. data/doc/api/DXOpal/Sprite/Physics.html +426 -0
  32. data/doc/api/DXOpal/Window.html +235 -152
  33. data/doc/api/Kernel.html +131 -0
  34. data/doc/api/_index.html +276 -4
  35. data/doc/api/class_list.html +1 -1
  36. data/doc/api/css/style.css +1 -0
  37. data/doc/api/file.README.html +6 -8
  38. data/doc/api/frames.html +1 -1
  39. data/doc/api/index.html +6 -8
  40. data/doc/api/method_list.html +1600 -0
  41. data/doc/api/top-level-namespace.html +154 -3
  42. data/lib/dxopal/input.rb +4 -2
  43. data/lib/dxopal/version.rb +1 -1
  44. metadata +21 -8
@@ -0,0 +1,268 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: DXOpal::Sprite::CollisionCheck::ClassMethods
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "DXOpal::Sprite::CollisionCheck::ClassMethods";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../DXOpal.html" title="DXOpal (module)">DXOpal</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Sprite.html" title="DXOpal::Sprite (class)">Sprite</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../CollisionCheck.html" title="DXOpal::Sprite::CollisionCheck (module)">CollisionCheck</a></span></span>
41
+ &raquo;
42
+ <span class="title">ClassMethods</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: DXOpal::Sprite::CollisionCheck::ClassMethods
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dl>
78
+ <dt>Included in:</dt>
79
+ <dd><span class='object_link'><a href="../../Sprite.html" title="DXOpal::Sprite (class)">DXOpal::Sprite</a></span></dd>
80
+ </dl>
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/dxopal/sprite/collision_check.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
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="#check-instance_method" title="#check (instance method)">#<strong>check</strong>(offences, defences, shot = :shot, hit = :hit) &#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'>
124
+ <p>Run collision checking for set of sprites - offences: Sprite or [Sprite] - defences: Sprite or [Sprite] - shot: method name - hit: method name.</p>
125
+ </div></span>
126
+
127
+ </li>
128
+
129
+
130
+ </ul>
131
+
132
+
133
+
134
+
135
+ <div id="instance_method_details" class="method_details_list">
136
+ <h2>Instance Method Details</h2>
137
+
138
+
139
+ <div class="method_details first">
140
+ <h3 class="signature first" id="check-instance_method">
141
+
142
+ #<strong>check</strong>(offences, defences, shot = :shot, hit = :hit) &#x21d2; <tt>Object</tt>
143
+
144
+
145
+
146
+
147
+
148
+ </h3><div class="docstring">
149
+ <div class="discussion">
150
+
151
+ <p>Run collision checking for set of sprites</p>
152
+ <ul><li>
153
+ <p>offences: Sprite or [Sprite]</p>
154
+ </li><li>
155
+ <p>defences: Sprite or [Sprite]</p>
156
+ </li><li>
157
+ <p>shot: method name</p>
158
+ </li><li>
159
+ <p>hit: method name</p>
160
+ </li></ul>
161
+
162
+ <p>This method has two modes.</p>
163
+ <ul><li>
164
+ <p>If `offences` and `defences` are the same, collision check will be performed on each pair from the array. Method `hit` is called on the each sprite, with the other sprite as an argument.</p>
165
+ </li><li>
166
+ <p>Otherwise, collision check will be performed on each pair of offence sprite and defence sprite. In this case, method `shot` is called on the offence sprite and method `hit` is called on the defence sprite, with the other sprite as an argument.</p>
167
+ </li></ul>
168
+
169
+ <p>TODO: return true if any collition is detected TODO: skip collision checking if shot/hit returned `:discard`</p>
170
+
171
+
172
+ </div>
173
+ </div>
174
+ <div class="tags">
175
+
176
+
177
+ </div><table class="source_code">
178
+ <tr>
179
+ <td>
180
+ <pre class="lines">
181
+
182
+
183
+ 26
184
+ 27
185
+ 28
186
+ 29
187
+ 30
188
+ 31
189
+ 32
190
+ 33
191
+ 34
192
+ 35
193
+ 36
194
+ 37
195
+ 38
196
+ 39
197
+ 40
198
+ 41
199
+ 42
200
+ 43
201
+ 44
202
+ 45
203
+ 46
204
+ 47
205
+ 48
206
+ 49
207
+ 50
208
+ 51
209
+ 52
210
+ 53
211
+ 54
212
+ 55
213
+ 56
214
+ 57</pre>
215
+ </td>
216
+ <td>
217
+ <pre class="code"><span class="info file"># File 'lib/dxopal/sprite/collision_check.rb', line 26</span>
218
+
219
+ <span class='kw'>def</span> <span class='id identifier rubyid_check'>check</span><span class='lparen'>(</span><span class='id identifier rubyid_offences'>offences</span><span class='comma'>,</span> <span class='id identifier rubyid_defences'>defences</span><span class='comma'>,</span> <span class='id identifier rubyid_shot'>shot</span><span class='op'>=</span><span class='symbol'>:shot</span><span class='comma'>,</span> <span class='id identifier rubyid_hit'>hit</span><span class='op'>=</span><span class='symbol'>:hit</span><span class='rparen'>)</span>
220
+ <span class='id identifier rubyid_offences'>offences</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_offences'>offences</span><span class='rparen'>)</span>
221
+ <span class='id identifier rubyid_defences'>defences</span> <span class='op'>=</span> <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_defences'>defences</span><span class='rparen'>)</span>
222
+ <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='id identifier rubyid_j'>j</span> <span class='op'>=</span> <span class='int'>0</span> <span class='comment'># trick to use i, j in the `#{}`
223
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_offences'>offences</span><span class='period'>.</span><span class='id identifier rubyid_equal?'>equal?</span><span class='lparen'>(</span><span class='id identifier rubyid_defences'>defences</span><span class='rparen'>)</span>
224
+ <span class='comment'># any-vs-any mode
225
+ </span> <span class='id identifier rubyid_sprites'>sprites</span> <span class='op'>=</span> <span class='id identifier rubyid_offences'>offences</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../../Sprite.html" title="DXOpal::Sprite (class)">Sprite</a></span></span><span class='rparen'>)</span><span class='rbrace'>}</span>
226
+ <span class='id identifier rubyid_n'>n</span> <span class='op'>=</span> <span class='id identifier rubyid_sprites'>sprites</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
227
+ <span class='backtick'>%x{</span><span class='tstring_content'>
228
+ for (var i=0; i&lt;n; i++) {
229
+ for (var j=i+1; j&lt;n; j++) {
230
+ if (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sprites'>sprites</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='id identifier rubyid_sprites'>sprites</span><span class='lbracket'>[</span><span class='id identifier rubyid_j'>j</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>) {
231
+ </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sprites'>sprites</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_hit'>hit</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
232
+ </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_sprites'>sprites</span><span class='lbracket'>[</span><span class='id identifier rubyid_j'>j</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_hit'>hit</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
233
+ }
234
+ }
235
+ }
236
+ </span><span class='tstring_end'>}</span></span>
237
+ <span class='kw'>else</span>
238
+ <span class='comment'># offence-vs-defence mode
239
+ </span> <span class='backtick'>%x{</span><span class='tstring_content'>
240
+ for (var i=0; i&lt;offences.length; i++) {
241
+ for (var j=0; j&lt;defences.length; j++) {
242
+ if (</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_offences'>offences</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span> <span class='op'>===</span> <span class='id identifier rubyid_defences'>defences</span><span class='lbracket'>[</span><span class='id identifier rubyid_j'>j</span><span class='rbracket'>]</span><span class='embexpr_end'>}</span><span class='tstring_content'>) {
243
+ </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_offences'>offences</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_shot'>shot</span><span class='comma'>,</span> <span class='id identifier rubyid_defences'>defences</span><span class='lbracket'>[</span><span class='id identifier rubyid_j'>j</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
244
+ </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_defences'>defences</span><span class='lbracket'>[</span><span class='id identifier rubyid_j'>j</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_hit'>hit</span><span class='comma'>,</span> <span class='id identifier rubyid_offences'>offences</span><span class='lbracket'>[</span><span class='id identifier rubyid_i'>i</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_content'>;
245
+ }
246
+ }
247
+ }
248
+ </span><span class='tstring_end'>}</span></span>
249
+ <span class='kw'>end</span>
250
+ <span class='kw'>end</span></pre>
251
+ </td>
252
+ </tr>
253
+ </table>
254
+ </div>
255
+
256
+ </div>
257
+
258
+ </div>
259
+
260
+ <div id="footer">
261
+ Generated on Tue Dec 29 11:37:23 2020 by
262
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
263
+ 0.9.26 (ruby-2.7.0).
264
+ </div>
265
+
266
+ </div>
267
+ </body>
268
+ </html>
@@ -0,0 +1,426 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: DXOpal::Sprite::Physics
8
+
9
+ &mdash; Documentation by YARD 0.9.26
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "DXOpal::Sprite::Physics";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (P)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../DXOpal.html" title="DXOpal (module)">DXOpal</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Sprite.html" title="DXOpal::Sprite (class)">Sprite</a></span></span>
41
+ &raquo;
42
+ <span class="title">Physics</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: DXOpal::Sprite::Physics
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <dl>
78
+ <dt>Included in:</dt>
79
+ <dd><span class='object_link'><a href="../Sprite.html" title="DXOpal::Sprite (class)">DXOpal::Sprite</a></span></dd>
80
+ </dl>
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/dxopal/sprite/physics.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+
94
+ <p>Experimental Matter.js (physics engine) support</p>
95
+
96
+ <p>You need to load matter.js in advance to using these features.</p>
97
+
98
+
99
+ </div>
100
+ </div>
101
+ <div class="tags">
102
+
103
+
104
+ </div>
105
+
106
+
107
+
108
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
109
+ <ul class="summary">
110
+
111
+ <li class="public ">
112
+ <span class="summary_signature">
113
+
114
+ <a href="#_matter_body-instance_method" title="#_matter_body (instance method)">#<strong>_matter_body</strong> &#x21d2; Object </a>
115
+
116
+
117
+
118
+ </span>
119
+
120
+
121
+
122
+
123
+ <span class="note title readonly">readonly</span>
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ <span class="summary_desc"><div class='inline'>
134
+ <p>Returns the value of attribute _matter_body.</p>
135
+ </div></span>
136
+
137
+ </li>
138
+
139
+
140
+ </ul>
141
+
142
+
143
+
144
+
145
+
146
+ <h2>
147
+ Instance Method Summary
148
+ <small><a href="#" class="summary_toggle">collapse</a></small>
149
+ </h2>
150
+
151
+ <ul class="summary">
152
+
153
+ <li class="public ">
154
+ <span class="summary_signature">
155
+
156
+ <a href="#_move_matter_body-instance_method" title="#_move_matter_body (instance method)">#<strong>_move_matter_body</strong> &#x21d2; Object </a>
157
+
158
+
159
+
160
+ </span>
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'></div></span>
171
+
172
+ </li>
173
+
174
+
175
+ <li class="public ">
176
+ <span class="summary_signature">
177
+
178
+ <a href="#_move_to_matter_body-instance_method" title="#_move_to_matter_body (instance method)">#<strong>_move_to_matter_body</strong>(mx, my) &#x21d2; Object </a>
179
+
180
+
181
+
182
+ </span>
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+ <span class="summary_desc"><div class='inline'></div></span>
193
+
194
+ </li>
195
+
196
+
197
+ <li class="public ">
198
+ <span class="summary_signature">
199
+
200
+ <a href="#physical_body=-instance_method" title="#physical_body= (instance method)">#<strong>physical_body=</strong>(ary) &#x21d2; Object </a>
201
+
202
+
203
+
204
+ </span>
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+ <span class="summary_desc"><div class='inline'>
215
+ <p>Create Matter Body and register it to the World - type: :rectangle, etc.</p>
216
+ </div></span>
217
+
218
+ </li>
219
+
220
+
221
+ </ul>
222
+
223
+
224
+
225
+ <div id="instance_attr_details" class="attr_details">
226
+ <h2>Instance Attribute Details</h2>
227
+
228
+
229
+ <span id=""></span>
230
+ <div class="method_details first">
231
+ <h3 class="signature first" id="_matter_body-instance_method">
232
+
233
+ #<strong>_matter_body</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
234
+
235
+
236
+
237
+
238
+
239
+ </h3><div class="docstring">
240
+ <div class="discussion">
241
+
242
+ <p>Returns the value of attribute _matter_body.</p>
243
+
244
+
245
+ </div>
246
+ </div>
247
+ <div class="tags">
248
+
249
+
250
+ </div><table class="source_code">
251
+ <tr>
252
+ <td>
253
+ <pre class="lines">
254
+
255
+
256
+ 25
257
+ 26
258
+ 27</pre>
259
+ </td>
260
+ <td>
261
+ <pre class="code"><span class="info file"># File 'lib/dxopal/sprite/physics.rb', line 25</span>
262
+
263
+ <span class='kw'>def</span> <span class='id identifier rubyid__matter_body'>_matter_body</span>
264
+ <span class='ivar'>@_matter_body</span>
265
+ <span class='kw'>end</span></pre>
266
+ </td>
267
+ </tr>
268
+ </table>
269
+ </div>
270
+
271
+ </div>
272
+
273
+
274
+ <div id="instance_method_details" class="method_details_list">
275
+ <h2>Instance Method Details</h2>
276
+
277
+
278
+ <div class="method_details first">
279
+ <h3 class="signature first" id="_move_matter_body-instance_method">
280
+
281
+ #<strong>_move_matter_body</strong> &#x21d2; <tt>Object</tt>
282
+
283
+
284
+
285
+
286
+
287
+ </h3><table class="source_code">
288
+ <tr>
289
+ <td>
290
+ <pre class="lines">
291
+
292
+
293
+ 27
294
+ 28
295
+ 29
296
+ 30
297
+ 31</pre>
298
+ </td>
299
+ <td>
300
+ <pre class="code"><span class="info file"># File 'lib/dxopal/sprite/physics.rb', line 27</span>
301
+
302
+ <span class='kw'>def</span> <span class='id identifier rubyid__move_matter_body'>_move_matter_body</span>
303
+ <span class='comment'># TODO: support non-default center_x, center_y
304
+ </span> <span class='backtick'>`</span><span class='tstring_content'>Matter.Body.setPosition(</span><span class='embexpr_beg'>#{</span><span class='ivar'>@_matter_body</span><span class='embexpr_end'>}</span><span class='tstring_content'>,
305
+ Matter.Vector.create(</span><span class='embexpr_beg'>#{</span><span class='ivar'>@x</span><span class='op'>+</span><span class='ivar'>@center_x</span><span class='embexpr_end'>}</span><span class='tstring_content'>, </span><span class='embexpr_beg'>#{</span><span class='ivar'>@y</span><span class='op'>+</span><span class='ivar'>@center_y</span><span class='embexpr_end'>}</span><span class='tstring_content'>))</span><span class='tstring_end'>`</span></span>
306
+ <span class='kw'>end</span></pre>
307
+ </td>
308
+ </tr>
309
+ </table>
310
+ </div>
311
+
312
+ <div class="method_details ">
313
+ <h3 class="signature " id="_move_to_matter_body-instance_method">
314
+
315
+ #<strong>_move_to_matter_body</strong>(mx, my) &#x21d2; <tt>Object</tt>
316
+
317
+
318
+
319
+
320
+
321
+ </h3><table class="source_code">
322
+ <tr>
323
+ <td>
324
+ <pre class="lines">
325
+
326
+
327
+ 33
328
+ 34
329
+ 35
330
+ 36</pre>
331
+ </td>
332
+ <td>
333
+ <pre class="code"><span class="info file"># File 'lib/dxopal/sprite/physics.rb', line 33</span>
334
+
335
+ <span class='kw'>def</span> <span class='id identifier rubyid__move_to_matter_body'>_move_to_matter_body</span><span class='lparen'>(</span><span class='id identifier rubyid_mx'>mx</span><span class='comma'>,</span> <span class='id identifier rubyid_my'>my</span><span class='rparen'>)</span>
336
+ <span class='ivar'>@x</span> <span class='op'>=</span> <span class='id identifier rubyid_mx'>mx</span> <span class='op'>-</span> <span class='ivar'>@center_x</span>
337
+ <span class='ivar'>@y</span> <span class='op'>=</span> <span class='id identifier rubyid_my'>my</span> <span class='op'>-</span> <span class='ivar'>@center_y</span>
338
+ <span class='kw'>end</span></pre>
339
+ </td>
340
+ </tr>
341
+ </table>
342
+ </div>
343
+
344
+ <div class="method_details ">
345
+ <h3 class="signature " id="physical_body=-instance_method">
346
+
347
+ #<strong>physical_body=</strong>(ary) &#x21d2; <tt>Object</tt>
348
+
349
+
350
+
351
+
352
+
353
+ </h3><div class="docstring">
354
+ <div class="discussion">
355
+
356
+ <p>Create Matter Body and register it to the World</p>
357
+ <ul><li>
358
+ <p>type: :rectangle, etc.</p>
359
+ </li></ul>
360
+
361
+
362
+ </div>
363
+ </div>
364
+ <div class="tags">
365
+
366
+
367
+ </div><table class="source_code">
368
+ <tr>
369
+ <td>
370
+ <pre class="lines">
371
+
372
+
373
+ 9
374
+ 10
375
+ 11
376
+ 12
377
+ 13
378
+ 14
379
+ 15
380
+ 16
381
+ 17
382
+ 18
383
+ 19
384
+ 20
385
+ 21
386
+ 22
387
+ 23
388
+ 24</pre>
389
+ </td>
390
+ <td>
391
+ <pre class="code"><span class="info file"># File 'lib/dxopal/sprite/physics.rb', line 9</span>
392
+
393
+ <span class='kw'>def</span> <span class='id identifier rubyid_physical_body='>physical_body=</span><span class='lparen'>(</span><span class='id identifier rubyid_ary'>ary</span><span class='rparen'>)</span>
394
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Call Sprite#initialize before calling physical_body=</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
395
+ <span class='id identifier rubyid_type'>type</span> <span class='op'>=</span> <span class='id identifier rubyid_ary'>ary</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
396
+ <span class='kw'>case</span> <span class='id identifier rubyid_type'>type</span>
397
+ <span class='kw'>when</span> <span class='symbol'>:rectangle</span>
398
+ <span class='id identifier rubyid__'>_</span><span class='comma'>,</span> <span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='op'>*</span><span class='id identifier rubyid_ary'>ary</span>
399
+ <span class='id identifier rubyid_x'>x</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_x'>x</span> <span class='op'>+</span> <span class='id identifier rubyid_width'>width</span><span class='op'>/</span><span class='int'>2</span>
400
+ <span class='id identifier rubyid_y'>y</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_y'>y</span> <span class='op'>+</span> <span class='id identifier rubyid_height'>height</span><span class='op'>/</span><span class='int'>2</span>
401
+ <span class='id identifier rubyid_info'>info</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_width'>width</span><span class='comma'>,</span> <span class='id identifier rubyid_height'>height</span><span class='rbracket'>]</span>
402
+ <span class='backtick'>`</span><span class='tstring_content'>opts.angle = opts.angle || </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_angle'>angle</span> <span class='op'>*</span> <span class='const'>Math</span><span class='op'>::</span><span class='const'>PI</span> <span class='op'>/</span> <span class='int'>180</span><span class='embexpr_end'>}</span><span class='tstring_end'>`</span></span>
403
+ <span class='ivar'>@_matter_body</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>Matter.Bodies[type](x, y, width, height, opts)</span><span class='tstring_end'>`</span></span>
404
+ <span class='kw'>else</span>
405
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>type </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_type'>type</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> is unknown or not supported yet</span><span class='tstring_end'>&quot;</span></span>
406
+ <span class='kw'>end</span>
407
+ <span class='const'><span class='object_link'><a href="../Sprite.html" title="DXOpal::Sprite (class)">Sprite</a></span></span><span class='period'>.</span><span class='id identifier rubyid__add_matter_body'><span class='object_link'><a href="../Sprite.html#_add_matter_body-class_method" title="DXOpal::Sprite._add_matter_body (method)">_add_matter_body</a></span></span><span class='lparen'>(</span><span class='ivar'>@_matter_body</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_info'>info</span><span class='rparen'>)</span>
408
+ <span class='kw'>end</span></pre>
409
+ </td>
410
+ </tr>
411
+ </table>
412
+ </div>
413
+
414
+ </div>
415
+
416
+ </div>
417
+
418
+ <div id="footer">
419
+ Generated on Tue Dec 29 11:37:23 2020 by
420
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
421
+ 0.9.26 (ruby-2.7.0).
422
+ </div>
423
+
424
+ </div>
425
+ </body>
426
+ </html>