pixie_dust 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fd7e836bf9e27f02d84578a4eee7960321b7880a
4
+ data.tar.gz: 7f29353d320cd158f9f3ee1587fda88c0c41731a
5
+ SHA512:
6
+ metadata.gz: f28b2a9df7597546534d706a978cfe6e4bcb66fbfd512d5a06685dcece6ff81386a8589d1181a607908c8f63e5048148dbaebf44133013f7dfcf9a48c2cb101a
7
+ data.tar.gz: ec4da058366b69863134e3100c8bdbe058570c5812e4d9891f993da67340044123fd13fbf2363845f2b6e7b42cec1643e9c29628a1c567837bfbd2ef9b5517e1
@@ -1,3 +1,3 @@
1
1
  module PixieDust
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -18,7 +18,7 @@ Camera = (I={}) ->
18
18
  x: App.width/2 # World Coordinates
19
19
  y: App.height/2 # World Coordinates
20
20
  velocity: Point.ZERO
21
- maxSpeed: 25
21
+ maxSpeed: 750
22
22
  t90: 2 # Time in seconds for camera to move 90% of the way to the target
23
23
 
24
24
  currentType = "centered"
@@ -116,7 +116,7 @@ Camera = (I={}) ->
116
116
 
117
117
  objects.invoke "trigger", "overlay", canvas
118
118
 
119
- self.include "Bounded"
119
+ self.include "Ageable", "Bounded"
120
120
 
121
121
  # The order of theses includes is important for
122
122
  # the way in wich they modify the camera view transform
@@ -126,6 +126,8 @@ Camera = (I={}) ->
126
126
 
127
127
  return self
128
128
 
