entityjs 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. data/.gitignore +7 -6
  2. data/.rspec +2 -0
  3. data/README.md +170 -49
  4. data/Rakefile +9 -0
  5. data/bin/entityjs +24 -14
  6. data/entityjs.gemspec +15 -9
  7. data/lib/entityjs/assets.rb +167 -0
  8. data/lib/entityjs/command.rb +52 -27
  9. data/lib/entityjs/commands/build.rb +128 -0
  10. data/lib/entityjs/commands/comp.rb +74 -0
  11. data/lib/entityjs/commands/font.rb +73 -0
  12. data/lib/entityjs/commands/new.rb +59 -0
  13. data/lib/entityjs/commands/server.rb +54 -0
  14. data/lib/entityjs/commands/templates.rb +28 -0
  15. data/lib/entityjs/commands/test.rb +69 -0
  16. data/lib/entityjs/config.rb +130 -0
  17. data/lib/entityjs/dirc.rb +184 -0
  18. data/lib/entityjs/parsers/parse_tmx.rb +41 -0
  19. data/lib/entityjs/parsers/parse_xml.rb +39 -0
  20. data/lib/entityjs/version.rb +1 -1
  21. data/lib/entityjs.rb +53 -0
  22. data/license.txt +1 -1
  23. data/public/play.html +122 -0
  24. data/public/qunit/qunit.css +226 -0
  25. data/public/qunit/qunit.entity.js +190 -0
  26. data/public/qunit/qunit.input.js +200 -0
  27. data/public/qunit/qunit.js +1598 -0
  28. data/public/qunit/qunit.mock.js +97 -0
  29. data/public/tests.html +45 -0
  30. data/spec/javascripts/helpers/accept.png +0 -0
  31. data/spec/javascripts/helpers/alligator.mp3 +0 -0
  32. data/spec/javascripts/helpers/alligator.ogg +0 -0
  33. data/spec/javascripts/helpers/canvas.js +15 -0
  34. data/spec/javascripts/helpers/entityunit.js +50 -0
  35. data/spec/javascripts/helpers/factories.js +11 -0
  36. data/spec/javascripts/helpers/jquery-1.7.1.min.js +4 -0
  37. data/spec/javascripts/src/core/comp_spec.js +145 -0
  38. data/spec/javascripts/src/core/entity_spec.js +324 -0
  39. data/spec/javascripts/src/core/load_spec.js +71 -0
  40. data/spec/javascripts/src/core/query_spec.js +157 -0
  41. data/spec/javascripts/src/core/re_spec.js +61 -0
  42. data/spec/javascripts/src/core/system_spec.js +41 -0
  43. data/spec/javascripts/src/cycle/draw_spec.js +106 -0
  44. data/spec/javascripts/src/cycle/tick_spec.js +20 -0
  45. data/spec/javascripts/src/cycle/update_spec.js +86 -0
  46. data/spec/javascripts/src/display/align_spec.js +43 -0
  47. data/spec/javascripts/src/display/circle_spec.js +26 -0
  48. data/spec/javascripts/src/display/group_spec.js +7 -0
  49. data/spec/javascripts/src/display/image_spec.js +32 -0
  50. data/spec/javascripts/src/display/imgtext_spec.js +32 -0
  51. data/spec/javascripts/src/display/rect_spec.js +13 -0
  52. data/spec/javascripts/src/display/screen_spec.js +47 -0
  53. data/spec/javascripts/src/display/sprite_spec.js +28 -0
  54. data/spec/javascripts/src/display/text_spec.js +30 -0
  55. data/spec/javascripts/src/input/keyboard_spec.js +67 -0
  56. data/spec/javascripts/src/input/mouse_spec.js +133 -0
  57. data/spec/javascripts/src/input/pressed_spec.js +31 -0
  58. data/spec/javascripts/src/math/bisect_spec.js +59 -0
  59. data/spec/javascripts/src/math/body_spec.js +30 -0
  60. data/spec/javascripts/src/math/drag_spec.js +38 -0
  61. data/spec/javascripts/src/math/force_spec.js +134 -0
  62. data/spec/javascripts/src/math/hit_spec.js +28 -0
  63. data/spec/javascripts/src/math/hitmap_spec.js +52 -0
  64. data/spec/javascripts/src/math/limit_spec.js +35 -0
  65. data/spec/javascripts/src/math/point_spec.js +57 -0
  66. data/spec/javascripts/src/math/tile_spec.js +78 -0
  67. data/spec/javascripts/src/media/sound_spec.js +40 -0
  68. data/spec/javascripts/src/pattern/automap_spec.js +93 -0
  69. data/spec/javascripts/src/pattern/flicker_spec.js +66 -0
  70. data/spec/javascripts/src/pattern/timestep_spec.js +23 -0
  71. data/spec/javascripts/src/save/storage_spec.js +37 -0
  72. data/spec/javascripts/src/util/log_spec.js +9 -0
  73. data/spec/javascripts/src/util/polyfill_spec.js +13 -0
  74. data/spec/javascripts/src/util/random_spec.js +33 -0
  75. data/spec/javascripts/src/util/scene_spec.js +52 -0
  76. data/spec/javascripts/src/util/sheet_spec.js +25 -0
  77. data/spec/javascripts/src/util/support_spec.js +17 -0
  78. data/spec/javascripts/support/jasmine.yml +76 -0
  79. data/spec/javascripts/support/jasmine_config.rb +32 -0
  80. data/spec/javascripts/support/jasmine_runner.rb +32 -0
  81. data/spec/lib/entityjs/assets_spec.rb +216 -0
  82. data/spec/lib/entityjs/command_spec.rb +53 -0
  83. data/spec/lib/entityjs/commands/build_spec.rb +69 -0
  84. data/spec/lib/entityjs/commands/comp_spec.rb +45 -0
  85. data/spec/lib/entityjs/commands/font_spec.rb +7 -0
  86. data/spec/lib/entityjs/commands/new_spec.rb +20 -0
  87. data/spec/lib/entityjs/commands/templates_spec.rb +9 -0
  88. data/spec/lib/entityjs/commands/test_spec.rb +31 -0
  89. data/spec/lib/entityjs/config_spec.rb +19 -0
  90. data/spec/lib/entityjs/dirc_spec.rb +83 -0
  91. data/spec/lib/entityjs/version_spec.rb +9 -0
  92. data/spec/spec_helper.rb +21 -3
  93. data/spec/support/factories.rb +19 -0
  94. data/spec/support/mygame.rb +11 -0
  95. data/src/core/comp.js +318 -0
  96. data/src/core/entity.js +549 -0
  97. data/src/core/load.js +242 -0
  98. data/src/core/query.js +354 -0
  99. data/src/core/re.js +74 -0
  100. data/src/core/system.js +121 -0
  101. data/src/cycle/draw.js +178 -0
  102. data/src/cycle/tick.js +25 -0
  103. data/src/{entityjs/cycle → cycle}/tween.js +60 -60
  104. data/src/{entityjs/cycle → cycle}/update.js +86 -85
  105. data/src/{entityjs/cycle → cycle}/wait.js +22 -21
  106. data/src/{entityjs/cycle → cycle}/worker.js +8 -8
  107. data/src/display/align.js +45 -0
  108. data/src/display/circle.js +33 -0
  109. data/src/{entityjs/display → display}/group.js +62 -62
  110. data/src/display/image.js +35 -0
  111. data/src/display/imgtext.js +102 -0
  112. data/src/{entityjs/display → display}/rect.js +18 -18
  113. data/src/display/screen.js +57 -0
  114. data/src/display/sprite.js +54 -0
  115. data/src/display/text.js +44 -0
  116. data/src/{entityjs/input → input}/keyboard.js +152 -150
  117. data/src/input/mouse.js +111 -0
  118. data/src/input/pressed.js +41 -0
  119. data/src/{entityjs/input → input}/touch.js +24 -28
  120. data/src/math/bisect.js +84 -0
  121. data/src/math/body.js +70 -0
  122. data/src/{entityjs/math → math}/drag.js +44 -38
  123. data/src/math/force.js +143 -0
  124. data/src/math/hit.js +32 -0
  125. data/src/math/hitmap.js +167 -0
  126. data/src/math/limit.js +37 -0
  127. data/src/math/point.js +40 -0
  128. data/src/math/tile.js +109 -0
  129. data/src/media/channel.js +93 -0
  130. data/src/{entityjs/media → media}/playlist.js +4 -4
  131. data/src/media/sound.js +114 -0
  132. data/src/{entityjs/net → net}/socket.js +51 -51
  133. data/src/pattern/automap.js +133 -0
  134. data/src/{entityjs/pattern → pattern}/flicker.js +206 -213
  135. data/src/pattern/timestep.js +31 -0
  136. data/src/{entityjs/save → save}/database.js +6 -6
  137. data/src/{entityjs/save → save}/storage.js +47 -56
  138. data/src/{entityjs/util → util}/log.js +17 -25
  139. data/src/{entityjs/util → util}/polyfill.js +24 -24
  140. data/src/util/random.js +20 -0
  141. data/src/util/scene.js +102 -0
  142. data/src/util/sheet.js +35 -0
  143. data/src/{entityjs/util → util}/support.js +109 -132
  144. data/{examples/keys → templates/arrow_keys/assets/images}/arrow.png +0 -0
  145. data/templates/arrow_keys/config.yml +22 -0
  146. data/templates/arrow_keys/readme.txt +9 -0
  147. data/templates/arrow_keys/scripts/display/arrow.js +69 -0
  148. data/templates/arrow_keys/scripts/init.js +10 -0
  149. data/templates/arrow_keys/scripts/input/controls.js +35 -0
  150. data/templates/arrow_keys/scripts/scenes/home.js +20 -0
  151. data/templates/arrow_keys/scripts/scenes/load.js +57 -0
  152. data/templates/arrow_keys/tests/display/arrow_test.js +29 -0
  153. data/templates/arrow_keys/tests/init_test.js +4 -0
  154. data/templates/arrow_keys/tests/input/controls_test.js +32 -0
  155. data/templates/arrow_keys/tests/scenes/home_test.js +0 -0
  156. data/templates/arrow_keys/tests/scenes/load_test.js +16 -0
  157. data/templates/blank/config.yml +22 -0
  158. data/templates/blank/readme.txt +79 -0
  159. data/templates/platform/assets/images/bit.png +0 -0
  160. data/templates/platform/assets/images/hero.png +0 -0
  161. data/templates/platform/assets/images/items.png +0 -0
  162. data/templates/platform/assets/images/tiles.png +0 -0
  163. data/templates/platform/assets/levels/level1.tmx +44 -0
  164. data/templates/platform/assets/sounds/coin.mp3 +0 -0
  165. data/templates/platform/assets/sounds/coin.ogg +0 -0
  166. data/templates/platform/config.yml +22 -0
  167. data/templates/platform/readme.txt +87 -0
  168. data/templates/platform/scripts/display/bit.js +12 -0
  169. data/templates/platform/scripts/display/hero.js +77 -0
  170. data/templates/platform/scripts/display/tile.js +2 -0
  171. data/templates/platform/scripts/display/tsprite.js +17 -0
  172. data/templates/platform/scripts/init.js +7 -0
  173. data/templates/platform/scripts/items/coin.js +27 -0
  174. data/templates/platform/scripts/items/item.js +41 -0
  175. data/templates/platform/scripts/items/spring.js +25 -0
  176. data/templates/platform/scripts/scenes/home.js +10 -0
  177. data/templates/platform/scripts/scenes/load.js +27 -0
  178. data/templates/platform/scripts/scenes/play.js +31 -0
  179. data/templates/platform/scripts/util/counter.js +34 -0
  180. data/templates/platform/scripts/util/level.js +84 -0
  181. data/templates/platform/tests/display/bit_test.js +7 -0
  182. data/templates/platform/tests/display/hero_test.js +73 -0
  183. data/templates/platform/tests/display/tile_test.js +7 -0
  184. data/templates/platform/tests/display/tsprite_test.js +8 -0
  185. data/templates/platform/tests/factories.js +30 -0
  186. data/templates/platform/tests/items/coin_test.js +28 -0
  187. data/templates/platform/tests/items/item_test.js +36 -0
  188. data/templates/platform/tests/items/spring_test.js +21 -0
  189. data/templates/platform/tests/scenes/home_test.js +9 -0
  190. data/templates/platform/tests/scenes/load_test.js +11 -0
  191. data/templates/platform/tests/scenes/play_test.js +15 -0
  192. data/templates/platform/tests/util/counter_test.js +9 -0
  193. data/templates/platform/tests/util/level_test.js +29 -0
  194. metadata +249 -97
  195. data/build/build_debug.bat +0 -1
  196. data/build/build_min.bat +0 -1
  197. data/build/config.php +0 -64
  198. data/build/debug.php +0 -48
  199. data/build/files.php +0 -74
  200. data/build/jsmin.php +0 -376
  201. data/build/min.php +0 -50
  202. data/changelog.txt +0 -53
  203. data/examples/keys/keys.html +0 -59
  204. data/examples/keys/keys.js +0 -148
  205. data/examples/mouse/mouse.html +0 -58
  206. data/examples/mouse/mouse.js +0 -60
  207. data/examples/scenes/home.png +0 -0
  208. data/examples/scenes/scenes.html +0 -55
  209. data/examples/scenes/scenes.js +0 -134
  210. data/examples/scenes/win.png +0 -0
  211. data/examples/sounds/sound1.mp3 +0 -0
  212. data/examples/sounds/sound1.ogg +0 -0
  213. data/examples/sounds/sounds.html +0 -56
  214. data/examples/sounds/sounds.js +0 -44
  215. data/examples/style/background.png +0 -0
  216. data/examples/style/sheet.css +0 -762
  217. data/examples/tiles/tiles.html +0 -56
  218. data/examples/tiles/tiles.js +0 -85
  219. data/examples/tiles/tiles.png +0 -0
  220. data/lib/blank/config.js +0 -4
  221. data/lib/blank/config.yml +0 -21
  222. data/lib/blank/home.js +0 -11
  223. data/lib/blank/init.js +0 -7
  224. data/lib/blank/load.js +0 -21
  225. data/lib/blank/play.html +0 -29
  226. data/lib/entity.debug.js +0 -52
  227. data/lib/entity.min.js +0 -184
  228. data/lib/entityjs/comp.rb +0 -11
  229. data/lib/entityjs/game.rb +0 -93
  230. data/lib/entityjs/min.rb +0 -11
  231. data/lib/entityjs/refresh.rb +0 -14
  232. data/spec/lib/entityjs/game_spec.rb +0 -11
  233. data/src/entityjs/core/component.js +0 -306
  234. data/src/entityjs/core/entity.js +0 -516
  235. data/src/entityjs/core/load.js +0 -224
  236. data/src/entityjs/core/query.js +0 -410
  237. data/src/entityjs/core/re.js +0 -70
  238. data/src/entityjs/core/system.js +0 -125
  239. data/src/entityjs/cycle/draw.js +0 -185
  240. data/src/entityjs/cycle/ticker.js +0 -27
  241. data/src/entityjs/display/anchor.js +0 -53
  242. data/src/entityjs/display/bitfont.js +0 -93
  243. data/src/entityjs/display/bitmap.js +0 -37
  244. data/src/entityjs/display/circle.js +0 -30
  245. data/src/entityjs/display/font.js +0 -41
  246. data/src/entityjs/display/screen.js +0 -46
  247. data/src/entityjs/display/sprite.js +0 -37
  248. data/src/entityjs/input/mouse.js +0 -123
  249. data/src/entityjs/input/pressed.js +0 -81
  250. data/src/entityjs/math/bind.js +0 -76
  251. data/src/entityjs/math/bisect.js +0 -69
  252. data/src/entityjs/math/body.js +0 -39
  253. data/src/entityjs/math/hitmap.js +0 -165
  254. data/src/entityjs/math/hittest.js +0 -26
  255. data/src/entityjs/math/physics.js +0 -142
  256. data/src/entityjs/math/point.js +0 -57
  257. data/src/entityjs/math/tile.js +0 -91
  258. data/src/entityjs/media/channel.js +0 -93
  259. data/src/entityjs/media/sound.js +0 -110
  260. data/src/entityjs/pattern/arraymap.js +0 -89
  261. data/src/entityjs/pattern/timestep.js +0 -34
  262. data/src/entityjs/util/random.js +0 -38
  263. data/src/entityjs/util/scene.js +0 -101
  264. data/src/entityjs/util/sheet.js +0 -51
