dxopal 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +4 -2
- data/Rakefile +1 -1
- data/build/dxopal.js +995 -95
- data/build/dxopal.min.js +1 -1
- data/doc/api/DXOpal.html +2 -2
- data/doc/api/DXOpal/Font.html +1 -1
- data/doc/api/DXOpal/Image.html +1 -1
- data/doc/api/DXOpal/Input.html +3 -3
- data/doc/api/DXOpal/Input/MouseCodes.html +1 -1
- data/doc/api/DXOpal/RemoteResource.html +1 -1
- data/doc/api/DXOpal/Sound.html +76 -3
- data/doc/api/DXOpal/SoundEffect.html +2 -2
- data/doc/api/DXOpal/SoundEffect/WaveTypes.html +1 -1
- data/doc/api/DXOpal/Sprite.html +1 -1
- data/doc/api/DXOpal/Window.html +2 -2
- data/doc/api/_index.html +1 -1
- data/doc/api/file.README.html +1 -1
- data/doc/api/index.html +1 -1
- data/doc/api/method_list.html +29 -21
- data/doc/api/top-level-namespace.html +1 -1
- data/dxopal.gemspec +5 -1
- data/opal/dxopal.rb +7 -1
- data/opal/dxopal/input.rb +2 -2
- data/opal/dxopal/input/key_codes.rb +77 -71
- data/opal/dxopal/sound.rb +10 -1
- data/opal/dxopal/version.rb +1 -1
- data/opal/dxopal/window.rb +1 -1
- metadata +20 -5
data/dxopal.gemspec
CHANGED
@@ -10,7 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["yutaka.hara+github@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Game development framework for Opal}
|
13
|
-
spec.homepage = "https://github.
|
13
|
+
spec.homepage = "https://yhara.github.io/dxopal/"
|
14
|
+
spec.metadata = {
|
15
|
+
"source_code_uri" => "https://github.com/yhara/dxopal"
|
16
|
+
}
|
14
17
|
spec.license = "MIT"
|
15
18
|
|
16
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -26,5 +29,6 @@ Gem::Specification.new do |spec|
|
|
26
29
|
spec.add_development_dependency "bundler", "~> 1.14"
|
27
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
28
31
|
spec.add_development_dependency "yard", "~> 0.9.12"
|
32
|
+
spec.add_development_dependency "puma", "~> 3.11.2"
|
29
33
|
spec.add_development_dependency "opal-sprockets", "~> 0.4.1"
|
30
34
|
end
|
data/opal/dxopal.rb
CHANGED
@@ -26,8 +26,14 @@ def require_remote(url)
|
|
26
26
|
eval `r.responseText`
|
27
27
|
end
|
28
28
|
|
29
|
-
# These
|
29
|
+
# These opal stdlibs will be embedded in dxopal.js.
|
30
|
+
require 'singleton'
|
31
|
+
require 'delegate'
|
32
|
+
require 'forwardable'
|
30
33
|
require 'pp'
|
34
|
+
require 'promise'
|
35
|
+
require 'set'
|
36
|
+
require 'time'
|
31
37
|
|
32
38
|
module DXOpal
|
33
39
|
include DXOpal::Constants::Colors
|
data/opal/dxopal/input.rb
CHANGED
@@ -69,7 +69,7 @@ module DXOpal
|
|
69
69
|
# (private) JS keydown event handler
|
70
70
|
ON_KEYDOWN_ = %x{
|
71
71
|
function(ev){
|
72
|
-
#{Input._pressing_keys}[ev.
|
72
|
+
#{Input._pressing_keys}[ev.code] = #{@@tick};
|
73
73
|
ev.preventDefault();
|
74
74
|
ev.stopPropagation();
|
75
75
|
}
|
@@ -77,7 +77,7 @@ module DXOpal
|
|
77
77
|
# (private) JS keyup event handler
|
78
78
|
ON_KEYUP_ = %x{
|
79
79
|
function(ev){
|
80
|
-
#{Input._pressing_keys}[ev.
|
80
|
+
#{Input._pressing_keys}[ev.code] = -#{@@tick};
|
81
81
|
ev.preventDefault();
|
82
82
|
ev.stopPropagation();
|
83
83
|
}
|
@@ -1,64 +1,70 @@
|
|
1
1
|
module DXOpal
|
2
2
|
module Input
|
3
|
+
# List of key codes (event.code)
|
4
|
+
# https://developer.mozilla.org/ja/docs/Web/API/KeyboardEvent
|
3
5
|
module KeyCodes
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
6
|
+
# TODO: add more keycodes (pull request welcome)
|
7
|
+
# especially keypads and us-keyboards
|
8
|
+
|
9
|
+
K_ESCAPE = 'Escape'
|
10
|
+
K_1 = 'Digit1'
|
11
|
+
K_2 = 'Digit2'
|
12
|
+
K_3 = 'Digit3'
|
13
|
+
K_4 = 'Digit4'
|
14
|
+
K_5 = 'Digit5'
|
15
|
+
K_6 = 'Digit6'
|
16
|
+
K_7 = 'Digit7'
|
17
|
+
K_8 = 'Digit8'
|
18
|
+
K_9 = 'Digit9'
|
19
|
+
K_0 = 'Digit0'
|
20
|
+
K_MINUS = 'Minus'
|
21
|
+
K_EQUALS = 'Equal'
|
22
|
+
K_BACK = 'Backspace'
|
23
|
+
K_TAB = 'Tab'
|
24
|
+
K_Q = 'KeyQ'
|
25
|
+
K_W = 'KeyW'
|
26
|
+
K_E = 'KeyE'
|
27
|
+
K_R = 'KeyR'
|
28
|
+
K_T = 'KeyT'
|
29
|
+
K_Y = 'KeyY'
|
30
|
+
K_U = 'KeyU'
|
31
|
+
K_I = 'KeyI'
|
32
|
+
K_O = 'KeyO'
|
33
|
+
K_P = 'KeyP'
|
34
|
+
K_LBRACKET = 'BracketLeft'
|
35
|
+
K_RBRACKET = 'BracketRight'
|
36
|
+
K_RETURN = 'Enter'
|
37
|
+
K_ENTER = 'Enter' # Alias; not in DXRuby
|
38
|
+
K_LCONTROL = 'ControlLeft'
|
39
|
+
K_A = 'KeyA'
|
40
|
+
K_S = 'KeyS'
|
41
|
+
K_D = 'KeyD'
|
42
|
+
K_F = 'KeyF'
|
43
|
+
K_G = 'KeyG'
|
44
|
+
K_H = 'KeyH'
|
45
|
+
K_J = 'KeyJ'
|
46
|
+
K_K = 'KeyK'
|
47
|
+
K_L = 'KeyL'
|
48
|
+
K_SEMICOLON = 'Semicolon'
|
49
|
+
K_APOSTROPHE = 'Quote' # '
|
44
50
|
#K_GRAVE = "`"
|
45
|
-
|
46
|
-
K_BACKSLASH =
|
47
|
-
K_Z =
|
48
|
-
K_X =
|
49
|
-
K_C =
|
50
|
-
K_V =
|
51
|
-
K_B =
|
52
|
-
K_N =
|
53
|
-
K_M =
|
54
|
-
K_COMMA =
|
55
|
-
K_PERIOD =
|
56
|
-
K_SLASH =
|
57
|
-
|
51
|
+
K_LSHIFT = 'ShiftLeft'
|
52
|
+
K_BACKSLASH = 'BackSlash' # Note: different to K_YEN
|
53
|
+
K_Z = 'KeyZ'
|
54
|
+
K_X = 'KeyX'
|
55
|
+
K_C = 'KeyC'
|
56
|
+
K_V = 'KeyV'
|
57
|
+
K_B = 'KeyB'
|
58
|
+
K_N = 'KeyN'
|
59
|
+
K_M = 'KeyM'
|
60
|
+
K_COMMA = 'Comma'
|
61
|
+
K_PERIOD = 'Period'
|
62
|
+
K_SLASH = 'Slash'
|
63
|
+
K_RSHIFT = 'ShiftRight'
|
58
64
|
#K_MULTIPLY = "*"
|
59
65
|
#K_LMENU Alt
|
60
|
-
K_SPACE =
|
61
|
-
#K_CAPITAL
|
66
|
+
K_SPACE = 'Space'
|
67
|
+
#K_CAPITAL
|
62
68
|
K_F1 = 112
|
63
69
|
K_F2 = 113
|
64
70
|
K_F3 = 114
|
@@ -94,20 +100,20 @@ module DXOpal
|
|
94
100
|
#K_ABNT_C1
|
95
101
|
#K_CONVERT
|
96
102
|
#K_NOCONVERT
|
97
|
-
|
103
|
+
K_YEN = 'IntlYen'
|
98
104
|
#K_ABNT_C2
|
99
105
|
#K_NUMPADEQUALS = *3 *1
|
100
|
-
K_PREVTRACK
|
101
|
-
K_AT
|
102
|
-
K_COLON =
|
103
|
-
K_UNDERLINE =
|
106
|
+
#K_PREVTRACK
|
107
|
+
#K_AT
|
108
|
+
K_COLON = 'Colon'
|
109
|
+
K_UNDERLINE = 'IntlRo' # _
|
104
110
|
#K_KANJI
|
105
111
|
#K_STOP
|
106
112
|
#K_AX
|
107
113
|
#K_UNLABELED
|
108
114
|
#K_NEXTTRACK
|
109
115
|
#K_NUMPADENTER Enter *3
|
110
|
-
|
116
|
+
K_RCONTROL = 'ControlRight'
|
111
117
|
#K_MUTE
|
112
118
|
#K_CALCULATOR
|
113
119
|
#K_PLAYPAUSE
|
@@ -121,12 +127,12 @@ module DXOpal
|
|
121
127
|
#K_RMENU Alt
|
122
128
|
#K_PAUSE = "Pause"
|
123
129
|
#K_HOME "Home"
|
124
|
-
K_UP =
|
130
|
+
K_UP = 'ArrowUp'
|
125
131
|
#K_PRIOR
|
126
|
-
K_LEFT =
|
127
|
-
K_RIGHT =
|
132
|
+
K_LEFT = 'ArrowLeft'
|
133
|
+
K_RIGHT = 'ArrowRight'
|
128
134
|
#K_END = "End"
|
129
|
-
K_DOWN =
|
135
|
+
K_DOWN = 'ArrowDown'
|
130
136
|
#K_NEXT
|
131
137
|
#K_INSERT = "Insert"
|
132
138
|
#K_DELETE = "Delete"
|
@@ -145,20 +151,20 @@ module DXOpal
|
|
145
151
|
#K_MYCOMPUTER
|
146
152
|
#K_MAIL
|
147
153
|
#K_MEDIASELECT
|
148
|
-
K_BACKSPACE =
|
154
|
+
K_BACKSPACE = 'Backspace'
|
149
155
|
#K_NUMPADSTAR * *3
|
150
156
|
#K_LALT Alt
|
151
|
-
|
157
|
+
K_CAPSLOCK = 'CapsLock'
|
152
158
|
#K_NUMPADMINUS - *3
|
153
159
|
#K_NUMPADPLUS + *3
|
154
160
|
#K_NUMPADPERIOD . *3
|
155
161
|
#K_NUMPADSLASH / *3
|
156
162
|
#K_RALT Alt
|
157
|
-
K_UPARROW =
|
163
|
+
K_UPARROW = 'ArrowUp'
|
158
164
|
#K_PGUP = "PageUp"
|
159
|
-
K_LEFTARROW =
|
160
|
-
K_RIGHTARROW =
|
161
|
-
K_DOWNARROW =
|
165
|
+
K_LEFTARROW = 'ArrowLeft'
|
166
|
+
K_RIGHTARROW = 'ArrowRight'
|
167
|
+
K_DOWNARROW = 'ArrowDown'
|
162
168
|
#K_PGDN = "PageDown"
|
163
169
|
end
|
164
170
|
end
|
data/opal/dxopal/sound.rb
CHANGED
@@ -41,13 +41,22 @@ module DXOpal
|
|
41
41
|
# Play this sound once
|
42
42
|
def play
|
43
43
|
raise "Sound #{path_or_url} is not loaded yet" unless @decoded
|
44
|
+
source = nil
|
44
45
|
%x{
|
45
46
|
var context = #{Sound.audio_context};
|
46
|
-
|
47
|
+
source = context.createBufferSource();
|
47
48
|
source.buffer = #{@decoded};
|
48
49
|
source.connect(context.destination);
|
49
50
|
source.start(0);
|
50
51
|
}
|
52
|
+
@source = source
|
53
|
+
end
|
54
|
+
|
55
|
+
# Stop playing this sound (if playing)
|
56
|
+
def stop
|
57
|
+
return unless @decoded
|
58
|
+
return unless @source
|
59
|
+
@source.JS.stop()
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
data/opal/dxopal/version.rb
CHANGED
data/opal/dxopal/window.rb
CHANGED
@@ -75,7 +75,7 @@ module DXOpal
|
|
75
75
|
|
76
76
|
# Draw
|
77
77
|
@@img.box_fill(0, 0, @@width, @@height, @@bgcolor)
|
78
|
-
sorted = @@draw_queue.sort{|a, b| a[0] == b[0] ? a[1] <=> b[1] : a[0] <=>
|
78
|
+
sorted = @@draw_queue.sort{|a, b| a[0] == b[0] ? a[1] <=> b[1] : a[0] <=> b[0] }
|
79
79
|
sorted.each do |item|
|
80
80
|
case item[2]
|
81
81
|
when :image then @@img.draw(*item.drop(3))
|
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.2.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: 2018-
|
11
|
+
date: 2018-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.9.12
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: puma
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.11.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.11.2
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: opal-sprockets
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,10 +192,11 @@ files:
|
|
178
192
|
- opal/dxopal/window.rb
|
179
193
|
- template/index.html
|
180
194
|
- template/main.rb
|
181
|
-
homepage: https://github.
|
195
|
+
homepage: https://yhara.github.io/dxopal/
|
182
196
|
licenses:
|
183
197
|
- MIT
|
184
|
-
metadata:
|
198
|
+
metadata:
|
199
|
+
source_code_uri: https://github.com/yhara/dxopal
|
185
200
|
post_install_message:
|
186
201
|
rdoc_options: []
|
187
202
|
require_paths:
|
@@ -198,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
213
|
version: '0'
|
199
214
|
requirements: []
|
200
215
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.6
|
216
|
+
rubygems_version: 2.7.6
|
202
217
|
signing_key:
|
203
218
|
specification_version: 4
|
204
219
|
summary: Game development framework for Opal
|