129
+ Object.extend Camera, oldCamera
130
+
129
131
  Camera.defaultModules = [
130
132
  "ZSort"
131
133
  "Zoom"
@@ -133,6 +135,5 @@ Camera.defaultModules = [
133
135
  "Shake"
134
136
  "Flash"
135
137
  "Fade"
138
+ "Transition"
136
139
  ]
137
-
138
- Object.extend Camera, oldCamera
@@ -0,0 +1,71 @@
1
+ Camera.Transition = (I, self) ->
2
+ Object.reverseMerge I,
3
+ transitionActive: null
4
+ transitionStart: null
5
+ transitionEnd: null
6
+
7
+ defaultOptions =
8
+ color: "white"
9
+
10
+ transitionProgress = ->
11
+ ((I.age - I.transitionStart) / (I.transitionEnd - I.transitionStart)).clamp(0, 1)
12
+
13
+ transitions =
14
+ angle: ({canvas, t, screenSize, color}) ->
15
+ # Leading point at the center
16
+ p0 = Point(t * (screenSize.x * 2), screenSize.y / 2)
17
+
18
+ p1 = p0.subtract(Point(screenSize.x, screenSize.y / 2))
19
+ p2 = p1.subtract(Point(screenSize.x, 0))
20
+ p3 = p2.add(Point(0, screenSize.y))
21
+ p4 = p3.add(Point(screenSize.x, 0))
22
+
23
+ canvas.drawPoly
24
+ points: [p0, p1, p2, p3, p4]
25
+ color: color
26
+
27
+ square: ({canvas, t, screenSize, color}) ->
28
+ width = 50
29
+ height = 50
30
+
31
+ (screenSize.y / height).ceil().times (y) ->
32
+ (screenSize.x / width).ceil().times (x) ->
33
+ cellProgress = (2 * t - (x + y).mod(2)).clamp(0, 1)
34
+
35
+ canvas.drawRect
36
+ x: x * width
37
+ y: y * height
38
+ width: width
39
+ height: height * cellProgress
40
+ color: color
41
+
42
+ line: ({canvas, t, screenSize, color}) ->
43
+ height = 50
44
+
45
+ (screenSize.y / height).ceil().times (y) ->
46
+ canvas.drawRect
47
+ x: 0
48
+ y: y * height
49
+ width: screenSize.x
50
+ height: height * t
51
+ color: color
52
+
53
+ # TODO Use transition options for color
54
+ # TODO default transition options
55
+
56
+ self.on "overlay", (canvas) ->
57
+ if transitionName = I.transitionActive
58
+ transitions[transitionName] Object.extend(
59
+ canvas: canvas
60
+ screenSize: Point(I.screen.width, I.screen.height)
61
+ t: transitionProgress()
62
+ , I.transitionOptions)
63
+
64
+ transition: ({name, duration, options}={}) ->
65
+ name ?= "angle"
66
+ duration ?= 1
67
+
68
+ I.transitionActive = name
69
+ I.transitionStart = I.age
70
+ I.transitionEnd = I.age + duration
71
+ I.transitionOptions = Object.extend({}, defaultOptions, options)
@@ -0,0 +1,20 @@
1
+ CameraTarget = (I={}) ->
2
+ Object.reverseMerge I,
3
+ target: "Player.controller=0"
4
+ lead: 1.25
5
+
6
+ self = GameObject(I).extend
7
+ draw: -> # NOP
8
+
9
+ self.on "update", (canvas) ->
10
+ if target = engine.first(I.target)
11
+ targetPosition = target.position()
12
+ targetVelocity = target.velocity()
13
+
14
+ # Camera should lead target's position by a multiple of the targets velocity
15
+ position = targetPosition.add(targetVelocity.scale(I.lead))
16
+
17
+ I.x = position.x
18
+ I.y = position.y
19
+
20
+ return self
@@ -19,7 +19,7 @@ Engine.Collision = (I, self) ->
19
19
  ###
20
20
  collides: (bounds, sourceObject, selector=".solid") ->
21
21
  self.find(selector).inject false, (collided, object) ->
22
- collided or (object != sourceObject) and object.collides(bounds)
22
+ collided or (object != sourceObject) and object.collides(bounds) and object
23
23
 
24
24
  ###*
25
25
  Detects collisions between a bounds and the game objects.
@@ -20,21 +20,21 @@ Engine.Selector = (I, self) ->
20
20
  player = engine.add
21
21
  x: 0
22
22
  y: 0
23
-
23
+
24
24
  enemy1 = engine.add
25
25
  enemy: true
26
26
  x: 10
27
27
  y: 0
28
-
28
+
29
29
  enemy2 = engine.add
30
30
  enemy: true
31
31
  x: 0
32
32
  y: 15
33
-
33
+
34
34
  player2 = engine.add
35
35
  x: 0
36
36
  y: 10
37
-
37
+
38
38
  equals engine.closest(".enemy", player.position()), enemy1
39
39
  equals engine.closest(".enemy", player2.position()), enemy2
40
40
 
@@ -55,33 +55,33 @@ Engine.Selector = (I, self) ->
55
55
 
56
56
  player = engine.add
57
57
  class: "Player"
58
-
58
+
59
59
  enemy = engine.add
60
60
  class: "Enemy"
61
61
  speed: 5
62
62
  x: 0
63
-
63
+
64
64
  distantEnemy = engine.add
65
65
  class "Enemy"
66
66
  x: 500
67
-
67
+
68
68
  boss = engine.add
69
69
  class: "Enemy"
70
70
  id: "Boss"
71
71
  x: 0
72
-
72
+
73
73
  # to select an object by id use "#anId"
74
74
  engine.find "#Boss"
75
75
  # => [boss]
76
-
76
+
77
77
  # to select an object by class use "MyClass"
78
78
  engine.find "Enemy"
79
79
  # => [enemy, distantEnemy, boss]
80
-
80
+
81
81
  # to select an object by properties use ".someProperty" or ".someProperty=someValue"
82
82
  engine.find ".speed=5"
83
83
  # => [enemy]
84
-
84
+
85
85
  # You may mix and match selectors.
86
86
  engine.find "Enemy.x=0"
87
87
  # => [enemy, boss] # doesn't return distantEnemy
@@ -90,7 +90,7 @@ Engine.Selector = (I, self) ->
90
90
  @methodOf Engine#
91
91
  @param {String} selector
92
92
  @returns {Array} An array of the objects found
93
- ###
93
+ ###
94
94
  each: (selector, fn) ->
95
95
  self.find(selector).each (obj, index) ->
96
96
  fn(obj, index)
@@ -153,7 +153,7 @@ Object.extend Engine.Selector,
153
153
  typeMatch = (component[TYPE] == object.I.class) || !component[TYPE]
154
154
 
155
155
  if attr = component[ATTR]
156
- if (value = component[ATTR_VALUE])?
156
+ if (value = component[ATTR_VALUE])?
157
157
  attrMatch = (object.I[attr] == value)
158
158
  else
159
159
  attrMatch = object.I[attr]
@@ -163,4 +163,3 @@ Object.extend Engine.Selector,
163
163
  return true if idMatch && typeMatch && attrMatch
164
164
 
165
165
  return false
166
-
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pixie_dust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Moore
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-24 00:00:00.000000000 Z
11
+ date: 2013-05-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,68 +27,60 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: coffee-script
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sprockets
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: cornerstone-source
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
- description: ! "\n Amazing libraries for developing games.\n Defines the main
83
+ description: "\n Amazing libraries for developing games.\n Defines the main
95
84
  PixieEngine GameObject and includes mixins to easily augment their behavior.\n "
96
85
  email:
97
86
  - yahivin@gmail.com
@@ -119,8 +108,10 @@ files:
119
108
  - source/camera.flash.coffee
120
109
  - source/camera.rotate.coffee
121
110
  - source/camera.shake.coffee
111
+ - source/camera.transition.coffee
122
112
  - source/camera.zoom.coffee
123
113
  - source/camera.zsort.coffee
114
+ - source/camera_target.coffee
124
115
  - source/clampable.coffee
125
116
  - source/collidable.coffee
126
117
  - source/collision.coffee
@@ -209,27 +200,26 @@ files:
209
200
  homepage: ''
210
201
  licenses:
211
202
  - MIT
203
+ metadata: {}
212
204
  post_install_message:
213
205
  rdoc_options: []
214
206
  require_paths:
215
207
  - lib
216
208
  required_ruby_version: !ruby/object:Gem::Requirement
217
- none: false
218
209
  requirements:
219
- - - ! '>='
210
+ - - '>='
220
211
  - !ruby/object:Gem::Version
221
212
  version: '0'
222
213
  required_rubygems_version: !ruby/object:Gem::Requirement
223
- none: false
224
214
  requirements:
225
- - - ! '>='
215
+ - - '>='
226
216
  - !ruby/object:Gem::Version
227
217
  version: '0'
228
218
  requirements: []
229
219
  rubyforge_project:
230
- rubygems_version: 1.8.24
220
+ rubygems_version: 2.0.3
231
221
  signing_key:
232
- specification_version: 3
222
+ specification_version: 4
233
223
  summary: Amazing libraries for developing games
234
224
  test_files:
235
225
  - test/active_bounds.coffee