dxopal 1.0.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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ignore +5 -0
  4. data/.nojekyll +4 -0
  5. data/CHANGELOG.md +90 -0
  6. data/DEVELOPMENT.md +57 -0
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +39 -0
  9. data/README.md +22 -0
  10. data/Rakefile +66 -0
  11. data/TODO.md +278 -0
  12. data/build/dxopal.js +46590 -0
  13. data/build/dxopal.min.js +1 -0
  14. data/config.ru +39 -0
  15. data/doc/api/DXOpal.html +129 -0
  16. data/doc/api/DXOpal/Font.html +485 -0
  17. data/doc/api/DXOpal/Image.html +2533 -0
  18. data/doc/api/DXOpal/Input.html +1086 -0
  19. data/doc/api/DXOpal/Input/MouseCodes.html +146 -0
  20. data/doc/api/DXOpal/RemoteResource.html +641 -0
  21. data/doc/api/DXOpal/Sound.html +568 -0
  22. data/doc/api/DXOpal/SoundEffect.html +444 -0
  23. data/doc/api/DXOpal/SoundEffect/WaveTypes.html +130 -0
  24. data/doc/api/DXOpal/Sprite.html +1419 -0
  25. data/doc/api/DXOpal/Window.html +1915 -0
  26. data/doc/api/_index.html +228 -0
  27. data/doc/api/class_list.html +51 -0
  28. data/doc/api/css/common.css +1 -0
  29. data/doc/api/css/full_list.css +58 -0
  30. data/doc/api/css/style.css +492 -0
  31. data/doc/api/file.CHANGELOG.html +162 -0
  32. data/doc/api/file.README.html +124 -0
  33. data/doc/api/file_list.html +61 -0
  34. data/doc/api/frames.html +17 -0
  35. data/doc/api/index.html +124 -0
  36. data/doc/api/js/app.js +248 -0
  37. data/doc/api/js/full_list.js +216 -0
  38. data/doc/api/js/jquery.js +4 -0
  39. data/doc/api/method_list.html +939 -0
  40. data/doc/api/top-level-namespace.html +110 -0
  41. data/doc/en/index.html +93 -0
  42. data/doc/ja/index.html +92 -0
  43. data/dxopal.gemspec +29 -0
  44. data/exe/dxopal +44 -0
  45. data/index.html +56 -0
  46. data/opal/dxopal.rb +54 -0
  47. data/opal/dxopal/constants/colors.rb +16 -0
  48. data/opal/dxopal/font.rb +20 -0
  49. data/opal/dxopal/image.rb +301 -0
  50. data/opal/dxopal/input.rb +170 -0
  51. data/opal/dxopal/input/key_codes.rb +168 -0
  52. data/opal/dxopal/remote_resource.rb +65 -0
  53. data/opal/dxopal/sound.rb +53 -0
  54. data/opal/dxopal/sound_effect.rb +84 -0
  55. data/opal/dxopal/sprite.rb +94 -0
  56. data/opal/dxopal/sprite/collision_area.rb +288 -0
  57. data/opal/dxopal/sprite/collision_check.rb +106 -0
  58. data/opal/dxopal/sprite/collision_checker.rb +169 -0
  59. data/opal/dxopal/sprite/physics.rb +82 -0
  60. data/opal/dxopal/version.rb +3 -0
  61. data/opal/dxopal/window.rb +173 -0
  62. data/template/index.html +13 -0
  63. data/template/main.rb +9 -0
  64. metadata +191 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 836050990feb2a654b7f7d414e26ad6ec681494a
