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.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.ignore +5 -0
- data/.nojekyll +4 -0
- data/CHANGELOG.md +90 -0
- data/DEVELOPMENT.md +57 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +39 -0
- data/README.md +22 -0
- data/Rakefile +66 -0
- data/TODO.md +278 -0
- data/build/dxopal.js +46590 -0
- data/build/dxopal.min.js +1 -0
- data/config.ru +39 -0
- data/doc/api/DXOpal.html +129 -0
- data/doc/api/DXOpal/Font.html +485 -0
- data/doc/api/DXOpal/Image.html +2533 -0
- data/doc/api/DXOpal/Input.html +1086 -0
- data/doc/api/DXOpal/Input/MouseCodes.html +146 -0
- data/doc/api/DXOpal/RemoteResource.html +641 -0
- data/doc/api/DXOpal/Sound.html +568 -0
- data/doc/api/DXOpal/SoundEffect.html +444 -0
- data/doc/api/DXOpal/SoundEffect/WaveTypes.html +130 -0
- data/doc/api/DXOpal/Sprite.html +1419 -0
- data/doc/api/DXOpal/Window.html +1915 -0
- data/doc/api/_index.html +228 -0
- data/doc/api/class_list.html +51 -0
- data/doc/api/css/common.css +1 -0
- data/doc/api/css/full_list.css +58 -0
- data/doc/api/css/style.css +492 -0
- data/doc/api/file.CHANGELOG.html +162 -0
- data/doc/api/file.README.html +124 -0
- data/doc/api/file_list.html +61 -0
- data/doc/api/frames.html +17 -0
- data/doc/api/index.html +124 -0
- data/doc/api/js/app.js +248 -0
- data/doc/api/js/full_list.js +216 -0
- data/doc/api/js/jquery.js +4 -0
- data/doc/api/method_list.html +939 -0
- data/doc/api/top-level-namespace.html +110 -0
- data/doc/en/index.html +93 -0
- data/doc/ja/index.html +92 -0
- data/dxopal.gemspec +29 -0
- data/exe/dxopal +44 -0
- data/index.html +56 -0
- data/opal/dxopal.rb +54 -0
- data/opal/dxopal/constants/colors.rb +16 -0
- data/opal/dxopal/font.rb +20 -0
- data/opal/dxopal/image.rb +301 -0
- data/opal/dxopal/input.rb +170 -0
- data/opal/dxopal/input/key_codes.rb +168 -0
- data/opal/dxopal/remote_resource.rb +65 -0
- data/opal/dxopal/sound.rb +53 -0
- data/opal/dxopal/sound_effect.rb +84 -0
- data/opal/dxopal/sprite.rb +94 -0
- data/opal/dxopal/sprite/collision_area.rb +288 -0
- data/opal/dxopal/sprite/collision_check.rb +106 -0
- data/opal/dxopal/sprite/collision_checker.rb +169 -0
- data/opal/dxopal/sprite/physics.rb +82 -0
- data/opal/dxopal/version.rb +3 -0
- data/opal/dxopal/window.rb +173 -0
- data/template/index.html +13 -0
- data/template/main.rb +9 -0
- metadata +191 -0
@@ -0,0 +1,110 @@
|
|
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
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "";
|
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</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">Top Level Namespace</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>Top Level Namespace
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
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>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
</p>
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<div id="footer">
|
103
|
+
Generated on Tue Oct 17 13:56:27 2017 by
|
104
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
|
+
0.9.9 (ruby-2.4.2).
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</body>
|
110
|
+
</html>
|
data/doc/en/index.html
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset= "utf-8" />
|
5
|
+
<title>DXOpal demo</title>
|
6
|
+
|
7
|
+
<link href='https://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="stylesheet" href="../../vendor/pages-themes-dinky-14e8031/_site/assets/css/style.css">
|
9
|
+
<script src="../../vendor/pages-themes-dinky-14e8031/_site/assets/js/scale.fix.js"></script>
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<div class="wrapper">
|
15
|
+
<header>
|
16
|
+
<h1 class="header"><a href='../../index.html'>DXOpal</a></h1>
|
17
|
+
<p class="header">
|
18
|
+
<a href='index.html'>English</a> | <a href='../ja/index.html'>日本語</a>
|
19
|
+
</p>
|
20
|
+
<p class="header">
|
21
|
+
DXOpal (<a href='https://github.com/yhara/dxopal'>github</a>) is a game development framework for <a href='http://opalrb.com'>Opal</a>.
|
22
|
+
</p>
|
23
|
+
</header>
|
24
|
+
|
25
|
+
<section>
|
26
|
+
<h2>Overview</h2>
|
27
|
+
<p>
|
28
|
+
DXOpal (<a href='https://github.com/yhara/dxopal'>github</a>) is a RubyGem to make browser games with Ruby.
|
29
|
+
API is similar to <a href='http://dxruby.osdn.jp/'>DXRuby</a>.
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<h2>Examples</h2>
|
33
|
+
<ul>
|
34
|
+
<li>
|
35
|
+
<a href="../../examples/apple_catcher/index.html">Apple Catcher</a>
|
36
|
+
</li>
|
37
|
+
<li>
|
38
|
+
<a href="../../examples/collision/index.html">Collision detection</a>
|
39
|
+
</li>
|
40
|
+
<li>
|
41
|
+
<a href="../../examples/triangles/index.html">STG-like demo</a>
|
42
|
+
</li>
|
43
|
+
<li>
|
44
|
+
<a href="../../examples/matter/index.html">Physics</a> (experimental / powered by <a href='http://brm.io/matter-js/'>Matter.js</a>)
|
45
|
+
</li>
|
46
|
+
</ul>
|
47
|
+
|
48
|
+
<h2>Getting Started</h2>
|
49
|
+
<h3>If you have Ruby installed:</h3>
|
50
|
+
<p>
|
51
|
+
<pre><code>$ gem install dxopal
|
52
|
+
$ mkdir game1
|
53
|
+
$ cd game1
|
54
|
+
$ dxopal init
|
55
|
+
$ dxopal server</code></pre>
|
56
|
+
</p>
|
57
|
+
<p>
|
58
|
+
Open <a href='http://localhost:7521/index.html'>http://localhost:7521/index.html</a> in browser.
|
59
|
+
</p>
|
60
|
+
<p>
|
61
|
+
Then edit main.rb and reload browser.
|
62
|
+
</p>
|
63
|
+
|
64
|
+
<h3>If you don't want to install Ruby:</h3>
|
65
|
+
<p>
|
66
|
+
If you have Git command, clone <a href='https://github.com/yhara/dxopal-starter-kit'>yhara/dxopal-starter-kit</a>.
|
67
|
+
Otherwise, download latest zip from <a href='https://github.com/yhara/dxopal-starter-kit/releases'>releases</a>.
|
68
|
+
</p>
|
69
|
+
<p>
|
70
|
+
Then open index.html with Firefox. (Note: you cannot use Google Chrome because it doesn't allow Ajax access to <code>file://</code>.)
|
71
|
+
</p>
|
72
|
+
<p>
|
73
|
+
Then edit main.rb and reload the browser tab.
|
74
|
+
</p>
|
75
|
+
|
76
|
+
<h2>Resources</h2>
|
77
|
+
<ul>
|
78
|
+
<li>
|
79
|
+
<a href="../api/index.html">API reference</a>
|
80
|
+
</li>
|
81
|
+
<li>
|
82
|
+
<a href="https://github.com/yhara/dxopal">Source code (github)</a>
|
83
|
+
</li>
|
84
|
+
</ul>
|
85
|
+
|
86
|
+
</section>
|
87
|
+
<footer>
|
88
|
+
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the <a href='https://github.com/pages-themes/dinky'>Dinky theme</a></small></p>
|
89
|
+
</footer>
|
90
|
+
</div>
|
91
|
+
</body>
|
92
|
+
</html>
|
93
|
+
|
data/doc/ja/index.html
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset= "utf-8" />
|
5
|
+
<title>DXOpal demo</title>
|
6
|
+
|
7
|
+
<link href='https://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="stylesheet" href="../../vendor/pages-themes-dinky-14e8031/_site/assets/css/style.css">
|
9
|
+
<script src="../../vendor/pages-themes-dinky-14e8031/_site/assets/js/scale.fix.js"></script>
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<div class="wrapper">
|
15
|
+
<header>
|
16
|
+
<h1 class="header"><a href='../../index.html'>DXOpal</a></h1>
|
17
|
+
<p class="header">
|
18
|
+
<a href='../en/index.html'>English</a> | <a href='index.html'>日本語</a>
|
19
|
+
</p>
|
20
|
+
<p class="header">
|
21
|
+
DXOpal (<a href='https://github.com/yhara/dxopal'>github</a>) は<a href='http://opalrb.com'>Opal</a>のためのゲームフレームワークです。
|
22
|
+
</p>
|
23
|
+
</header>
|
24
|
+
|
25
|
+
<section>
|
26
|
+
<h2>概要</h2>
|
27
|
+
<p>
|
28
|
+
DXOpalはRuby(<a href='http://opalrb.com'>Opal</a>)でブラウザゲームを作るためのライブラリです。
|
29
|
+
<a href='http://dxruby.osdn.jp/'>DXRuby</a>に似たAPIを持っています。
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<h2>デモ</h2>
|
33
|
+
<ul>
|
34
|
+
<li>
|
35
|
+
<a href="../../examples/apple_catcher/index.html">Apple Catcher</a>
|
36
|
+
</li>
|
37
|
+
<li>
|
38
|
+
<a href="../../examples/collision/index.html">Collision detection</a>
|
39
|
+
</li>
|
40
|
+
<li>
|
41
|
+
<a href="../../examples/triangles/index.html">STG-like demo</a>
|
42
|
+
</li>
|
43
|
+
<li>
|
44
|
+
<a href="../../examples/matter/index.html">Physics</a> (experimental / powered by <a href='http://brm.io/matter-js/'>Matter.js</a>)
|
45
|
+
</li>
|
46
|
+
</ul>
|
47
|
+
|
48
|
+
<h2>セットアップ</h2>
|
49
|
+
<h3>Rubyがインストール済みのとき</h3>
|
50
|
+
<p>
|
51
|
+
<pre><code>$ gem install dxopal
|
52
|
+
$ mkdir game1
|
53
|
+
$ cd game1
|
54
|
+
$ dxopal init
|
55
|
+
$ dxopal server</code></pre>
|
56
|
+
</p>
|
57
|
+
<p>
|
58
|
+
<a href='http://localhost:7521/index.html'>http://localhost:7521/index.html</a>を開くと画面が出ます。
|
59
|
+
</p>
|
60
|
+
<p>
|
61
|
+
main.rbを編集してブラウザをリロードすると動くはずです。
|
62
|
+
</p>
|
63
|
+
|
64
|
+
<h3>Rubyをインストールしたくないとき</h3>
|
65
|
+
<p>
|
66
|
+
Gitコマンドが使える場合は<a href='https://github.com/yhara/dxopal-starter-kit'>yhara/dxopal-starter-kit</a>をgit cloneしてください。そうでない場合は<a href='https://github.com/yhara/dxopal-starter-kit/releases'>releases</a>から最新のzipをダウンロードして展開してください。
|
67
|
+
</p>
|
68
|
+
<p>
|
69
|
+
index.htmlをFirefoxで開くと画面が出ます (Google Chromeは<code>file://</code>へのAjaxアクセスができないのでだめ)。
|
70
|
+
</p>
|
71
|
+
<p>
|
72
|
+
main.rbを編集してブラウザをリロードすると動くはずです。
|
73
|
+
</p>
|
74
|
+
|
75
|
+
<h2>リンク</h2>
|
76
|
+
<ul>
|
77
|
+
<li>
|
78
|
+
<a href="../api/index.html">APIリファレンス(英語)</a>
|
79
|
+
</li>
|
80
|
+
<li>
|
81
|
+
<a href="https://github.com/yhara/dxopal">ソースコード(github)</a>
|
82
|
+
</li>
|
83
|
+
</ul>
|
84
|
+
|
85
|
+
</section>
|
86
|
+
<footer>
|
87
|
+
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the <a href='https://github.com/pages-themes/dinky'>Dinky theme</a></small></p>
|
88
|
+
</footer>
|
89
|
+
</div>
|
90
|
+
</body>
|
91
|
+
</html>
|
92
|
+
|
data/dxopal.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require_relative 'opal/dxopal/version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dxopal"
|
8
|
+
spec.version = DXOpal::VERSION
|
9
|
+
spec.authors = ["Yutaka HARA"]
|
10
|
+
spec.email = ["yutaka.hara+github@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Game development framework for Opal}
|
13
|
+
spec.homepage = "https://github.com/yhara/dxopal"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(examples|vendor|test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "opal", "~> 0.10.5"
|
24
|
+
spec.add_runtime_dependency "thor", "~> 0.19.1"
|
25
|
+
spec.add_runtime_dependency "rack", "~> 2.0"
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "yard", "~> 0.9.9"
|
29
|
+
end
|
data/exe/dxopal
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
require 'rack'
|
4
|
+
require 'thor'
|
5
|
+
require_relative '../opal/dxopal/version' # Import DXOpal::VERSION
|
6
|
+
|
7
|
+
module DXOpal
|
8
|
+
class Cli < Thor
|
9
|
+
GEM_ROOT = "#{__dir__}/../"
|
10
|
+
|
11
|
+
desc "init", "Copy template files into this directory"
|
12
|
+
def init
|
13
|
+
FileUtils.cp("#{GEM_ROOT}/template/index.html", Dir.pwd)
|
14
|
+
puts "Wrote index.html"
|
15
|
+
FileUtils.cp("#{GEM_ROOT}/template/main.rb", Dir.pwd)
|
16
|
+
puts "Wrote main.rb"
|
17
|
+
FileUtils.cp("#{GEM_ROOT}/build/dxopal.min.js", Dir.pwd)
|
18
|
+
puts "Wrote dxopal.min.js"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "update", "Update dxopal.min.js"
|
22
|
+
def update
|
23
|
+
src = "#{GEM_ROOT}/build/dxopal.min.js"
|
24
|
+
dst = "#{Dir.pwd}/dxopal.min.js"
|
25
|
+
if File.exist?(dst) && File.read(src) == File.read(dst)
|
26
|
+
puts "dxopal.min.js is already up-to-date."
|
27
|
+
return
|
28
|
+
end
|
29
|
+
FileUtils.cp(src, dst)
|
30
|
+
puts "Wrote #{dst}"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "server", "Start local server"
|
34
|
+
def server
|
35
|
+
puts "Starting DXOpal Server"
|
36
|
+
puts "(Open http://localhost:7521/index.html in browser)"
|
37
|
+
puts "---"
|
38
|
+
app = Rack::Directory.new(Dir.pwd)
|
39
|
+
Rack::Server.start(app: app, Port: 7521)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
DXOpal::Cli.start
|
data/index.html
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset= "utf-8" />
|
5
|
+
<title>DXOpal demo</title>
|
6
|
+
|
7
|
+
<link href='https://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>
|
8
|
+
<link rel="stylesheet" href="vendor/pages-themes-dinky-14e8031/_site/assets/css/style.css">
|
9
|
+
<script src="vendor/pages-themes-dinky-14e8031/_site/assets/js/scale.fix.js"></script>
|
10
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<div class="wrapper">
|
15
|
+
<header>
|
16
|
+
<h1 class="header"><a href='index.html'>DXOpal</a></h1>
|
17
|
+
<p class="header">
|
18
|
+
<a href='doc/en/index.html'>English</a> | <a href='doc/ja/index.html'>日本語</a>
|
19
|
+
</p>
|
20
|
+
</header>
|
21
|
+
|
22
|
+
<section>
|
23
|
+
<canvas id="dxopal-canvas" style='float: left'></canvas>
|
24
|
+
<div id="editor" style='width: 350px; height: 300px; position: relative'></div>
|
25
|
+
<input type='button' style='float: right' id='run' value='Run'>
|
26
|
+
</section>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<script type="text/javascript" src="build/dxopal.js"></script>
|
30
|
+
<script>
|
31
|
+
eval(Opal.compile("DXOpal::Input.keyevent_target = `document.getElementById('dxopal-canvas')`"));
|
32
|
+
</script>
|
33
|
+
<script type="text/ruby" src="examples/top_page/main.rb"></script>
|
34
|
+
|
35
|
+
<script type="text/javascript" src="examples/_vendor/ace/ace.js" type="text/javascript" charset="utf-8"></script>
|
36
|
+
<script type="text/javascript" src="examples/_vendor/jquery-3.2.1.js"></script>
|
37
|
+
<script>
|
38
|
+
var editor = ace.edit("editor");
|
39
|
+
editor.setTheme("ace/theme/github");
|
40
|
+
editor.getSession().setMode("ace/mode/ruby");
|
41
|
+
$.get("examples/top_page/main.rb", function(rb) {
|
42
|
+
editor.setValue(rb, -1); // -1: set cursor to document start
|
43
|
+
});
|
44
|
+
$('#run').on("click", function() {
|
45
|
+
try {
|
46
|
+
eval(Opal.compile(editor.getValue()));
|
47
|
+
}
|
48
|
+
catch(e) {
|
49
|
+
alert(e);
|
50
|
+
throw e;
|
51
|
+
}
|
52
|
+
});
|
53
|
+
</script>
|
54
|
+
</body>
|
55
|
+
</html>
|
56
|
+
|
data/opal/dxopal.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'opal'
|
2
|
+
require 'console'; def console; $console; end
|
3
|
+
|
4
|
+
require 'dxopal/constants/colors'
|
5
|
+
require 'dxopal/font'
|
6
|
+
require 'dxopal/input'
|
7
|
+
require 'dxopal/input/key_codes'
|
8
|
+
require 'dxopal/image'
|
9
|
+
require 'dxopal/sound'
|
10
|
+
require 'dxopal/sound_effect'
|
11
|
+
require 'dxopal/sprite'
|
12
|
+
require 'dxopal/window'
|
13
|
+
require 'dxopal/version'
|
14
|
+
# Enable runtime compilation of Opal code (so that you can make games
|
15
|
+
# without even install Ruby)
|
16
|
+
require 'opal-parser'
|
17
|
+
def require_remote(url)
|
18
|
+
%x{
|
19
|
+
var r = new XMLHttpRequest();
|
20
|
+
r.overrideMimeType("text/plain"); // Patch for Firefox + file://
|
21
|
+
r.open("GET", url, false);
|
22
|
+
r.send('');
|
23
|
+
}
|
24
|
+
eval `r.responseText`
|
25
|
+
end
|
26
|
+
|
27
|
+
# These libraries will be included in dxopal.js:
|
28
|
+
require 'pp'
|
29
|
+
|
30
|
+
module DXOpal
|
31
|
+
include DXOpal::Constants::Colors
|
32
|
+
include DXOpal::Input::KeyCodes
|
33
|
+
include DXOpal::Input::MouseCodes
|
34
|
+
include DXOpal::SoundEffect::WaveTypes
|
35
|
+
|
36
|
+
# Like `Kernel.p`, but prints only limited times for each `key`
|
37
|
+
# This is useful for debugging your game without flooding the
|
38
|
+
# developer console.
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
# p_ player_x: @player.x
|
42
|
+
# p_({player_x: @player.x}, 20)
|
43
|
+
P_CT = Hash.new{|h, k| h[k] = 0}
|
44
|
+
def p_(hash, n=10)
|
45
|
+
key = hash.keys.sort.join
|
46
|
+
return if P_CT[key] >= n
|
47
|
+
`console.log(#{hash.inspect})`
|
48
|
+
P_CT[key] += 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# `require 'dxopal'` will automatically import names like `Window` to the
|
53
|
+
# toplevel (as `require 'dxruby'` does)
|
54
|
+
include DXOpal
|