pixie_dust 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README +16 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/game.js +9200 -0
  8. data/lib/corelib.js +3331 -0
  9. data/lib/pixie_dust/version.rb +3 -0
  10. data/lib/pixie_dust.rb +14 -0
  11. data/pixie.json +15 -0
  12. data/pixie_dust.gemspec +29 -0
  13. data/source/active_bounds.coffee +48 -0
  14. data/source/ageable.coffee +23 -0
  15. data/source/bounded.coffee +282 -0
  16. data/source/camera.coffee +138 -0
  17. data/source/camera.fade.coffee +69 -0
  18. data/source/camera.flash.coffee +69 -0
  19. data/source/camera.rotate.coffee +11 -0
  20. data/source/camera.shake.coffee +27 -0
  21. data/source/camera.zoom.coffee +25 -0
  22. data/source/camera.zsort.coffee +13 -0
  23. data/source/clampable.coffee +61 -0
  24. data/source/collidable.coffee +126 -0
  25. data/source/collision.coffee +272 -0
  26. data/source/collision_response.coffee +28 -0
  27. data/source/color.coffee +1113 -0
  28. data/source/color_table.coffee +2534 -0
  29. data/source/controllable.coffee +66 -0
  30. data/source/cooldown.coffee +82 -0
  31. data/source/debuggable.coffee +253 -0
  32. data/source/drawable.coffee +167 -0
  33. data/source/dust_emitter.coffee +36 -0
  34. data/source/easing.coffee +38 -0
  35. data/source/emitter.coffee +7 -0
  36. data/source/emitterable.coffee +68 -0
  37. data/source/engine.coffee +274 -0
  38. data/source/engine.collision.coffee +77 -0
  39. data/source/engine.data.coffee +23 -0
  40. data/source/engine.delay.coffee +41 -0
  41. data/source/engine.fps_counter.coffee +32 -0
  42. data/source/engine.game_state.coffee +86 -0
  43. data/source/engine.joysticks.coffee +47 -0
  44. data/source/engine.keyboard.coffee +17 -0
  45. data/source/engine.levels.coffee +69 -0
  46. data/source/engine.mouse.coffee +16 -0
  47. data/source/engine.selector.coffee +166 -0
  48. data/source/engine.stats.coffee +16 -0
  49. data/source/engine.tilemap.coffee +41 -0
  50. data/source/engine_background.coffee +32 -0
  51. data/source/expirable.coffee +47 -0
  52. data/source/flickerable.coffee +78 -0
  53. data/source/follow.coffee +65 -0
  54. data/source/framerate.coffee +42 -0
  55. data/source/game_object.coffee +181 -0
  56. data/source/game_object.effect.coffee +33 -0
  57. data/source/game_object.meter.coffee +191 -0
  58. data/source/game_over.coffee +40 -0
  59. data/source/game_state.coffee +67 -0
  60. data/source/game_state.save_state.coffee +76 -0
  61. data/source/game_state.single_camera.coffee +40 -0
  62. data/source/game_state_cameras.coffee +33 -0
  63. data/source/level_state.coffee +32 -0
  64. data/source/movable.coffee +57 -0
  65. data/source/oscillator.coffee +18 -0
  66. data/source/pixie_dust.coffee +2 -0
  67. data/source/resource_loader.coffee +35 -0
  68. data/source/rotatable.coffee +38 -0
  69. data/source/sprite.coffee +181 -0
  70. data/source/text_effect.coffee +74 -0
  71. data/source/text_effect.floating.coffee +22 -0
  72. data/source/text_screen.coffee +38 -0
  73. data/source/tilemap.coffee +56 -0
  74. data/source/timed_events.coffee +78 -0
  75. data/source/title_screen.coffee +38 -0
  76. data/source/tween.coffee +70 -0
  77. data/test/active_bounds.coffee +67 -0
  78. data/test/bounded.coffee +98 -0
  79. data/test/camera.coffee +29 -0
  80. data/test/clampable.coffee +18 -0
  81. data/test/collidable.coffee +51 -0
  82. data/test/collision.coffee +70 -0
  83. data/test/color.coffee +533 -0
  84. data/test/controllable.coffee +108 -0
  85. data/test/cooldown.coffee +116 -0
  86. data/test/debuggable.coffee +71 -0
  87. data/test/drawable.coffee +31 -0
  88. data/test/emitter.coffee +0 -0
  89. data/test/emitterable.coffee +15 -0
  90. data/test/engine.coffee +228 -0
  91. data/test/engine_data.coffee +12 -0
  92. data/test/engine_delay.coffee +14 -0
  93. data/test/engine_selector.coffee +100 -0
  94. data/test/expirable.coffee +35 -0
  95. data/test/flickerable.coffee +51 -0
  96. data/test/follow.coffee +34 -0
  97. data/test/game_object.coffee +78 -0
  98. data/test/game_object_effect.coffee +17 -0
  99. data/test/metered.coffee +33 -0
  100. data/test/movable.coffee +46 -0
  101. data/test/oscillator.coffee +28 -0
  102. data/test/resource_loader.coffee +7 -0
  103. data/test/rotatable.coffee +20 -0
  104. data/test/sprite.coffee +21 -0
  105. data/test/text.coffee +25 -0
  106. data/test/timed_events.coffee +23 -0
  107. data/test/tweening.coffee +18 -0
  108. metadata +233 -0
