shank 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Engine.Gamepads = (I, self) ->
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()
@@ -1,4 +1,6 @@
1
- Engine.Stats = (I={}, self) ->
1
+ root = (exports ? this)
2
+
3
+ root.Engine.Stats = (I={}, self) ->
2
4
  stats = xStats()
3
5
 
4
6
  $(stats.element).css
@@ -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
- window.onerror = (message, url, lineNumber) ->
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
- Gamepads = (I={}) ->
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
- Gamepads.Controller = (I={}) ->
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
 
@@ -1,4 +1,6 @@
1
- Joysticks = ( ->
1
+ root = (exports ? this)
2
+
3
+ root.Joysticks = ( ->
2
4
  type = "application/x-boomstickjavascriptjoysticksupport"
3
5
  plugin = null
4
6
  MAX_BUFFER = 2000
@@ -11,7 +11,9 @@ default, the track is looped.
11
11
  @namespace
12
12
  ###
13
13
 
14
- Music = (->
14
+ root = (exports ? this)
15
+
16
+ root.Music = (->
15
17
  # TODO: Load this from local storage of user preferences
16
18
  globalMusicVolume = 1
17
19
  trackVolume = 1
data/lib/shank/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shank
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shank
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Diebolt