shank 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shank/version.rb +1 -1
- data/lib/shank.rb +9 -2
- data/pixie.json +13 -0
- data/shank.gemspec +2 -0
- data/source/{init.coffee → _init.coffee} +0 -0
- data/source/engine.gamepads.coffee +6 -8
- data/source/error_handler.coffee +1 -3
- data/source/gamepads.coffee +21 -7
- data/source/gamepads.combined_controller.coffee +38 -0
- data/source/gamepads.controller.coffee +25 -23
- data/source/gamepads.keyboard_controller.coffee +90 -0
- data/source/keydown.coffee +5 -2
- data/source/mouse.coffee +10 -3
- data/source/music.coffee +1 -3
- data/source/shank.coffee +1 -17
- data/source/sound.coffee +27 -12
- metadata +82 -68
- data/source/engine_stats.coffee +0 -12
- data/source/joysticks.coffee +0 -240
- data/source/jquery.reverse_merge.coffee +0 -21
- data/test/jquery.reverse_merge.coffee +0 -43
- data/test/xstats.coffee +0 -7
- data/vendor/assets/javascripts/xstats.js +0 -767
metadata
CHANGED
@@ -1,61 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: shank
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 5
|
10
|
-
version: 0.0.5
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Matt Diebolt
|
14
9
|
- Daniel X. Moore
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
date: 2013-04-24 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
22
23
|
type: :development
|
23
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: coffee-script
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
24
34
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
- 0
|
31
|
-
version: "0"
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
32
40
|
prerelease: false
|
33
|
-
|
34
|
-
|
35
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sprockets
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
36
55
|
type: :runtime
|
37
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: pixie_dust
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
38
66
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
- 0
|
45
|
-
version: "0"
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :runtime
|
46
72
|
prerelease: false
|
47
|
-
|
48
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
49
79
|
description: Polyfills for making games in the browser
|
50
|
-
email:
|
80
|
+
email:
|
51
81
|
- pixie@pixieengine.com
|
52
82
|
executables: []
|
53
|
-
|
54
83
|
extensions: []
|
55
|
-
|
56
84
|
extra_rdoc_files: []
|
57
|
-
|
58
|
-
files:
|
85
|
+
files:
|
59
86
|
- .gitignore
|
60
87
|
- Gemfile
|
61
88
|
- LICENSE
|
@@ -63,16 +90,16 @@ files:
|
|
63
90
|
- Rakefile
|
64
91
|
- lib/shank.rb
|
65
92
|
- lib/shank/version.rb
|
93
|
+
- pixie.json
|
66
94
|
- shank.gemspec
|
95
|
+
- source/_init.coffee
|
67
96
|
- source/engine.gamepads.coffee
|
68
|
-
- source/engine_stats.coffee
|
69
97
|
- source/error_handler.coffee
|
70
98
|
- source/gamepads.coffee
|
99
|
+
- source/gamepads.combined_controller.coffee
|
71
100
|
- source/gamepads.controller.coffee
|
72
|
-
- source/
|
73
|
-
- source/joysticks.coffee
|
101
|
+
- source/gamepads.keyboard_controller.coffee
|
74
102
|
- source/jquery.hotkeys.coffee
|
75
|
-
- source/jquery.reverse_merge.coffee
|
76
103
|
- source/keydown.coffee
|
77
104
|
- source/mouse.coffee
|
78
105
|
- source/music.coffee
|
@@ -81,46 +108,33 @@ files:
|
|
81
108
|
- source/shank.coffee
|
82
109
|
- source/sound.coffee
|
83
110
|
- source/storage.coffee
|
84
|
-
- test/jquery.reverse_merge.coffee
|
85
111
|
- test/keydown.coffee
|
86
112
|
- test/pixie_canvas.coffee
|
87
113
|
- test/request_animation_frame.coffee
|
88
114
|
- test/sound.coffee
|
89
115
|
- test/storage.coffee
|
90
|
-
- test/xstats.coffee
|
91
|
-
- vendor/assets/javascripts/xstats.js
|
92
116
|
homepage: https://github.com/PixieEngine/Shank
|
93
117
|
licenses: []
|
94
|
-
|
95
118
|
post_install_message:
|
96
119
|
rdoc_options: []
|
97
|
-
|
98
|
-
require_paths:
|
120
|
+
require_paths:
|
99
121
|
- lib
|
100
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
123
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
|
106
|
-
|
107
|
-
- 0
|
108
|
-
version: "0"
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
129
|
none: false
|
111
|
-
requirements:
|
112
|
-
- -
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
segments:
|
116
|
-
- 0
|
117
|
-
version: "0"
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
118
134
|
requirements: []
|
119
|
-
|
120
135
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.8.
|
136
|
+
rubygems_version: 1.8.24
|
122
137
|
signing_key:
|
123
138
|
specification_version: 3
|
124
139
|
summary: Sometimes you gotta stab someone to make a game
|
125
140
|
test_files: []
|
126
|
-
|
data/source/engine_stats.coffee
DELETED
data/source/joysticks.coffee
DELETED
@@ -1,240 +0,0 @@
|
|
1
|
-
root = (exports ? this)
|
2
|
-
|
3
|
-
root.Joysticks = ( ->
|
4
|
-
type = "application/x-boomstickjavascriptjoysticksupport"
|
5
|
-
plugin = null
|
6
|
-
MAX_BUFFER = 2000
|
7
|
-
AXIS_MAX = 32767 - MAX_BUFFER
|
8
|
-
DEAD_ZONE = AXIS_MAX * 0.2
|
9
|
-
TRIP_HIGH = AXIS_MAX * 0.75
|
10
|
-
TRIP_LOW = AXIS_MAX * 0.5
|
11
|
-
|
12
|
-
# Raw Joysticks data
|
13
|
-
previousJoysticks = []
|
14
|
-
joysticks = []
|
15
|
-
|
16
|
-
controllers = []
|
17
|
-
|
18
|
-
buttonMappingDefault =
|
19
|
-
"A": 1
|
20
|
-
"B": 2
|
21
|
-
|
22
|
-
# X/C, Y/D are interchangeable
|
23
|
-
"C": 4
|
24
|
-
"D": 8
|
25
|
-
"X": 4
|
26
|
-
"Y": 8
|
27
|
-
|
28
|
-
"R": 32
|
29
|
-
"RB": 32
|
30
|
-
"R1": 32
|
31
|
-
|
32
|
-
"L": 16
|
33
|
-
"LB": 16
|
34
|
-
"L1": 16
|
35
|
-
|
36
|
-
"SELECT": 64
|
37
|
-
"BACK": 64
|
38
|
-
|
39
|
-
"START": 128
|
40
|
-
|
41
|
-
"HOME": 256
|
42
|
-
"GUIDE": 256
|
43
|
-
|
44
|
-
"TL": 512
|
45
|
-
"TR": 1024
|
46
|
-
|
47
|
-
"ANY": 0xFFFFFF
|
48
|
-
|
49
|
-
buttonMappingOSX =
|
50
|
-
"A": 2048
|
51
|
-
"B": 4096
|
52
|
-
|
53
|
-
"C": 8192
|
54
|
-
"D": 16384
|
55
|
-
"X": 8192
|
56
|
-
"Y": 16384
|
57
|
-
|
58
|
-
"R": 512
|
59
|
-
|
60
|
-
"L": 256
|
61
|
-
|
62
|
-
"SELECT": 32
|
63
|
-
"BACK": 32
|
64
|
-
|
65
|
-
"START": 16
|
66
|
-
|
67
|
-
"HOME": 1024
|
68
|
-
|
69
|
-
"LT": 64
|
70
|
-
"TR": 128
|
71
|
-
|
72
|
-
"ANY": 0xFFFFFF0
|
73
|
-
|
74
|
-
axisMappingDefault =
|
75
|
-
0: 0
|
76
|
-
1: 1
|
77
|
-
2: 2
|
78
|
-
3: 3
|
79
|
-
4: 4
|
80
|
-
5: 5
|
81
|
-
|
82
|
-
axisMappingOSX =
|
83
|
-
0: 2
|
84
|
-
1: 3
|
85
|
-
2: 4
|
86
|
-
3: 5
|
87
|
-
4: 0
|
88
|
-
5: 1
|
89
|
-
|
90
|
-
displayInstallPrompt = (text, url) ->
|
91
|
-
$ "<a />",
|
92
|
-
css:
|
93
|
-
backgroundColor: "yellow"
|
94
|
-
boxSizing: "border-box"
|
95
|
-
color: "#000"
|
96
|
-
display: "block"
|
97
|
-
fontWeight: "bold"
|
98
|
-
left: 0
|
99
|
-
padding: "1em"
|
100
|
-
position: "absolute"
|
101
|
-
textDecoration: "none"
|
102
|
-
top: 0
|
103
|
-
width: "100%"
|
104
|
-
zIndex: 2000
|
105
|
-
href: url
|
106
|
-
target: "_blank"
|
107
|
-
text: text
|
108
|
-
.appendTo("body")
|
109
|
-
|
110
|
-
Controller = (i, remapOSX) ->
|
111
|
-
if remapOSX == undefined
|
112
|
-
remapOSX = navigator.platform.match(/^Mac/)
|
113
|
-
|
114
|
-
if remapOSX
|
115
|
-
buttonMapping = buttonMappingOSX
|
116
|
-
axisMapping = axisMappingOSX
|
117
|
-
else
|
118
|
-
buttonMapping = buttonMappingDefault
|
119
|
-
axisMapping = axisMappingDefault
|
120
|
-
|
121
|
-
currentState = ->
|
122
|
-
joysticks[i]
|
123
|
-
|
124
|
-
previousState = ->
|
125
|
-
previousJoysticks[i]
|
126
|
-
|
127
|
-
axisTrips = []
|
128
|
-
|
129
|
-
self = Core().include(Bindable).extend
|
130
|
-
actionDown: (buttons...) ->
|
131
|
-
if state = currentState()
|
132
|
-
buttons.inject false, (down, button) ->
|
133
|
-
down || state.buttons & buttonMapping[button]
|
134
|
-
else
|
135
|
-
false
|
136
|
-
|
137
|
-
# true if button was just pressed
|
138
|
-
buttonPressed: (button) ->
|
139
|
-
buttonId = buttonMapping[button]
|
140
|
-
|
141
|
-
return (self.buttons() & buttonId) && !(previousState().buttons & buttonId)
|
142
|
-
|
143
|
-
position: (stick=0) ->
|
144
|
-
if state = currentState()
|
145
|
-
p = Point(self.axis(2*stick), self.axis(2*stick+1))
|
146
|
-
|
147
|
-
magnitude = p.magnitude()
|
148
|
-
|
149
|
-
if magnitude > AXIS_MAX
|
150
|
-
p.norm()
|
151
|
-
else if magnitude < DEAD_ZONE
|
152
|
-
Point(0, 0)
|
153
|
-
else
|
154
|
-
ratio = magnitude / AXIS_MAX
|
155
|
-
|
156
|
-
p.scale(ratio / AXIS_MAX)
|
157
|
-
|
158
|
-
else
|
159
|
-
Point(0, 0)
|
160
|
-
|
161
|
-
axis: (n) ->
|
162
|
-
n = axisMapping[n]
|
163
|
-
|
164
|
-
self.axes()[n] || 0
|
165
|
-
|
166
|
-
axes: ->
|
167
|
-
if state = currentState()
|
168
|
-
state.axes
|
169
|
-
else
|
170
|
-
[]
|
171
|
-
|
172
|
-
buttons: ->
|
173
|
-
if state = currentState()
|
174
|
-
state.buttons
|
175
|
-
|
176
|
-
processEvents: ->
|
177
|
-
[x, y] = [0, 1].map (n) ->
|
178
|
-
if !axisTrips[n] && self.axis(n).abs() > TRIP_HIGH
|
179
|
-
axisTrips[n] = true
|
180
|
-
|
181
|
-
return self.axis(n).sign()
|
182
|
-
|
183
|
-
if axisTrips[n] && self.axis(n).abs() < TRIP_LOW
|
184
|
-
axisTrips[n] = false
|
185
|
-
|
186
|
-
return 0
|
187
|
-
|
188
|
-
self.trigger("tap", Point(x, y)) if !x || !y
|
189
|
-
|
190
|
-
drawDebug: (canvas) ->
|
191
|
-
lineHeight = 18
|
192
|
-
canvas.fillColor("#FFF")
|
193
|
-
|
194
|
-
for axis, i in self.axes()
|
195
|
-
canvas.fillText(axis, 0, i * lineHeight)
|
196
|
-
|
197
|
-
canvas.fillText(self.buttons(), 0, i * lineHeight)
|
198
|
-
|
199
|
-
getController: (i) ->
|
200
|
-
controllers[i] ||= Controller(i)
|
201
|
-
|
202
|
-
init: ->
|
203
|
-
unless plugin
|
204
|
-
plugin = document.createElement("object")
|
205
|
-
plugin.type = type
|
206
|
-
plugin.width = 0
|
207
|
-
plugin.height = 0
|
208
|
-
|
209
|
-
$("body").append(plugin)
|
210
|
-
|
211
|
-
plugin.maxAxes = 6
|
212
|
-
|
213
|
-
unless plugin.status
|
214
|
-
promptElement = displayInstallPrompt("Your browser does not yet handle joysticks, please click here to install the Boomstick plugin!", "https://github.com/STRd6/Boomstick/wiki")
|
215
|
-
|
216
|
-
# The periodic check will remove the prompt if the player
|
217
|
-
# needs to accept or run the plugin manually
|
218
|
-
periodicCheck = ->
|
219
|
-
if plugin.status
|
220
|
-
promptElement.remove()
|
221
|
-
else
|
222
|
-
setTimeout periodicCheck, 500
|
223
|
-
|
224
|
-
periodicCheck()
|
225
|
-
|
226
|
-
status: ->
|
227
|
-
plugin?.status
|
228
|
-
|
229
|
-
update: ->
|
230
|
-
if plugin.joysticksJSON
|
231
|
-
previousJoysticks = joysticks
|
232
|
-
joysticks = JSON.parse(plugin.joysticksJSON())
|
233
|
-
|
234
|
-
for controller in controllers
|
235
|
-
controller?.processEvents()
|
236
|
-
|
237
|
-
joysticks: ->
|
238
|
-
joysticks
|
239
|
-
)()
|
240
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
###*
|
2
|
-
Merges properties from objects into target without overiding.
|
3
|
-
First come, first served.
|
4
|
-
|
5
|
-
@name reverseMerge
|
6
|
-
@methodOf jQuery#
|
7
|
-
|
8
|
-
@param {Object} target the object to merge the given properties onto
|
9
|
-
@param {Object} objects... one or more objects whose properties are merged onto target
|
10
|
-
|
11
|
-
@return {Object} target
|
12
|
-
###
|
13
|
-
jQuery.extend
|
14
|
-
reverseMerge: (target, objects...) ->
|
15
|
-
for object in objects
|
16
|
-
for name of object
|
17
|
-
unless target.hasOwnProperty(name)
|
18
|
-
target[name] = object[name]
|
19
|
-
|
20
|
-
return target
|
21
|
-
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module "jQuery.reverseMerge"
|
2
|
-
|
3
|
-
test "reverse merge", ->
|
4
|
-
o = {
|
5
|
-
exists: "cool"
|
6
|
-
}
|
7
|
-
|
8
|
-
$.reverseMerge o,
|
9
|
-
another: "also cool"
|
10
|
-
exists: "not cool"
|
11
|
-
u: undefined
|
12
|
-
|
13
|
-
equal o.exists, "cool"
|
14
|
-
equal o.another, "also cool"
|
15
|
-
equal o.u, undefined
|
16
|
-
ok "u" of o
|
17
|
-
|
18
|
-
test "multiple arguments", ->
|
19
|
-
o = {
|
20
|
-
a: 0
|
21
|
-
}
|
22
|
-
|
23
|
-
$.reverseMerge o, {
|
24
|
-
a: 1
|
25
|
-
b: 1
|
26
|
-
}, {
|
27
|
-
a: 2
|
28
|
-
b: 2
|
29
|
-
c: 2
|
30
|
-
}, {
|
31
|
-
a: 3
|
32
|
-
b: 3
|
33
|
-
c: 3
|
34
|
-
d: 3
|
35
|
-
}
|
36
|
-
|
37
|
-
equal o.a, 0
|
38
|
-
equal o.b, 1
|
39
|
-
equal o.c, 2
|
40
|
-
equal o.d, 3
|
41
|
-
|
42
|
-
module()
|
43
|
-
|