data/build/jsmin.php DELETED
@@ -1,376 +0,0 @@
1
- <?php
2
- /**
3
- * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
4
- *
5
- * This is pretty much a direct port of jsmin.c to PHP with just a few
6
- * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
7
- * outputs to stdout, this library accepts a string as input and returns another
8
- * string as output.
9
- *
10
- * PHP 5 or higher is required.
11
- *
12
- * Permission is hereby granted to use this version of the library under the
13
- * same terms as jsmin.c, which has the following license:
14
- *
15
- * --
16
- * Copyright (c) 2002 Douglas Crockford (www.crockford.com)
17
- *
18
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
19
- * this software and associated documentation files (the "Software"), to deal in
20
- * the Software without restriction, including without limitation the rights to
21
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
22
- * of the Software, and to permit persons to whom the Software is furnished to do
23
- * so, subject to the following conditions:
24
- *
25
- * The above copyright notice and this permission notice shall be included in all
26
- * copies or substantial portions of the Software.
27
- *
28
- * The Software shall be used for Good, not Evil.
29
- *
30
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
- * SOFTWARE.
37
- * --
38
- *
39
- * @package JSMin
40
- * @author Ryan Grove <ryan@wonko.com>
41
- * @copyright 2002 Douglas Crockford <douglas@crockford.com> (jsmin.c)
42
- * @copyright 2008 Ryan Grove <ryan@wonko.com> (PHP port)
43
- * @license http://opensource.org/licenses/mit-license.php MIT License
44
- * @version 1.1.1 (2008-03-02)
45
- * @link https://github.com/rgrove/jsmin-php/
46
- */
47
-
48
- class JSMin {
49
- const ORD_LF = 10;
50
- const ORD_SPACE = 32;
51
- const ACTION_KEEP_A = 1;
52
- const ACTION_DELETE_A = 2;
53
- const ACTION_DELETE_A_B = 3;
54
-
55
- protected $a = '';
56
- protected $b = '';
57
- protected $input = '';
58
- protected $inputIndex = 0;
59
- protected $inputLength = 0;
60
- protected $lookAhead = null;
61
- protected $output = '';
62
-
63
- // -- Public Static Methods --------------------------------------------------
64
-
65
- /**
66
- * Minify Javascript
67
- *
68
- * @uses __construct()
69
- * @uses min()
70
- * @param string $js Javascript to be minified
71
- * @return string
72
- */
73
- public static function minify($js) {
74
- $jsmin = new JSMin($js);
75
- return $jsmin->min();
76
- }
77
-
78
- // -- Public Instance Methods ------------------------------------------------
79
-
80
- /**
81
- * Constructor
82
- *
83
- * @param string $input Javascript to be minified
84
- */
85
- public function __construct($input) {
86
- $this->input = str_replace("\r\n", "\n", $input);
87
- $this->inputLength = strlen($this->input);
88
- }
89
-
90
- // -- Protected Instance Methods ---------------------------------------------
91
-
92
- /**
93
- * Action -- do something! What to do is determined by the $command argument.
94
- *
95
- * action treats a string as a single character. Wow!
96
- * action recognizes a regular expression if it is preceded by ( or , or =.
97
- *
98
- * @uses next()
99
- * @uses get()
100
- * @throws JSMinException If parser errors are found:
101
- * - Unterminated string literal
102
- * - Unterminated regular expression set in regex literal
103
- * - Unterminated regular expression literal
104
- * @param int $command One of class constants:
105
- * ACTION_KEEP_A Output A. Copy B to A. Get the next B.
106
- * ACTION_DELETE_A Copy B to A. Get the next B. (Delete A).
107
- * ACTION_DELETE_A_B Get the next B. (Delete B).
108
- */
109
- protected function action($command) {
110
- switch($command) {
111
- case self::ACTION_KEEP_A:
112
- $this->output .= $this->a;
113
-
114
- case self::ACTION_DELETE_A:
115
- $this->a = $this->b;
116
-
117
- if ($this->a === "'" || $this->a === '"') {
118
- for (;;) {
119
- $this->output .= $this->a;
120
- $this->a = $this->get();
121
-
122
- if ($this->a === $this->b) {
123
- break;
124
- }
125
-
126
- if (ord($this->a) <= self::ORD_LF) {
127
- throw new JSMinException('Unterminated string literal.');
128
- }
129
-
130
- if ($this->a === '\\') {
131
- $this->output .= $this->a;
132
- $this->a = $this->get();
133
- }
134
- }
135
- }
136
-
137
- case self::ACTION_DELETE_A_B:
138
- $this->b = $this->next();
139
-
140
- if ($this->b === '/' && (
141
- $this->a === '(' || $this->a === ',' || $this->a === '=' ||
142
- $this->a === ':' || $this->a === '[' || $this->a === '!' ||
143
- $this->a === '&' || $this->a === '|' || $this->a === '?' ||
144
- $this->a === '{' || $this->a === '}' || $this->a === ';' ||
145
- $this->a === "\n" )) {
146
-
147
- $this->output .= $this->a . $this->b;
148
-
149
- for (;;) {
150
- $this->a = $this->get();
151
-
152
- if ($this->a === '[') {
153
- /*
154
- inside a regex [...] set, which MAY contain a '/' itself. Example: mootools Form.Validator near line 460:
155
- return Form.Validator.getValidator('IsEmpty').test(element) || (/^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]\.?){0,63}[a-z0-9!#$%&'*+/=?^_`{|}~-]@(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])$/i).test(element.get('value'));
156
- */
157
- for (;;) {
158
- $this->output .= $this->a;
159
- $this->a = $this->get();
160
-
161
- if ($this->a === ']') {
162
- break;
163
- } elseif ($this->a === '\\') {
164
- $this->output .= $this->a;
165
- $this->a = $this->get();
166
- } elseif (ord($this->a) <= self::ORD_LF) {
167
- throw new JSMinException('Unterminated regular expression set in regex literal.');
168
- }
169
- }
170
- } elseif ($this->a === '/') {
171
- break;
172
- } elseif ($this->a === '\\') {
173
- $this->output .= $this->a;
174
- $this->a = $this->get();
175
- } elseif (ord($this->a) <= self::ORD_LF) {
176
- throw new JSMinException('Unterminated regular expression literal.');
177
- }
178
-
179
- $this->output .= $this->a;
180
- }
181
-
182
- $this->b = $this->next();
183
- }
184
- }
185
- }
186
-
187
- /**
188
- * Get next char. Convert ctrl char to space.
189
- *
190
- * @return string|null
191
- */
192
- protected function get() {
193
- $c = $this->lookAhead;
194
- $this->lookAhead = null;
195
-
196
- if ($c === null) {
197
- if ($this->inputIndex < $this->inputLength) {
198
- $c = substr($this->input, $this->inputIndex, 1);
199
- $this->inputIndex += 1;
200
- } else {
201
- $c = null;
202
- }
203
- }
204
-
205
- if ($c === "\r") {
206
- return "\n";
207
- }
208
-
209
- if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
210
- return $c;
211
- }
212
-
213
- return ' ';
214
- }
215
-
216
- /**
217
- * Is $c a letter, digit, underscore, dollar sign, or non-ASCII character.
218
- *
219
- * @return bool
220
- */
221
- protected function isAlphaNum($c) {
222
- return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
223
- }
224
-
225
- /**
226
- * Perform minification, return result
227
- *
228
- * @uses action()
229
- * @uses isAlphaNum()
230
- * @return string
231
- */
232
- protected function min() {
233
- $this->a = "\n";
234
- $this->action(self::ACTION_DELETE_A_B);
235
-
236
- while ($this->a !== null) {
237
- switch ($this->a) {
238
- case ' ':
239
- if ($this->isAlphaNum($this->b)) {
240
- $this->action(self::ACTION_KEEP_A);
241
- } else {
242
- $this->action(self::ACTION_DELETE_A);
243
- }
244
- break;
245
-
246
- case "\n":
247
- switch ($this->b) {
248
- case '{':
249
- case '[':
250
- case '(':
251
- case '+':
252
- case '-':
253
- $this->action(self::ACTION_KEEP_A);
254
- break;
255
-
256
- case ' ':
257
- $this->action(self::ACTION_DELETE_A_B);
258
- break;
259
-
260
- default:
261
- if ($this->isAlphaNum($this->b)) {
262
- $this->action(self::ACTION_KEEP_A);
263
- }
264
- else {
265
- $this->action(self::ACTION_DELETE_A);
266
- }
267
- }
268
- break;
269
-
270
- default:
271
- switch ($this->b) {
272
- case ' ':
273
- if ($this->isAlphaNum($this->a)) {
274
- $this->action(self::ACTION_KEEP_A);
275
- break;
276
- }
277
-
278
- $this->action(self::ACTION_DELETE_A_B);
279
- break;
280
-
281
- case "\n":
282
- switch ($this->a) {
283
- case '}':
284
- case ']':
285
- case ')':
286
- case '+':
287
- case '-':
288
- case '"':
289
- case "'":
290
- $this->action(self::ACTION_KEEP_A);
291
- break;
292
-
293
- default:
294
- if ($this->isAlphaNum($this->a)) {
295
- $this->action(self::ACTION_KEEP_A);
296
- }
297
- else {
298
- $this->action(self::ACTION_DELETE_A_B);
299
- }
300
- }
301
- break;
302
-
303
- default:
304
- $this->action(self::ACTION_KEEP_A);
305
- break;
306
- }
307
- }
308
- }
309
-
310
- return $this->output;
311
- }
312
-
313
- /**
314
- * Get the next character, skipping over comments. peek() is used to see
315
- * if a '/' is followed by a '/' or '*'.
316
- *
317
- * @uses get()
318
- * @uses peek()
319
- * @throws JSMinException On unterminated comment.
320
- * @return string
321
- */
322
- protected function next() {
323
- $c = $this->get();
324
-
325
- if ($c === '/') {
326
- switch($this->peek()) {
327
- case '/':
328
- for (;;) {
329
- $c = $this->get();
330
-
331
- if (ord($c) <= self::ORD_LF) {
332
- return $c;
333
- }
334
- }
335
-
336
- case '*':
337
- $this->get();
338
-
339
- for (;;) {
340
- switch($this->get()) {
341
- case '*':
342
- if ($this->peek() === '/') {
343
- $this->get();
344
- return ' ';
345
- }
346
- break;
347
-
348
- case null:
349
- throw new JSMinException('Unterminated comment.');
350
- }
351
- }
352
-
353
- default:
354
- return $c;
355
- }
356
- }
357
-
358
- return $c;
359
- }
360
-
361
- /**
362
- * Get next char. If is ctrl character, translate to a space or newline.
363
- *
364
- * @uses get()
365
- * @return string|null
366
- */
367
- protected function peek() {
368
- $this->lookAhead = $this->get();
369
- return $this->lookAhead;
370
- }
371
- }
372
-
373
- // -- Exceptions ---------------------------------------------------------------
374
- class JSMinException extends Exception {}
375
-
376
- ?>
data/build/min.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- /*
3
- Retrojs minifier
4
- Version 0.1
5
-
6
- This will minify all javascript files in the source path.
7
-
8
- The default source path is entityjs/src/
9
-
10
- When releasing a new version of your game. You could put it inside the source folder (entityjs/src)
11
- and it will be compiled into one javascript file for you.
12
-
13
- @warning This will minify ALL files in source path directories and sub-directories even
14
- if its not a javascript file!
15
-
16
- @usage
17
- Go into the command prompt
18
- Nagivate to min.php
19
- type "php min.php"
20
- or put all files into your server and navigate to the min.php file.
21
- */
22
-
23
- require 'config.php';
24
-
25
- require 'jsmin.php';
26
-
27
- require 'files.php';
28
-
29
- //add all files
30
- foreach($files as $k){
31
- $source .= file_get_contents($k);
32
- }
33
-
34
- //compile
35
- $js=JSMin::minify($source);
36
-
37
- //add license
38
- $js = file_get_contents($license) . $js;
39
-
40
- //add version
41
- $js = str_replace($version_pattern, $version, $js);
42
-
43
- //paste into file
44
- $full_des = $des_path.'/'.$min_name;
45
-
46
- file_put_contents($full_des, $js);
47
-
48
- printf('Success! Minified file at %s',$full_des);
49
-
50
- ?>
data/changelog.txt DELETED
@@ -1,53 +0,0 @@
1
- -----------------------------------------------------------------------------------------
2
- Version 0.2.2 [Dec 6, 2011]
3
-
4
- Fixed distanceTo on point component.
5
- Added length argument to query filter / map.
6
- Removed multiple scene creation from re.scene.
7
- Components now dispatch dispose on entity removal.
8
- Renamed re.tile globals.
9
- Mouse now has optional toScreen coordinates.
10
- Screen now has screen convertions globals.
11
- Text input focus disables keyboard input.
12
-
13
- -----------------------------------------------------------------------------------------
14
- Version 0.2.1 [Oct 11, 2011]
15
-
16
- Added timestep component.
17
- Added rect component.
18
- Added circle component.
19
- Renamed size to hittest component.
20
- Add distanceTo to point component.
21
- Returning false on a signal will remove it.
22
- Added wait component.
23
- Renamed sprimate to flicker.
24
- Renamed position to anchor.
25
- Remove coordinate object properties.
26
- Renamed define to extend.
27
-
28
- -----------------------------------------------------------------------------------------
29
- Version 0.2 [Sept 30, 2011]
30
-
31
- Added query catching.
32
- Added log component.
33
- System is now extendable and can be used on multiple canvases.
34
- Added ticker component.
35
- Load now removes directories.
36
- Renamed default to inherit.
37
- Load now creates generic extensions.
38
- Sound component added.
39
- Keyboard, mouse, canvas and sounds now work in all browsers.
40
- Added scale and rotation to draw components.
41
- Implemented hitmap component.
42
- Adding signals now accepts a third context argument.
43
- Sprimate now accepts string frames.
44
- Added screen component.
45
- Added bitfont component.
46
- Added random component.
47
- Added playlist component.
48
- Added position component.
49
-
50
- -----------------------------------------------------------------------------------------
51
- Version 0.1 [Sept 15, 2011]
52
-
53
- First release
@@ -1,59 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <meta http-equiv="X-UA-Compatible" content="chrome=1">
6
-
7
- <title>Keys Demo</title>
8
- <script language="javascript">
9
- //modify path of entity.debug.js
10
- path = '../../';
11
- </script>
12
- <script src="../../lib/entity.debug.js" language="javascript"></script>
13
- <script src="keys.js" language="javascript"></script>
14
-
15
- <link rel="stylesheet" type="text/css" href="../style/sheet.css" />
16
-
17
- </head>
18
-
19
- <body>
20
-
21
-
22
- <div class="container_24">
23
- <div id="content">
24
- <h1>Keys Demo</h1>
25
-
26
- <div class="canvas-container">
27
- <canvas id="canvas" width="500" height="400"> </canvas>
28
- </div>
29
-
30
- <div class="grid_12">
31
- <h2 class="hd-left bg-yellow">Overview</h2>
32
- <p>
33
- You can control the arrow on screen with key input. You can even add more arrows. View the <a href="keys.js">source code</a> to see how easy it is to program.
34
- </p>
35
- </div>
36
-
37
- <div class="grid_12">
38
- <h2 class="hd-right bg-yellow">Controls</h2>
39
-
40
- <ul>
41
- <li><span class="key">W</span> <span class="key">A</span> <span class="key">S</span> <span class="key">D</span> Move arrow.</li>
42
- <li><span class="key">Arrow Keys</span> Move arrow. </li>
43
- <li><span class="key">SPACE</span> Add arrow.</li>
44
- <li><span class="key">R</span> Remove arrow.</li>
45
- </ul>
46
-
47
- </div>
48
-
49
- <div class="clear"></div>
50
- </div>
51
-
52
-
53
-
54
- </div>
55
-
56
- </body>
57
-
58
-
59
- </html>
@@ -1,148 +0,0 @@
1
- /*
2
- This is a demo of the pressed component and sprite component.
3
-
4
- By using WASD or the arrow keys you can move the sprite
5
- across the canvas.
6
-
7
- */
8
-
9
- //Its good practice to keep all constants in an organized object.
10
- //This makes it easier to edit in the future.
11
- re.constants = {
12
- canvasId:'#canvas',
13
- assets:"arrow.png",
14
- arrowSpeed:120,
15
- arrowSizeX:40,
16
- arrowSizeY:40
17
-
18
- };
19
-
20
- //first step of every entityjs game is to define a ready function
21
- //this will be called when the webpage is finished loading.
22
- re.ready(function(){
23
-
24
- //because we're not running on a server turn off root path
25
- re.load.path = '';
26
-
27
- //load up the spritesheet
28
- re.load(re.constants.assets)
29
- .complete(function(){
30
-
31
- //inits the system
32
- re.system.init(re.constants.canvasId);
33
-
34
- re.sys.clearColor = '#FFFFFF';
35
-
36
- //starts the mainloop of the application
37
- //you can also write sys for shortform
38
- re.sys.start();
39
-
40
- //create moving arrow
41
- re.entity('arrow');
42
-
43
- //add listener for space presses
44
- //you can also call re.e instead of re.entity
45
- re.e('keyboard')
46
- //listens for keyup on the space key
47
- .addSignal('keydown:space', function(){
48
-
49
- //creates a new entity with the arrow component
50
- re.e('arrow');
51
-
52
- })
53
- //second signal
54
- //remove key upon R key up
55
- .addSignal('keyup:r', function(){
56
-
57
- var q = re('arrow');
58
- if(q.length() > 0){
59
-
60
- //remove first arrow from array
61
- re('arrow').get(0).dispose();
62
- }
63
-
64
- });
65
-
66
- })
67
- .error(function(){
68
- console.log('Error something went wrong.');
69
- })
70
- .progress(function(current, total, asset){
71
- console.log('Progress: '+current+' / '+ total);
72
- console.log('Asset loaded: ', asset);
73
- });
74
-
75
- });
76
-
77
- /*
78
- This creates a new component kinda like a class
79
- except it can be removed or added at anytime.
80
-
81
- */
82
- re.c('arrow')
83
- //adds requirement components
84
- .require('pressed update sprite arrow.png')
85
- //define constructor
86
- .init(function(){
87
- //center arrow
88
- this.posX = re.sys.sizeX * 0.5;
89
- this.posY = re.sys.sizeY * 0.5;
90
-
91
- //this will break the sprite sheet into grids
92
- this.sizeX = re.constants.arrowSizeX;
93
- this.sizeY = re.constants.arrowSizeY;
94
-
95
- //listens for updates every frame
96
- this.addSignal('update', this.arrow_update);
97
-
98
- //prevents default action of keys
99
- this.preventDefault('up left right down space r');
100
-
101
- })
102
- //define deconstructor
103
- .dispose(function(){
104
-
105
- //will remove the signal
106
- this.removeSignal('update', this.arrow_update);
107
-
108
- })
109
- //values here are set only if they are null
110
- .inherit({
111
- speed:re.constants.arrowSpeed
112
- })
113
- //define private variables of the arrow component
114
- .namespace({
115
-
116
- update:function(tick, total){
117
- var s = this.speed * tick;
118
-
119
- //move based on keypress
120
- //listens for w key down OR up key down
121
- if(this.pressed('w', 'up')){
122
-
123
- this.posY -= s;
124
-
125
- this.setFrameId(0);
126
-
127
- } else if(this.pressed('s', 'down')){
128
-
129
- this.posY += s;
130
- this.setFrameId(2);
131
-
132
- }
133
-
134
- if(this.pressed('a', 'left')){
135
-
136
- this.posX -= s;
137
- this.setFrameId(3);
138
-
139
- } else if(this.pressed('d', 'right')){
140
-
141
- this.posX += s;
142
- this.setFrameId(1);
143
-
144
- }
145
-
146
- }
147
-
148
- });