opal-phaserjs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +34 -0
- data/README.md +32 -0
- data/demo/.ruby-version +1 -0
- data/demo/Gemfile +4 -0
- data/demo/Gemfile.lock +30 -0
- data/demo/app/main.rb +16 -0
- data/demo/block.png +0 -0
- data/demo/config.ru +10 -0
- data/demo/index.html +18 -0
- data/demo/main.js +15 -0
- data/demo/phaser.png +0 -0
- data/demo/style.css +5 -0
- data/lib/opal-phaser.rb +1 -0
- data/lib/opal/phaser.rb +8 -0
- data/lib/opal/phaser/core.rb +2 -0
- data/lib/opal/phaser/core/game.rb +34 -0
- data/lib/opal/phaser/core/state.rb +43 -0
- data/lib/opal/phaser/version.rb +5 -0
- data/opal-phaserjs.gemspec +21 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6b662c35d744907c498c5bdff83a8e5dfa78d0e7
|
4
|
+
data.tar.gz: 1ceb7d31a8f6558caf07cb7d7822437b11d8eac2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ad77e2d568065f6d14dc9bcc104d33e4b5f8d85e97837f20e26cf2b750dc585ad964c0b793e00b35a9848bfd11dda347c0e44586bc97dd4c4d030ea620c50d54
|
7
|
+
data.tar.gz: 00a75df933e9ca6c253c66bd4d3fe440820df95acffdd6814c43352475f4d860500a58ba68369dc83c3f8bd3eefd09b9a3741bad7ccff1c014e31776f43c90ca
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
prepros.cfg
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
opal-phaserjs (0.0.1)
|
5
|
+
opal (~> 0.6.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
hike (1.2.3)
|
11
|
+
json (1.8.1)
|
12
|
+
multi_json (1.10.1)
|
13
|
+
opal (0.6.3)
|
14
|
+
source_map
|
15
|
+
sprockets
|
16
|
+
rack (1.6.0)
|
17
|
+
rake (10.4.2)
|
18
|
+
source_map (3.0.1)
|
19
|
+
json
|
20
|
+
sprockets (2.12.3)
|
21
|
+
hike (~> 1.2)
|
22
|
+
multi_json (~> 1.0)
|
23
|
+
rack (~> 1.0)
|
24
|
+
tilt (~> 1.1, != 1.3.0)
|
25
|
+
tilt (1.4.1)
|
26
|
+
yard (0.8.7.6)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
opal-phaserjs!
|
33
|
+
rake
|
34
|
+
yard
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# opal-phaserjs
|
2
|
+
The goal of this project is to completely wrap the Phaser api in opal, to allow developers to write HTML5 and WebGL games entirely from ruby code.
|
3
|
+
|
4
|
+
If you have not heard of Phaser, check out these links:
|
5
|
+
|
6
|
+
* Phaser: https://github.com/photonstorm/phaser
|
7
|
+
* Phaser Examples: https://github.com/photonstorm/phaser-examples
|
8
|
+
|
9
|
+
## Cloning this repository
|
10
|
+
|
11
|
+
```
|
12
|
+
$ git clone https://github.com/orbitalimpact/opal-phaserjs
|
13
|
+
```
|
14
|
+
|
15
|
+
## Getting involved
|
16
|
+
|
17
|
+
To contribute to this project, follow the steps below.
|
18
|
+
|
19
|
+
1. Fork the repo ( https://github.com/orbitalimpact/opal-phaserjs/fork )
|
20
|
+
2. Create your feature branch (`git checkout -b new-branch`)
|
21
|
+
3. Commit your changes (`git commit -am 'description of commit'`)
|
22
|
+
4. Push to the branch (`git push origin new-branch`)
|
23
|
+
5. Create a Pull Request
|
24
|
+
|
25
|
+
## Licenses
|
26
|
+
|
27
|
+
Phaser and all examples are released under the MIT License: http://opensource.org/licenses/MIT
|
28
|
+
|
29
|
+
opal-phaser is released under the Berkeley Software Distribution (BSD) 3-Clause License: http://opensource.org/licenses/BSD-3-Clause
|
30
|
+
|
31
|
+
Copyright (c) 2014, Orbital Impact
|
32
|
+
All rights reserved.
|
data/demo/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/demo/Gemfile
ADDED
data/demo/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
opal-phaserjs (0.0.1)
|
5
|
+
opal (~> 0.6.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
hike (1.2.3)
|
11
|
+
json (1.8.1)
|
12
|
+
multi_json (1.10.1)
|
13
|
+
opal (0.6.3)
|
14
|
+
source_map
|
15
|
+
sprockets
|
16
|
+
rack (1.6.0)
|
17
|
+
source_map (3.0.1)
|
18
|
+
json
|
19
|
+
sprockets (2.12.3)
|
20
|
+
hike (~> 1.2)
|
21
|
+
multi_json (~> 1.0)
|
22
|
+
rack (~> 1.0)
|
23
|
+
tilt (~> 1.1, != 1.3.0)
|
24
|
+
tilt (1.4.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
opal-phaserjs!
|
data/demo/app/main.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'opal'
|
2
|
+
require 'opal/phaser'
|
3
|
+
|
4
|
+
class Game
|
5
|
+
def initialize
|
6
|
+
@phaser = Phaser::Game.new(800, 654) do |state|
|
7
|
+
state.preload do |game|
|
8
|
+
game.load.image('logo', 'phaser.png')
|
9
|
+
end
|
10
|
+
|
11
|
+
state.create do |game|
|
12
|
+
game.add.sprite(game.world.centerX, game.world.centerY, 'logo')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/demo/block.png
ADDED
Binary file
|
data/demo/config.ru
ADDED
data/demo/index.html
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset= "utf-8" />
|
5
|
+
<title>Opal-Phaser</title>
|
6
|
+
<link rel="stylesheet" href="style.css">
|
7
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/phaser/2.2.1/phaser.js"></script>
|
8
|
+
<script src="/assets/main.js"></script>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<script>
|
13
|
+
window.onload = function() {
|
14
|
+
Opal.Game.$new()
|
15
|
+
}
|
16
|
+
</script>
|
17
|
+
</body>
|
18
|
+
</html>
|
data/demo/main.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
// This file is just a sanity check to see if this demo works in plain JS
|
2
|
+
|
3
|
+
function Game () {
|
4
|
+
this.game = new Phaser.Game(800, 600, Phaser.AUTO, "", { preload: preload, create: create });
|
5
|
+
|
6
|
+
function preload () {
|
7
|
+
this.game.load.image("logo", "phaser.png");
|
8
|
+
}
|
9
|
+
|
10
|
+
function create () {
|
11
|
+
this.logo = this.game.add.sprite(100, 100, "logo");
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
phaserGame = new Game();
|
data/demo/phaser.png
ADDED
Binary file
|
data/demo/style.css
ADDED
data/lib/opal-phaser.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'opal/phaser'
|
data/lib/opal/phaser.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'native'
|
2
|
+
module Phaser
|
3
|
+
AUTO = %x{ Phaser.AUTO }
|
4
|
+
|
5
|
+
class Game
|
6
|
+
include ::Native
|
7
|
+
def initialize(width, height, renderer = Phaser::AUTO,
|
8
|
+
parent = '', state = nil, transparent = false, antialias = true,
|
9
|
+
physics = nil, &block)
|
10
|
+
|
11
|
+
if state
|
12
|
+
state.game = self
|
13
|
+
else
|
14
|
+
state = State.new(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
if block_given?
|
18
|
+
state.instance_eval(&block)
|
19
|
+
end
|
20
|
+
|
21
|
+
_native = %x{
|
22
|
+
new Phaser.Game(width, height, renderer, parent, #{state.to_n}, transparent,
|
23
|
+
antialias, physics)
|
24
|
+
}
|
25
|
+
super(_native)
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_native :load, :load
|
29
|
+
alias_native :add, :add
|
30
|
+
alias_native :world, :world
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Phaser
|
2
|
+
class State
|
3
|
+
attr_writer :game
|
4
|
+
def initialize(game = nil, &block)
|
5
|
+
@game = game
|
6
|
+
@native = %x{ new Phaser.State() }
|
7
|
+
|
8
|
+
@preload = proc {}
|
9
|
+
@create = proc {}
|
10
|
+
@update = proc {}
|
11
|
+
@render = proc {}
|
12
|
+
|
13
|
+
if block_given?
|
14
|
+
instance_eval(&block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def preload(&block)
|
20
|
+
@preload = proc { block.call(@game) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def create(&block)
|
24
|
+
@create = proc { block.call(@game) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def update(&block)
|
28
|
+
@update = proc { block.call(@game) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def render(&block)
|
32
|
+
@render = proc { block.call(@game) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_n
|
36
|
+
%x{
|
37
|
+
var obj = { preload: #@preload, create: #@create }
|
38
|
+
}
|
39
|
+
|
40
|
+
return %x{ obj }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/opal/phaser/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'opal-phaserjs'
|
6
|
+
s.version = Opal::Phaser::VERSION
|
7
|
+
s.authors = ['George Plymale', 'Gabriel Rios']
|
8
|
+
s.email = ['george@orbitalimpact.com', 'gabrielfalcaorios@gmail.com']
|
9
|
+
s.homepage = 'http://github.com/orbitalimpact/opal-phaserjs'
|
10
|
+
s.summary = 'Opal access to phaser'
|
11
|
+
s.description = 'Phaser library for opal'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_paths = ['lib']
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'opal', '~> 0.6.0'
|
19
|
+
s.add_development_dependency 'yard'
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal-phaserjs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- George Plymale
|
8
|
+
- Gabriel Rios
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: opal
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.6.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.6.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: yard
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: Phaser library for opal
|
57
|
+
email:
|
58
|
+
- george@orbitalimpact.com
|
59
|
+
- gabrielfalcaorios@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- README.md
|
68
|
+
- demo/.ruby-version
|
69
|
+
- demo/Gemfile
|
70
|
+
- demo/Gemfile.lock
|
71
|
+
- demo/app/main.rb
|
72
|
+
- demo/block.png
|
73
|
+
- demo/config.ru
|
74
|
+
- demo/index.html
|
75
|
+
- demo/main.js
|
76
|
+
- demo/phaser.png
|
77
|
+
- demo/style.css
|
78
|
+
- lib/opal-phaser.rb
|
79
|
+
- lib/opal/phaser.rb
|
80
|
+
- lib/opal/phaser/core.rb
|
81
|
+
- lib/opal/phaser/core/game.rb
|
82
|
+
- lib/opal/phaser/core/state.rb
|
83
|
+
- lib/opal/phaser/version.rb
|
84
|
+
- opal-phaserjs.gemspec
|
85
|
+
homepage: http://github.com/orbitalimpact/opal-phaserjs
|
86
|
+
licenses: []
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.2.2
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Opal access to phaser
|
108
|
+
test_files: []
|
109
|
+
has_rdoc:
|