shank 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/assets/javascripts/engine.gamepads.coffee +8 -6
- data/lib/assets/javascripts/engine_stats.coffee +3 -1
- data/lib/assets/javascripts/error_handler.coffee +3 -1
- data/lib/assets/javascripts/gamepads.coffee +4 -2
- data/lib/assets/javascripts/gamepads.controller.coffee +6 -4
- data/lib/assets/javascripts/joysticks.coffee +3 -1
- data/lib/assets/javascripts/music.coffee +3 -1
- data/lib/shank/version.rb +1 -1
- metadata +3 -3
@@ -3,17 +3,17 @@ The <code>Gamepads</code> module gives the engine access to gamepads.
|
|
3
3
|
|
4
4
|
# First you need to add the `Gamepads` module to the engine
|
5
5
|
Engine.defaultModules.push "Gamepads"
|
6
|
-
|
6
|
+
|
7
7
|
window.engine = Engine
|
8
8
|
...
|
9
|
-
|
9
|
+
|
10
10
|
# Then you need to get a controller reference
|
11
11
|
# id = 0 for player 1, etc.
|
12
12
|
controller = engine.controller(id)
|
13
|
-
|
13
|
+
|
14
14
|
# Point indicating direction primary axis is held
|
15
15
|
direction = controller.position()
|
16
|
-
|
16
|
+
|
17
17
|
# Check if buttons are held
|
18
18
|
controller.actionDown("A")
|
19
19
|
controller.actionDown("B")
|
@@ -27,9 +27,11 @@ The <code>Gamepads</code> module gives the engine access to gamepads.
|
|
27
27
|
@param {Object} I Instance variables
|
28
28
|
@param {Object} self Reference to the engine
|
29
29
|
###
|
30
|
-
|
30
|
+
root = (exports ? this)
|
31
|
+
|
32
|
+
root.Engine.Gamepads = (I, self) ->
|
31
33
|
gamepads = Gamepads()
|
32
|
-
|
34
|
+
|
33
35
|
self.bind "beforeUpdate", ->
|
34
36
|
# Update the gamepads
|
35
37
|
gamepads.update()
|
@@ -2,7 +2,9 @@
|
|
2
2
|
This error handler captures any runtime errors and reports them to the IDE
|
3
3
|
if present.
|
4
4
|
###
|
5
|
-
|
5
|
+
root = (exports ? this)
|
6
|
+
|
7
|
+
root.onerror = (message, url, lineNumber) ->
|
6
8
|
errorContext = $('script').last().text().split('\n')[(lineNumber-5)..(lineNumber+4)]
|
7
9
|
|
8
10
|
errorContext[4] = "<b style='font-weight: bold; text-decoration: underline;'>" + errorContext[4] + "</b>"
|
@@ -1,10 +1,12 @@
|
|
1
|
-
|
1
|
+
root = (exports ? this)
|
2
|
+
|
3
|
+
root.Gamepads = (I={}) ->
|
2
4
|
state = {} # holds current and previous states
|
3
5
|
controllers = [] # controller cache
|
4
6
|
|
5
7
|
# Capture the current gamepad state
|
6
8
|
snapshot = ->
|
7
|
-
Array::map.call navigator.webkitGamepads || navigator.webkitGetGamepads(), (x) ->
|
9
|
+
Array::map.call navigator.webkitGamepads || navigator.webkitGetGamepads(), (x) ->
|
8
10
|
axes: x.axes
|
9
11
|
buttons: x.buttons
|
10
12
|
|
@@ -1,13 +1,15 @@
|
|
1
|
-
|
1
|
+
root = (exports ? this)
|
2
|
+
|
3
|
+
root.Gamepads.Controller = (I={}) ->
|
2
4
|
Object.reverseMerge I,
|
3
5
|
debugColor: "#000"
|
4
|
-
|
6
|
+
|
5
7
|
MAX_BUFFER = 0.03
|
6
8
|
AXIS_MAX = 1 - MAX_BUFFER
|
7
9
|
DEAD_ZONE = AXIS_MAX * 0.2
|
8
10
|
TRIP_HIGH = AXIS_MAX * 0.75
|
9
11
|
TRIP_LOW = AXIS_MAX * 0.5
|
10
|
-
|
12
|
+
|
11
13
|
BUTTON_THRESHOLD = 0.5
|
12
14
|
|
13
15
|
buttonMapping =
|
@@ -38,7 +40,7 @@ Gamepads.Controller = (I={}) ->
|
|
38
40
|
|
39
41
|
"TL": 9
|
40
42
|
"TR": 10
|
41
|
-
|
43
|
+
|
42
44
|
currentState = ->
|
43
45
|
I.state.current?[I.index]
|
44
46
|
|
data/lib/shank/version.rb
CHANGED
metadata
CHANGED