4
+ data.tar.gz: 8aa0a2abf670038be330b1e9b22cd2e882c834d1
5
+ SHA512:
6
+ metadata.gz: 8d83eb5cd04c24ee0026b83d8a7f9719a2aaaba6400d9136298f8f409b7de0a9c14cacd6ab8526b35f625bc20b7669cd12b553d9fac0cd254a828cafc802a2df
7
+ data.tar.gz: 49af36830ebf06a735392e266a0e2aeb4b5172e7545101c5d2fac0d47f2be9b1fa0229f9e8f089b762434a22a722491394f83f12deffc8c2854c7947511c3ab1
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /vendor/pages-themes-dinky-14e8031
2
+ /starter-kit
3
+ /.yardoc
4
+ /tmp
5
+ /,
data/.ignore ADDED
@@ -0,0 +1,5 @@
1
+ # Ignore file for ripgrep
2
+ /build/
3
+ /doc/api/
4
+ /examples/_vendor/
5
+ /vendor/
data/.nojekyll ADDED
@@ -0,0 +1,4 @@
1
+ Disable Jekyll on GitHub Pages
2
+ https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/
3
+
4
+ Without this file, examples/_vendor/ is not uploaded
data/CHANGELOG.md ADDED
@@ -0,0 +1,90 @@
1
+ ## v1.0.0 (2017-10-26)
2
+
3
+ ### Breaking change: canvas id
4
+
5
+ Old:
6
+
7
+ <canvas id="canvas">
8
+
9
+ New:
10
+
11
+ <canvas id="dxopal-canvas">
12
+
13
+ ### Other improvements:
14
+
15
+ - new: Sprite.check (collision detection)
16
+ - new: Window.bgcolor
17
+ - new: Input.mouse_down?, mouse_push?, mouse_release?
18
+ - new: Input.keyevent_target
19
+ - new: Matter.js support (experimental)
20
+ - new: Window.loop can be called twice
21
+ - fix: Image transparency was ignored
22
+ - fix: Sprite.clean was broken
23
+ - fix: Window.width=, height= did not work
24
+
25
+ ## v0.3.0 (2017-08-03)
26
+
27
+ - new: Window.real_fps
28
+ - new: Some more drawing methods
29
+ - new: SoundEffect class
30
+ - improve: Better fps stabillity (use requestAnimationFrame)
31
+
32
+ ## v0.2.0 (2017-06-02)
33
+
34
+ - new: Add example (apple_catcher)
35
+
36
+ ### Breaking Change: resource loading
37
+
38
+ Image.load and Sound.new are removed. They look like a synchronous API
39
+ but actually were not. It was fun to emulate DXRuby APIs with JS Promise,
40
+ but I found it
41
+ very confusing while implementing the AppleCatcher example.
42
+
43
+ Since v0.2, resource loading look like this.
44
+
45
+ ```rb
46
+ Image.register(:player, 'images/player.png')
47
+ Sound.register(:game_over, 'sounds/game_over.wav')
48
+
49
+ Window.load_resources do
50
+ Window.loop do
51
+ # ... Window.draw(0, 0, Image[:player]) ...
52
+
53
+ # ... Sound[:game_over].play ...
54
+ end
55
+ end
56
+ ```
57
+
58
+ ## v0.1.2 (2017-05-01)
59
+
60
+ - new: Window.pause, .resume
61
+ - new: Window.draw_box_fill
62
+ - new: Sprite.update, Sprite.clean
63
+
64
+ ## v0.1.1 (2017-04-30)
65
+
66
+ - fix: Image#draw now respects alpha channel
67
+ - fix: Vanished sprites have no collision
68
+ - new: Image#slice
69
+
70
+ ## v0.1.0 (2017-04-24)
71
+
72
+ - new: Sprite.new, collision detection
73
+ - new: Input.mouse_pos_x, mouse_pos_y
74
+
75
+ ## v0.0.3 (2017-04-23)
76
+
77
+ - fix: Input.key_down? return true after key is released
78
+ - new: color constants
79
+ - new: Image.new, Image#circle, etc.
80
+ - new: console
81
+ - refactor: Split source file
82
+
83
+ ## v0.0.2 (2017-04-22)
84
+
85
+ - Moved demos to yhara/dxopal-game
86
+ - Now ruby is not mandatory to make games with DXOpal
87
+
88
+ ## v0.0.1 (2017-04-19)
89
+
90
+ - Gemified (not pushed to rubygems.org yet)
data/DEVELOPMENT.md ADDED
@@ -0,0 +1,57 @@
1
+ # How to start developing DXOpal
2
+
3
+ ## Prerequisites
4
+
5
+ - Ruby (tested with 2.3.3)
6
+ - Node.js (to minify .js)
7
+
8
+ ## Setup
9
+
10
+ ```
11
+ $ git clone https://github.com/yhara/dxopal
12
+ $ cd dxopal
13
+ $ bundle install
14
+ $ npm install uglify-es -g
15
+ $ bundle exec rackup
16
+ $ open http://localhost:9292/
17
+ ```
18
+
19
+ Developing dxopal-starter-kit:
20
+
21
+ ```
22
+ $ cd dxopal # Must be cloned into here
23
+ $ git clone https://github.com/yhara/dxopal-starter-kit
24
+ ```
25
+
26
+ ## Build .js
27
+
28
+ $ rake build
29
+ $ rake build_min # Build and minify
30
+
31
+ ## Documents
32
+
33
+ Build API reference:
34
+
35
+ $ rake api
36
+
37
+ ## Directory structure
38
+
39
+ - build/
40
+ - dxopal.js
41
+ - dxopal.min.js
42
+ - doc/
43
+ - api/
44
+ - en/
45
+ - ja/
46
+ - examples/
47
+ - exe/
48
+ - dxopal
49
+ - opal/ : Source code
50
+ - dxopal.rb
51
+ - dxopal/
52
+ - template/ : Template files for `dxopal init` command
53
+ - index.html
54
+ - main.rb
55
+ - vendor/
56
+ - matter.js
57
+ - pages-themes-dinky-14e8031/
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dxopal (1.0.0)
5
+ opal (~> 0.10.5)
6
+ rack (~> 2.0)
7
+ thor (~> 0.19.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ concurrent-ruby (1.0.5)
13
+ hike (1.2.3)
14
+ opal (0.10.5)
15
+ hike (~> 1.2)
16
+ sourcemap (~> 0.1.0)
17
+ sprockets (~> 3.1)
18
+ tilt (>= 1.4)
19
+ rack (2.0.3)
20
+ rake (10.5.0)
21
+ sourcemap (0.1.1)
22
+ sprockets (3.7.1)
23
+ concurrent-ruby (~> 1.0)
24
+ rack (> 1, < 3)
25
+ thor (0.19.4)
26
+ tilt (2.0.8)
27
+ yard (0.9.9)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.14)
34
+ dxopal!
35
+ rake (~> 10.0)
36
+ yard (~> 0.9.9)
37
+
38
+ BUNDLED WITH
39
+ 1.15.4
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # DXOpal
2
+
3
+ Game development framework for [Opal](http://opalrb.org/),
4
+ has similar API to [DXRuby](http://dxruby.osdn.jp/)
5
+
6
+ ## Website
7
+
8
+ https://yhara.github.io/dxopal/
9
+
10
+ ## License
11
+
12
+ MIT (including images and sounds under examples/)
13
+
14
+ ## Acknowledgements
15
+
16
+ - [Opal](http://opalrb.org/)
17
+ - [DXRuby](http://dxruby.osdn.jp/)
18
+ - [Bxfr](http://www.bfxr.net/) examples/apple_catcher/sounds/Explosion2.wav is made by this
19
+
20
+ ## Contact
21
+
22
+ https://github.com/yhara/dxopal
data/Rakefile ADDED
@@ -0,0 +1,66 @@
1
+ require 'opal'
2
+ require_relative 'opal/dxopal/version'
3
+
4
+ desc "Build dxopal.js"
5
+ task :build => ["build/dxopal.js"]
6
+
7
+ desc "Build dxopal.js and dxopal.min.js"
8
+ task :build_min => ["build/dxopal.min.js", "starter-kit/dxopal.min.js"]
9
+
10
+ file "starter-kit/dxopal.min.js" => "build/dxopal.min.js" do |t| cp t.source, t.name end
11
+
12
+ file "build/dxopal.min.js" => "build/dxopal.js" do |t|
13
+ sh "uglifyjs #{t.source} -o #{t.name}"
14
+ end
15
+
16
+ file "build/dxopal.js" => Dir["opal/**/*.rb"] + ["vendor/matter.js"] do |t|
17
+ Opal.append_path("opal")
18
+ js = Opal::Builder.build("dxopal.rb").to_s
19
+ js << File.read("vendor/matter.js")
20
+ File.write(t.name, js)
21
+ end
22
+
23
+ desc "Rebuild API reference"
24
+ task :api do
25
+ sh "yard doc -o doc/api/ opal/**/*.rb"
26
+ end
27
+
28
+ namespace "release" do
29
+ desc "Make a release commit"
30
+ task :prepare do
31
+ sh "rake build_min -B"
32
+ sh "gem build dxopal.gemspec"
33
+ sh "git ci -a -m 'v#{DXOpal::VERSION}'"
34
+ end
35
+
36
+ desc "Make a release commit"
37
+ task :push do
38
+ sh "git tag 'v#{DXOpal::VERSION}'"
39
+ sh "git push origin master --tags"
40
+ end
41
+
42
+ desc "Release gem"
43
+ task :push_gem do
44
+ sh "gem build dxopal.gemspec"
45
+ sh "gem push dxopal-#{DXOpal::VERSION}.gem"
46
+ end
47
+
48
+ desc "Make a release commit"
49
+ task :push_kit do
50
+ cd "starter-kit" do
51
+ sh "git ci dxopal.min.js -m 'v#{DXOpal::VERSION}'"
52
+ sh "git tag 'v#{DXOpal::VERSION}'"
53
+ sh "git push origin master --tags"
54
+ end
55
+ end
56
+ end
57
+
58
+ # How to make a release
59
+ # TODO: should edit lib/dxopal/version.rb :-\
60
+ # 1. Edit CHANGELOG.md
61
+ # 2. `rake release:prepare`
62
+ # 3. Test
63
+ # - Open starter-kit/index.html in Firefox
64
+ # - rackup and open http://localhost:9292/
65
+ # 4. `rake release:push`
66
+ # 5. `rake release:push_game`
data/TODO.md ADDED
@@ -0,0 +1,278 @@
1
+ # Compatibility to DXRuby
2
+
3
+ ## module Input
4
+
5
+ - [ ] x - TODO: pad support
6
+ - [ ] y - TODO: pad support
7
+ - [x] key_down?
8
+ - [x] key_push?
9
+ - [x] key_release?
10
+ - [ ] set_repeat
11
+ - [ ] set_key_repeat
12
+ - [ ] set_pad_repeat
13
+ - [ ] set_config
14
+ - [x] mouse_x
15
+ - [x] mouse_y
16
+ - [x] mouse_pos_x
17
+ - [x] mouse_pos_y
18
+ - [ ] set_mouse_pos
19
+ - [x] mouse_down?
20
+ - [x] mouse_push?
21
+ - [x] mouse_release?
22
+ - [ ] mouse_wheel_pos
23
+ - [ ] mouse_wheel_pos=
24
+ - [ ] mouse_enable=
25
+ - [ ] keys
26
+ - [ ] requested_close?
27
+ - [ ] set_cursor
28
+
29
+ These methods are waiting Pull Requests because I don't have a gamepad.
30
+
31
+ - [ ] pad_down?
32
+ - [ ] pad_push?
33
+ - [ ] pad_release?
34
+ - [ ] pad_num
35
+ - [ ] pad_axis
36
+ - [ ] pad_lstick
37
+ - [ ] pad_rstick
38
+ - [ ] pad_pov
39
+ - [ ] pad_lx
40
+ - [ ] pad_ly
41
+ - [ ] pad_rx
42
+ - [ ] pad_ry
43
+ - [ ] pad_pov_x
44
+ - [ ] pad_pov_y
45
+ - [ ] pads
46
+
47
+ These methods will not be supported.
48
+
49
+ - update
50
+
51
+ ## module Window
52
+
53
+ - [x] loop
54
+ - [x] draw
55
+ - [ ] draw_scale
56
+ - [x] draw_rot
57
+ - [ ] draw_alpha
58
+ - [ ] draw_add
59
+ - [ ] draw_sub
60
+ - [ ] draw_shader
61
+ - [ ] draw_ex
62
+ - [ ] draw_font - partially
63
+ - [ ] draw_font_ex
64
+ - [ ] draw_morph
65
+ - [ ] draw_tile
66
+ - [x] draw_pixel
67
+ - [x] draw_line
68
+ - [x] draw_box
69
+ - [x] draw_box_fill
70
+ - [x] draw_circle
71
+ - [x] draw_circle_fill
72
+ - [ ] ox
73
+ - [ ] ox=
74
+ - [ ] oy
75
+ - [ ] oy=
76
+ - [ ] get_screen_shot
77
+ - [ ] get_load
78
+ - [ ] open_filename
79
+ - [ ] save_filename
80
+ - [ ] folder_dialog
81
+ - [ ] x
82
+ - [ ] x=
83
+ - [ ] y
84
+ - [ ] y=
85
+ - [x] width
86
+ - [x] width=
87
+ - [x] height
88
+ - [x] height=
89
+ - [ ] scale
90
+ - [ ] scale=
91
+ - [ ] windowed?
92
+ - [ ] windowed=
93
+ - [ ] full_screen?
94
+ - [ ] full_screen=
95
+ - [x] real_fps
96
+ - [x] fps
97
+ - [x] fps=
98
+ - [ ] frameskip?
99
+ - [ ] frameskip=
100
+ - [x] bgcolor
101
+ - [x] bgcolor=
102
+ - [ ] resize
103
+ - [ ] active?
104
+ - [ ] running_time
105
+ - [ ] get_screen_modes
106
+ - [ ] get_current_modes
107
+ - [ ] discard
108
+ - [ ] decide
109
+ - [ ] before_call
110
+ - [ ] after_call
111
+
112
+ These methods will not be supported.
113
+
114
+ - caption
115
+ - caption=
116
+ - create
117
+ - close
118
+ - created?
119
+ - closed?
120
+ - update
121
+ - sync
122
+ - load_icon
123
+ - hWnd
124
+ - min_filter
125
+ - min_filter=
126
+ - mag_filter
127
+ - mag_filter=
128
+
129
+ ## class Font
130
+
131
+ - [ ] Font.new - partially
132
+ - [x] Font.default
133
+ - [x] Font.default=
134
+ - [ ] get_width
135
+ - [x] size
136
+ - [x] fontname
137
+ - [ ] name
138
+ - [ ] italic
139
+ - [ ] weight
140
+ - [ ] auto_fitting
141
+ - [ ] info
142
+
143
+ These methods will not be supported.
144
+
145
+ - install
146
+ - dispose
147
+ - disposed?
148
+
149
+ ## class Image
150
+
151
+ - [x] Image.new
152
+ - [ ] Image.load_tiles
153
+ - [ ] Image.create_from_array
154
+ - [ ] Image.load_from_file_in_memory
155
+ - [ ] Image.perlin_noise
156
+ - [ ] Image.octave_perlin_noise
157
+ - [ ] Image.custom_perlin_noise
158
+ - [ ] Image.perlin_seed
159
+ - [x] `[]`
160
+ - [x] `[]=`
161
+ - [x] compare
162
+ - [x] line
163
+ - [x] box
164
+ - [x] box_fill
165
+ - [x] circle
166
+ - [x] circle_fill
167
+ - [x] triangle
168
+ - [x] triangle_fill
169
+ - [x] fill
170
+ - [x] clear
171
+ - [ ] copy_rect
172
+ - [x] draw
173
+ - [ ] draw_font - partially
174
+ - [ ] draw_font_ex
175
+ - [ ] save
176
+ - [x] slice
177
+ - [x] slice_tiles
178
+ - [ ] dup
179
+ - [ ] clone
180
+ - [ ] set_color_key
181
+ - [x] width
182
+ - [x] height
183
+ - [ ] flush
184
+ - [ ] effect_image_font
185
+ - [ ] change_hls
186
+
187
+ These methods will not be supported.
188
+
189
+ - Image.load (use Image.register and `Image.[]` instead)
190
+ - dispose
191
+ - delayed_dispose
192
+ - disposed?
193
+
194
+ ## class RenderTarget
195
+ ## class Shader
196
+ ## class Shader::Core
197
+ ## class Sound
198
+
199
+ - [ ] Sound.load_from_memory
200
+ - [x] play
201
+ - [ ] start=
202
+ - [ ] loop_start=
203
+ - [ ] loop_end=
204
+ - [ ] loop_count=
205
+ - [x] stop
206
+ - [ ] set_volume
207
+ - [ ] pan
208
+ - [ ] pan=
209
+ - [ ] frequency
210
+ - [ ] frequency=
211
+
212
+ These methods will not be supported.
213
+
214
+ - Sound.new (use Sound.register and `Sound.[]` instead)
215
+ - dispose
216
+ - disposed?
217
+
218
+ ## class SoundEffect
219
+
220
+ - [x] SoundEffect.new
221
+ - [ ] add
222
+ - [x] play
223
+ - [x] stop
224
+ - [ ] save
225
+
226
+ These methods will not be supported.
227
+
228
+ - disposed?
229
+
230
+ ## class Sprite
231
+
232
+ - [x] Sprite.new
233
+ - [x] Sprite.check
234
+ - [x] Sprite.update
235
+ - [x] Sprite.draw
236
+ - [x] Sprite.clean
237
+ - [x] draw
238
+ - [x] `===`
239
+ - [x] check
240
+ - [x] x
241
+ - [x] x=
242
+ - [x] y
243
+ - [x] y=
244
+ - [x] z
245
+ - [x] z=
246
+ - [ ] angle
247
+ - [ ] angle=
248
+ - [ ] scale_x
249
+ - [ ] scale_x=
250
+ - [ ] scale_y
251
+ - [ ] scale_y=
252
+ - [ ] center_x
253
+ - [ ] center_x=
254
+ - [ ] center_y
255
+ - [ ] center_y=
256
+ - [ ] alpha
257
+ - [ ] alpha=
258
+ - [ ] blend
259
+ - [ ] blend=
260
+ - [ ] shader
261
+ - [ ] shader=
262
+ - [x] image
263
+ - [x] image=
264
+ - [ ] target
265
+ - [ ] target=
266
+ - [x] collision
267
+ - [x] collision=
268
+ - [x] collision_enable
269
+ - [x] collision_enable=
270
+ - [ ] collision_sync
271
+ - [ ] collision_sync=
272
+ - [x] visible
273
+ - [x] visible=
274
+ - [x] vanish
275
+ - [x] vanished?
276
+ - [ ] param_hash
277
+ - [ ] offset_sync
278
+ - [ ] offset_sync=