@@ -0,0 +1,78 @@
1
+ module "GameObject"
2
+
3
+ test "()", ->
4
+ gameObject = GameObject()
5
+ ok gameObject
6
+
7
+ test ".construct", ->
8
+ gameObject = GameObject.construct
9
+ x: 20
10
+ y: 20
11
+
12
+ equals(gameObject.position().x, 20)
13
+
14
+ test "construct invalid object", ->
15
+ raises ->
16
+ GameObject.construct
17
+ class: "aaaaa"
18
+
19
+ test "#closest", ->
20
+ o = GameObject
21
+ x: 0
22
+ y: 0
23
+
24
+ other = GameObject
25
+ x: 1
26
+ y: 1
27
+
28
+ other2 = GameObject
29
+ x: 10
30
+ y: 10
31
+
32
+ equals o.closest([]), null
33
+
34
+ equals o.closest([other, other2]), other
35
+
36
+ test "#sendOrApply", ->
37
+ o = GameObject()
38
+
39
+ p = o.sendOrApply "position"
40
+
41
+ equals p.x, o.I.x
42
+
43
+ test "[event] create", 1, ->
44
+ o = GameObject()
45
+ o.bind "create", ->
46
+ ok true, "created event is fired on create"
47
+
48
+ o.create()
49
+ o.create() # Make sure only fired once
50
+
51
+ test "[event] update", 1, ->
52
+ gameObject = GameObject()
53
+
54
+ gameObject.bind "update", ->
55
+ equals(gameObject.I.age, 0, 'Age should be 0 on first update')
56
+
57
+ gameObject.trigger "update", 1
58
+
59
+ test "elapsedTime", 1, ->
60
+ gameObject = GameObject()
61
+
62
+ timeStep = 33
63
+
64
+ gameObject.bind "update", (t) ->
65
+ equals t, timeStep
66
+
67
+ gameObject.update(timeStep)
68
+
69
+ test "[event] destroy", 1, ->
70
+ o = GameObject()
71
+
72
+ o.bind "destroy", ->
73
+ ok true, "destroyed event is fired on destroy"
74
+
75
+ o.destroy()
76
+ o.destroy() # Make sure it's not called twice
77
+
78
+ module()
@@ -0,0 +1,17 @@
1
+ module "GameObject.Effect"
2
+
3
+ test "fadeOut", ->
4
+ player = GameObject()
5
+
6
+ fadedOut = false
7
+
8
+ player.fadeOut 1, ->
9
+ fadedOut = true
10
+
11
+ player.trigger "update", 1
12
+ player.trigger "afterUpdate", 1
13
+
14
+ equals player.I.alpha, 0, "Player has faded out"
15
+ ok fadedOut, "callback was called"
16
+
17
+ module()
@@ -0,0 +1,33 @@
1
+ module 'Metered'
2
+
3
+ test "should exist", ->
4
+ obj = GameObject()
5
+
6
+ ok obj.meter
7
+
8
+ test "should respect 0 being set as the meter attribute", ->
9
+ obj = GameObject
10
+ health: 0
11
+ healthMax: 110
12
+
13
+ obj.meter 'health'
14
+
15
+ equals obj.I.health, 0
16
+
17
+ test "should set max<Attribute> if it isn't present in the including object", ->
18
+ obj = GameObject
19
+ health: 150
20
+
21
+ obj.meter 'health'
22
+
23
+ equals obj.I.healthMax, 150
24
+
25
+ test "should set both <attribute> and max<attribute> if they aren't present in the including object", ->
26
+ obj = GameObject()
27
+
28
+ obj.meter 'turbo'
29
+
30
+ equals obj.I.turbo, 100
31
+ equals obj.I.turboMax, 100
32
+
33
+ module()
@@ -0,0 +1,46 @@
1
+ module "Movable"
2
+
3
+ test "should update velocity", ->
4
+ particle = GameObject
5
+ velocity: Point(1, 2)
6
+ x: 50
7
+ y: 50
8
+
9
+ particle.update(1)
10
+
11
+ equals particle.I.x, 51, "x position updated according to velocity"
12
+ equals particle.I.y, 52, "y position updated according to velocity"
13
+
14
+ test "should not exceed max speed", ->
15
+ particle = GameObject
16
+ velocity: Point(5, 5)
17
+ acceleration: Point(1, 1)
18
+ maxSpeed: 10
19
+
20
+ 20.times ->
21
+ particle.update(1)
22
+
23
+ ok particle.I.velocity.magnitude() <= particle.I.maxSpeed, "magnitude of the velocity should not exceed maxSpeed"
24
+
25
+ test "should be able to get velocity", ->
26
+ object = GameObject()
27
+
28
+ ok object.velocity()
29
+
30
+ test "should be able to get acceleration", ->
31
+ object = GameObject()
32
+
33
+ ok object.acceleration()
34
+
35
+ test "should increase velocity according to acceleration", ->
36
+ particle = GameObject
37
+ velocity: Point(0, -30)
38
+ acceleration: Point(0, 60)
39
+
40
+ 60.times ->
41
+ particle.update(1/60)
42
+
43
+ equals particle.I.velocity.x, 0
44
+ equals particle.I.velocity.y, 30
45
+
46
+ module()
@@ -0,0 +1,28 @@
1
+ module "Oscillator"
2
+
3
+ test "various values", ->
4
+ # Cosine Oscillator
5
+ o = Oscillator
6
+ period: 30
7
+ amplitude: 10
8
+
9
+ equals o(0), 10
10
+ equals o(30), 10
11
+ equals o(15), -10
12
+ equals o(7.5).toFixed(6), 0
13
+ equals o(22.5).toFixed(6), 0
14
+
15
+ # Sine Oscillator
16
+ o = Oscillator
17
+ period: 30
18
+ amplitude: 10
19
+ offset: -(Math.TAU / 4)
20
+
21
+ equals o(0).toFixed(6), 0
22
+ equals o(30).toFixed(6), 0
23
+ equals o(15).toFixed(6), 0
24
+ equals o(7.5).toFixed(6), 10
25
+ equals o(22.5).toFixed(6), -10
26
+
27
+ # Clear out the module
28
+ module()
@@ -0,0 +1,7 @@
1
+ module "ResourceLoader"
2
+
3
+ test ".urlFor", ->
4
+ equals ResourceLoader.urlFor("images", "guy"), "#{BASE_URL}/images/guy.png?#{MTIME}"
5
+
6
+ module undefined
7
+
@@ -0,0 +1,20 @@
1
+ module("Rotatable")
2
+
3
+ test "objects update their rotation", ->
4
+ obj = GameObject
5
+ rotationalVelocity: Math.PI / 4
6
+ rotation: Math.PI / 6
7
+
8
+ equals obj.I.rotation, Math.PI / 6, "Respects default rotation value"
9
+
10
+ 2.times ->
11
+ obj.update(1)
12
+
13
+ equals obj.I.rotation, Math.PI / 2 + Math.PI / 6
14
+
15
+ 4.times ->
16
+ obj.update(1)
17
+
18
+ equals obj.I.rotation, (3 / 2) * Math.PI + Math.PI / 6
19
+
20
+ module()
@@ -0,0 +1,21 @@
1
+ module "Sprite"
2
+
3
+ test "EMPTY and NONE", ->
4
+ ok Sprite.EMPTY
5
+ ok Sprite.NONE
6
+
7
+ asyncTest "callback and cache", ->
8
+ spriteUrl = "http://images.pixie.strd6.com/avatars/1/thumb.png"
9
+
10
+ callback = ->
11
+ sprite2 = Sprite.load spriteUrl, (s) ->
12
+ ok s.width isnt null
13
+ ok s.width is sprite2.width
14
+
15
+ start()
16
+
17
+ sprite = Sprite.load spriteUrl, callback
18
+
19
+ ok sprite.width is null
20
+
21
+ module()
data/test/text.coffee ADDED
@@ -0,0 +1,25 @@
1
+ module "TextEffect"
2
+
3
+ test "text moves up vertically", ->
4
+ text = TextEffect
5
+ velocity: Point(0, -1)
6
+
7
+ text.update(1)
8
+
9
+ equals text.I.x, 0
10
+ equals text.I.y, -1
11
+
12
+ 4.times ->
13
+ text.update(1)
14
+
15
+ equals text.I.x, 0
16
+ equals text.I.y, -5
17
+
18
+ module "TextEffect.Floating"
19
+
20
+ test "add to engine", ->
21
+ engine = Engine()
22
+
23
+ engine.add "TextEffect.Floating"
24
+
25
+ module()
@@ -0,0 +1,23 @@
1
+ module "TimedEvents"
2
+
3
+ test "#every", 4, ->
4
+ o = GameObject()
5
+
6
+ o.every 1, ->
7
+ ok true
8
+
9
+ 4.times ->
10
+ o.update(1)
11
+ o.trigger "afterUpdate", 1
12
+
13
+ test "#delay", 1, ->
14
+ o = GameObject()
15
+
16
+ 3.times (n) ->
17
+ o.delay n, ->
18
+ ok(true)
19
+
20
+ o.update(0.5)
21
+
22
+ # Clear out the module
23
+ module()
@@ -0,0 +1,18 @@
1
+ module "Tweening"
2
+
3
+ test "should allow for simple linear tweening", ->
4
+ o = GameObject
5
+ x: 0
6
+
7
+ targetValue = 10
8
+ o.tween 10,
9
+ x: targetValue
10
+
11
+ 12.times (i) ->
12
+ o.update(1)
13
+ o.trigger "afterUpdate", 1
14
+
15
+ equals o.I.x, Math.min(i + 1, targetValue)
16
+
17
+ # Clear out the module
18
+ module()
metadata ADDED
@@ -0,0 +1,233 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pixie_dust
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Daniel Moore
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: cornerstone-source
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: ! "\n Amazing libraries for developing games.\n Defines the main
63
+ PixieEngine GameObject and includes mixins to easily augment their behavior.\n "
64
+ email:
65
+ - yahivin@gmail.com
66
+ executables: []
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README
74
+ - README.md
75
+ - Rakefile
76
+ - game.js
77
+ - lib/corelib.js
78
+ - lib/pixie_dust.rb
79
+ - lib/pixie_dust/version.rb
80
+ - pixie.json
81
+ - pixie_dust.gemspec
82
+ - source/active_bounds.coffee
83
+ - source/ageable.coffee
84
+ - source/bounded.coffee
85
+ - source/camera.coffee
86
+ - source/camera.fade.coffee
87
+ - source/camera.flash.coffee
88
+ - source/camera.rotate.coffee
89
+ - source/camera.shake.coffee
90
+ - source/camera.zoom.coffee
91
+ - source/camera.zsort.coffee
92
+ - source/clampable.coffee
93
+ - source/collidable.coffee
94
+ - source/collision.coffee
95
+ - source/collision_response.coffee
96
+ - source/color.coffee
97
+ - source/color_table.coffee
98
+ - source/controllable.coffee
99
+ - source/cooldown.coffee
100
+ - source/debuggable.coffee
101
+ - source/drawable.coffee
102
+ - source/dust_emitter.coffee
103
+ - source/easing.coffee
104
+ - source/emitter.coffee
105
+ - source/emitterable.coffee
106
+ - source/engine.coffee
107
+ - source/engine.collision.coffee
108
+ - source/engine.data.coffee
109
+ - source/engine.delay.coffee
110
+ - source/engine.fps_counter.coffee
111
+ - source/engine.game_state.coffee
112
+ - source/engine.joysticks.coffee
113
+ - source/engine.keyboard.coffee
114
+ - source/engine.levels.coffee
115
+ - source/engine.mouse.coffee
116
+ - source/engine.selector.coffee
117
+ - source/engine.stats.coffee
118
+ - source/engine.tilemap.coffee
119
+ - source/engine_background.coffee
120
+ - source/expirable.coffee
121
+ - source/flickerable.coffee
122
+ - source/follow.coffee
123
+ - source/framerate.coffee
124
+ - source/game_object.coffee
125
+ - source/game_object.effect.coffee
126
+ - source/game_object.meter.coffee
127
+ - source/game_over.coffee
128
+ - source/game_state.coffee
129
+ - source/game_state.save_state.coffee
130
+ - source/game_state.single_camera.coffee
131
+ - source/game_state_cameras.coffee
132
+ - source/level_state.coffee
133
+ - source/movable.coffee
134
+ - source/oscillator.coffee
135
+ - source/pixie_dust.coffee
136
+ - source/resource_loader.coffee
137
+ - source/rotatable.coffee
138
+ - source/sprite.coffee
139
+ - source/text_effect.coffee
140
+ - source/text_effect.floating.coffee
141
+ - source/text_screen.coffee
142
+ - source/tilemap.coffee
143
+ - source/timed_events.coffee
144
+ - source/title_screen.coffee
145
+ - source/tween.coffee
146
+ - test/active_bounds.coffee
147
+ - test/bounded.coffee
148
+ - test/camera.coffee
149
+ - test/clampable.coffee
150
+ - test/collidable.coffee
151
+ - test/collision.coffee
152
+ - test/color.coffee
153
+ - test/controllable.coffee
154
+ - test/cooldown.coffee
155
+ - test/debuggable.coffee
156
+ - test/drawable.coffee
157
+ - test/emitter.coffee
158
+ - test/emitterable.coffee
159
+ - test/engine.coffee
160
+ - test/engine_data.coffee
161
+ - test/engine_delay.coffee
162
+ - test/engine_selector.coffee
163
+ - test/expirable.coffee
164
+ - test/flickerable.coffee
165
+ - test/follow.coffee
166
+ - test/game_object.coffee
167
+ - test/game_object_effect.coffee
168
+ - test/metered.coffee
169
+ - test/movable.coffee
170
+ - test/oscillator.coffee
171
+ - test/resource_loader.coffee
172
+ - test/rotatable.coffee
173
+ - test/sprite.coffee
174
+ - test/text.coffee
175
+ - test/timed_events.coffee
176
+ - test/tweening.coffee
177
+ homepage: ''
178
+ licenses:
179
+ - MIT
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubyforge_project:
198
+ rubygems_version: 1.8.24
199
+ signing_key:
200
+ specification_version: 3
201
+ summary: Amazing libraries for developing games
202
+ test_files:
203
+ - test/active_bounds.coffee
204
+ - test/bounded.coffee
205
+ - test/camera.coffee
206
+ - test/clampable.coffee
207
+ - test/collidable.coffee
208
+ - test/collision.coffee
209
+ - test/color.coffee
210
+ - test/controllable.coffee
211
+ - test/cooldown.coffee
212
+ - test/debuggable.coffee
213
+ - test/drawable.coffee
214
+ - test/emitter.coffee
215
+ - test/emitterable.coffee
216
+ - test/engine.coffee
217
+ - test/engine_data.coffee
218
+ - test/engine_delay.coffee
219
+ - test/engine_selector.coffee
220
+ - test/expirable.coffee
221
+ - test/flickerable.coffee
222
+ - test/follow.coffee
223
+ - test/game_object.coffee
224
+ - test/game_object_effect.coffee
225
+ - test/metered.coffee
226
+ - test/movable.coffee
227
+ - test/oscillator.coffee
228
+ - test/resource_loader.coffee
229
+ - test/rotatable.coffee
230
+ - test/sprite.coffee
231
+ - test/text.coffee
232
+ - test/timed_events.coffee
233
+ - test/tweening.coffee