canvasengine 1.3.0 → 2.0.1-beta.1

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 (125) hide show
  1. package/.cursorrules +0 -0
  2. package/.github/workflows/ci.yml +29 -0
  3. package/README.md +79 -0
  4. package/dist/compiler/vite.js +119 -0
  5. package/dist/compiler/vite.js.map +1 -0
  6. package/dist/index.d.ts +846 -0
  7. package/dist/index.js +3340 -0
  8. package/dist/index.js.map +1 -0
  9. package/index.d.ts +6 -0
  10. package/logo.png +0 -0
  11. package/package.json +84 -18
  12. package/src/compiler/grammar.pegjs +180 -0
  13. package/src/compiler/vite.ts +166 -0
  14. package/src/components/Canvas.ts +134 -0
  15. package/src/components/Container.ts +46 -0
  16. package/src/components/DisplayObject.ts +458 -0
  17. package/src/components/DrawMap/index.ts +65 -0
  18. package/src/components/Graphic.ts +147 -0
  19. package/src/components/NineSliceSprite.ts +46 -0
  20. package/src/components/ParticleEmitter.ts +39 -0
  21. package/src/components/Scene.ts +6 -0
  22. package/src/components/Sprite.ts +493 -0
  23. package/src/components/Text.ts +145 -0
  24. package/src/components/Tilemap/Tile.ts +79 -0
  25. package/src/components/Tilemap/TileGroup.ts +207 -0
  26. package/src/components/Tilemap/TileLayer.ts +163 -0
  27. package/src/components/Tilemap/TileSet.ts +41 -0
  28. package/src/components/Tilemap/index.ts +80 -0
  29. package/src/components/TilingSprite.ts +39 -0
  30. package/src/components/Viewport.ts +159 -0
  31. package/src/components/index.ts +12 -0
  32. package/src/components/types/DisplayObject.ts +68 -0
  33. package/src/components/types/MouseEvent.ts +3 -0
  34. package/src/components/types/Spritesheet.ts +389 -0
  35. package/src/components/types/index.ts +4 -0
  36. package/src/directives/Drag.ts +84 -0
  37. package/src/directives/KeyboardControls.ts +922 -0
  38. package/src/directives/Scheduler.ts +112 -0
  39. package/src/directives/Sound.ts +91 -0
  40. package/src/directives/Transition.ts +45 -0
  41. package/src/directives/ViewportCull.ts +40 -0
  42. package/src/directives/ViewportFollow.ts +26 -0
  43. package/src/directives/index.ts +7 -0
  44. package/src/engine/animation.ts +113 -0
  45. package/src/engine/bootstrap.ts +19 -0
  46. package/src/engine/directive.ts +23 -0
  47. package/src/engine/reactive.ts +379 -0
  48. package/src/engine/signal.ts +138 -0
  49. package/src/engine/trigger.ts +40 -0
  50. package/src/engine/utils.ts +135 -0
  51. package/src/hooks/addContext.ts +6 -0
  52. package/src/hooks/useProps.ts +155 -0
  53. package/src/hooks/useRef.ts +21 -0
  54. package/src/index.ts +14 -0
  55. package/src/presets/Bar.ts +89 -0
  56. package/src/presets/Button.ts +0 -0
  57. package/src/presets/Joystick.ts +286 -0
  58. package/src/presets/NightAmbiant.ts +122 -0
  59. package/src/presets/Particle.ts +53 -0
  60. package/src/utils/Ease.ts +33 -0
  61. package/src/utils/RadialGradient.ts +86 -0
  62. package/starter/assets/logo.png +0 -0
  63. package/starter/components/app.ce +18 -0
  64. package/starter/components/hello.ce +35 -0
  65. package/starter/index.html +21 -0
  66. package/starter/main.ts +6 -0
  67. package/starter/package.json +20 -0
  68. package/starter/tsconfig.json +32 -0
  69. package/starter/vite.config.ts +12 -0
  70. package/tsconfig.json +32 -0
  71. package/tsconfig.node.json +10 -0
  72. package/tsup.config.ts +28 -0
  73. package/vitest.config.ts +12 -0
  74. package/.gitattributes +0 -22
  75. package/.npmignore +0 -163
  76. package/canvasengine-1.3.0.all.min.js +0 -21
  77. package/canvasengine.js +0 -5802
  78. package/core/DB.js +0 -24
  79. package/core/ModelServer.js +0 -348
  80. package/core/Users.js +0 -190
  81. package/core/engine-common.js +0 -952
  82. package/doc/cocoonjs.md +0 -36
  83. package/doc/doc-lang.yml +0 -43
  84. package/doc/doc-router.yml +0 -14
  85. package/doc/doc-tuto.yml +0 -9
  86. package/doc/doc.yml +0 -39
  87. package/doc/element.md +0 -37
  88. package/doc/entity.md +0 -90
  89. package/doc/extend.md +0 -47
  90. package/doc/get_started.md +0 -19
  91. package/doc/images/entity.png +0 -0
  92. package/doc/multitouch.md +0 -58
  93. package/doc/nodejs.md +0 -142
  94. package/doc/scene.md +0 -44
  95. package/doc/text.md +0 -156
  96. package/examples/server/client.html +0 -31
  97. package/examples/server/server.js +0 -16
  98. package/examples/tiled_server/client.html +0 -52
  99. package/examples/tiled_server/images/tiles_spritesheet.png +0 -0
  100. package/examples/tiled_server/server/map.json +0 -50
  101. package/examples/tiled_server/server/map.tmx +0 -16
  102. package/examples/tiled_server/server/server.js +0 -16
  103. package/extends/Animation.js +0 -910
  104. package/extends/Effect.js +0 -252
  105. package/extends/Gleed2d.js +0 -252
  106. package/extends/Hit.js +0 -1509
  107. package/extends/Input.js +0 -699
  108. package/extends/Marshal.js +0 -716
  109. package/extends/Scrolling.js +0 -388
  110. package/extends/Soundmanager2.js +0 -5466
  111. package/extends/Spritesheet.js +0 -196
  112. package/extends/Text.js +0 -366
  113. package/extends/Tiled.js +0 -403
  114. package/extends/Window.js +0 -575
  115. package/extends/gamepad.js +0 -397
  116. package/extends/socket.io.min.js +0 -2
  117. package/extends/swf/soundmanager2.swf +0 -0
  118. package/extends/swf/soundmanager2_debug.swf +0 -0
  119. package/extends/swf/soundmanager2_flash9.swf +0 -0
  120. package/extends/swf/soundmanager2_flash9_debug.swf +0 -0
  121. package/extends/swf/soundmanager2_flash_xdomain.zip +0 -0
  122. package/extends/workers/transition.js +0 -43
  123. package/index.js +0 -46
  124. package/license.txt +0 -19
  125. package/readme.md +0 -483
package/readme.md DELETED
@@ -1,483 +0,0 @@
1
- # Canvas Engine
2
- http://canvasengine.net
3
-
4
- ## Description
5
-
6
- Framework to create video games in HTML5 Canvas
7
-
8
- ## Get Started
9
-
10
- Follow the steps below to start:
11
-
12
- 1. Download the code `canvasengine-X.Y.Z.all.min.js` on Github or this website
13
- 2. Add this code in your page :
14
-
15
- <!DOCTYPE html>
16
- <script src="canvasengine-X.Y.Z.all.min.js"></script>
17
- <canvas id="canvas_id" width="640" height="480"></canvas>
18
-
19
-
20
- 3. Initialize the canvas in your JS file :
21
-
22
- var canvas = CE.defines("canvas_id").ready(function() {
23
-
24
- });
25
-
26
- Method `ready` is called when the canvas is ready (DOM loaded)
27
-
28
- ## Use development files
29
-
30
- Development files allows you to improve or correct CanvasEngine. To do this, insert these two files:
31
-
32
- <!DOCTYPE html>
33
- <script src="core/engine-common.js"></script>
34
- <script src="canvasengine.js"></script>
35
- <canvas id="canvas_id" width="640" height="480"></canvas>
36
-
37
- > View other branches of CanvasEngine on Github, you'll other version under development
38
-
39
- If you want to use features (Animation, Input, etc), add the appropriate files :
40
-
41
- <script src="extends/Animation.js"></script>
42
-
43
- If you develop or modify a feature, you can use the global variable `Global_CE` to use other features.
44
-
45
- Example :
46
-
47
- // In extends/your_feacture.js
48
- Global_CE.Input.press(Input.Enter, function() {
49
- });
50
-
51
- ### Your code
52
-
53
- Your code contains classe(s) :
54
-
55
- Class.create("My_Class", {
56
-
57
-
58
- });
59
-
60
- The developer can use this class in his game. You can also add code like this:
61
-
62
- var My_Class = {
63
- My_Class: {
64
- New: function) {
65
- return Class.New("My_Class");
66
- }
67
- }
68
- };
69
-
70
- it will use the namespace defined initially by the user :
71
-
72
- var canvas = CE.defines("canvas_id").extend(My_Class).ready(function() {
73
- canvas.Scene.call("MyScene");
74
- });
75
-
76
- canvas.Scene.new({
77
- name: "MyScene",
78
- ready: function(stage) {
79
- var foo = canvas.My_Class.New();
80
- }
81
- });
82
-
83
- ### Documentation
84
-
85
- Try to properly document the code for developer :
86
-
87
- /**
88
- @doc my_class
89
- @class Definition of "My Class"
90
- @example
91
-
92
- ...
93
-
94
- */
95
- Class.create("My_Class", {
96
-
97
- /**
98
- @doc my_class/
99
- @method foo ...
100
- @param bar {String} ...
101
- @example
102
-
103
- ...
104
-
105
- */
106
- foo: function(bar) {
107
-
108
- }
109
-
110
- });
111
-
112
- See [http://canvasengine.net/doc](http://canvasengine.net/doc)
113
-
114
-
115
- ## Features
116
-
117
- **Low-level API**
118
-
119
- * Fullscreen support (Supported platforms).
120
- * Multiple image file formats: DDS, JPG, PNG and TGA.
121
- * Define a transparent color
122
- * Scene Structure
123
- * Overlay scenes
124
- * Pause scene
125
- * Multiplayer model
126
- * Preloading
127
- * Get the percentage of loading
128
- * Elements Manipulation
129
- * Manipulation : jQuery syntaxe
130
- * Draw : HTML5 Canvas API syntaxe
131
- * Utilities
132
- * merge object
133
- * class
134
-
135
- **Windows**
136
-
137
- * Dialog box with the outline
138
- * Cursor
139
-
140
- **Animations**
141
-
142
- * Set an animation from a spritesheet
143
- * Frequence and animation speed
144
- * Sequence of multiple image
145
- * Creating a custom animation with multiple sequences
146
- * Display once, loop or temporary
147
-
148
- **Timeline (aka Tween)**
149
-
150
- * Easy to make interpolations effects
151
- * 29 Effects :
152
- * easeInQuad, easeOutQuad, easeInCubic, easeOutCubic, etc.
153
- * Loop
154
-
155
- **Collision**
156
-
157
- * Entities model
158
- * Test collision with virtual grid
159
- * Polygon intersection and Contains Point.
160
-
161
- **Text**
162
-
163
- * Set maximum line width
164
- * Display effect
165
- * Line by line
166
- * Character by character
167
- * font file formats : TTF, EOT
168
- * external fonts
169
- * Google Fonts
170
- * Fontdeck
171
- * Fonts.com
172
- * Typekit
173
-
174
- **Sound**
175
-
176
- * Multiple sound file formats: OGG, WAV, MP3.
177
- * Fading effects
178
- * Web Audio or SoundManager2
179
-
180
- **Effects**
181
-
182
- * Change tone screen
183
- * Perform a flash
184
- * Shake screen
185
-
186
- **Scrolling**
187
-
188
-
189
- **Level Design**
190
-
191
- * Tiled Map Editor (http://www.mapeditor.org)
192
- * Gleed 2d (http://gleed2d.codeplex.com)
193
-
194
- **Save & Load**
195
-
196
- * Encoding with BISON.js
197
-
198
- **Spritesheet Management**
199
-
200
- **Input**
201
-
202
- * Access to input types: Keyboard, Mouse, Xbox360 Pad, Joysticks
203
- * click, dbclick, mousemove, mouseup, mousedown, mouseout, mouseover*
204
- * Multi-Touch with Hammer.js :
205
- * hold
206
- * tap
207
- * doubletap
208
- * drag, dragstart, dragend, dragup, dragdown, dragleft, dragright
209
- * swipe, swipeup, swipedown, swipeleft, swiperight
210
- * transform, transformstart, transformend
211
- * rotate
212
- * pinch, pinchin, pinchout
213
- * touch (gesture detection starts)
214
- * release (gesture detection ends)
215
-
216
- ## Roadmap (in order)
217
-
218
- ### v1.4
219
-
220
- * Box2d
221
- * Synchronized multi canvas (local multiplayer)
222
-
223
- ### v2.0
224
-
225
- * Users and Groups Management for multiplayer model
226
- * CSS drawing
227
-
228
- ## Test performance
229
-
230
- ### v1.0.6
231
-
232
- * [Native class and CanvasEngine Class 1](http://jsperf.com/native-class-and-canvasengine-class)
233
- * [Native class and CanvasEngine Class 2](http://jsperf.com/native-class-and-canvasengine-class-test2)
234
-
235
- ## Contributors
236
-
237
- * [robwalch](https://github.com/robwalch) - [commit](https://github.com/robwalch/CanvasEngine/commit/e55909952c26ba1ec3e3d5bd6f733ddfffc4b647)
238
-
239
- ## Changelog
240
-
241
- ### v1.3.0
242
-
243
- * Add transition effects in scenes
244
- * Add loading fonts, json and videos
245
- * Add using Google Fonts
246
- * Add Using WebCam
247
- * multiplayer model improved
248
- * emit to specific scenes
249
- * `assignEvents()`
250
- * `loadEvents()` in Scene Class
251
- * `CE.connectServer()` and `CE.io`
252
- * Using `Tiled` and `Hit` classes
253
- * Compatible with Express 3
254
- * Documentation Improved
255
- * Tested with Node.js > 0.10.0
256
- * Add `getImageData()`, `putImageData()`, `createImageData()` and `toDataURL()` in Canvas class
257
- * Add `arcTo()` and `isPointInPath()` in Context class
258
- * Add `opaqueImage()` in Materials class
259
- * Add `toTimer()` in CanvasEngine Core
260
- * Add `toMatrix()` and `rotateMatrix()` in CanvasEngine Core
261
- * Add `remove()` in Window class
262
- * Add to Tiled Map Editor : spacing, margin and tile offset
263
- * Add `setPropertyByCell()`, `passableCell()` and `pathfinding()` in Grid class
264
- * Fix `invertColor()` in Materials class
265
- * Fix flip an element
266
- * Fix click on transparent image
267
- * Removes `forceEvent` property and adding the method `forceEvent()`
268
- * Improve `imageToCanvas()` in Materials class
269
- * Improve `getBasePath()` in Materials class
270
- * Ability to use the DOM to display the canvas
271
-
272
- ### v1.2.7
273
-
274
- * Add `extend()` in CanvasEngine Core ([Doc](http://canvasengine.net/doc/?p=core.utilities.extend))
275
- * Add `soundmanager` option in defines() ([Doc](http://canvasengine.net/doc/?p=core.engine.defines))
276
- * Add `ignoreLoadError` option in defines() ([Doc](http://canvasengine.net/doc/?p=core.engine.defines))
277
- * Removal `addMethod()` in Element class
278
- * Fix no recreating the sound if already created (with SoundManager2)
279
- * Rendering performance increased
280
-
281
- ### v1.2.6
282
-
283
- * Add `setSize()` in Canvas class ([Doc](http://canvasengine.net/doc/?p=core.canvas.setSize))
284
- * Add `isFullscreen()` in Canvas class ([Doc](http://canvasengine.net/doc/?p=core.canvas.isFullscreen))
285
- * Add mouse position in `trigger` parameters ([Doc](http://canvasengine.net/doc/?p=core.element.events.on))
286
- * Disable context menu by default ([Doc](http://canvasengine.net/doc/?p=core.engine.defines))
287
-
288
- ### v1.2.5
289
-
290
- * Fix loop animation
291
- * Add `patternSize` property in Animation Class ([Doc](http://canvasengine.net/doc/?p=extends.animation))
292
-
293
- ### v1.2.4
294
-
295
- * Fix `getMousePosition` ([Doc](http://canvasengine.net/doc/?p=core.canvas.getMousePosition))
296
-
297
- ### v1.2.3
298
-
299
- * Fix materials loading as `{id: Number, path: String}` ([Doc](http://canvasengine.net/doc/?p=core.materials.load))
300
- * Fix `mouseover` and `mouseout` ([Doc](http://canvasengine.net/doc/?p=core.element.events.on))
301
- * Add `mouveEvent` property in Canvas class ([Doc](http://canvasengine.net/doc/?p=core.canvas.mouseEvent))
302
- * Force `ready` method of canvas if the DOM is already loaded ([Doc](http://canvasengine.net/doc/?p=core.engine.ready))
303
-
304
- ### v1.2.2
305
-
306
- * Fix scene reloaded
307
- * Fix sounds for iOS
308
-
309
- ### v1.2.1
310
-
311
- * Add getBasePath method in Materials class
312
- * Add getFilename method in Materials class
313
- * Add mousedown et mouseup events
314
- * Add zIndex method in Scene class
315
- * Fix mulit-touch gestures on touchpads
316
- * Improve loading sounds
317
-
318
- ### v1.2.0
319
-
320
- * Add Text feature
321
- * Add Effect feature
322
- * Add Cursor feature in Window class
323
- * Add off method in Element class
324
- * Add scroll method in Window class
325
- * Add invertColor method in Materials class
326
- * Add forceEvent property in Element class
327
- * Add hasCmd method in Context class
328
- * Add propagationOpacity property in Element Class
329
- * Add mouseScroll method in Scrolling class
330
- * Add random method in CanvasEngine Core
331
- * Add freeze property in Scrolling class
332
- * Add mobileUserAgent method in CanvasEngine core
333
- * Fix event "canvas:render" when element is hidden
334
- * Fix clip method in Context class
335
- * Fix name attribute in Element class
336
- * Fix value 0 in Timeline class
337
- * Fix press method in Input class
338
- * Fix load method in Materials class
339
- * Fix animation construct in Animation class
340
- * Fix load sound in cache
341
- * Fix scrolling
342
- * Fix measureText method in Canvas class
343
- * Fix draw map in Tiled class
344
- * Fix testCell method in Hit class
345
- * Fix intersectsWith method in Polygon class
346
- * Fix animation loop in Animation class
347
- * Improve children method in Element class
348
- * Improve position method in Window class
349
- * Improve append method in Element class
350
- * Improve clone method in Element class
351
- * Improve reset method in Input class
352
- * Improve load and dump methods in Marshal class
353
- * Improve new method in CanvasEngine class
354
- * Improve classes in Hit class
355
- * Improve isPressed method in Input class
356
- * Merge Hammer.js in CanvasEngine for multi touch feature
357
-
358
- ### v1.1.1
359
-
360
- * Add testCell method in Grid class
361
- * Add removeCmd method in Element class
362
- * Add origin points in parameters in set method in SpriteSheet class
363
- * Changing getEntityCells method in Grid Class
364
- * Fix imageToCanvas method in Materials class
365
- * Fix frequence in Animation class
366
- * Fix set method in SpriteSheet class for windows
367
- * getPropertyByCell method in Hit class returns undefined if column or row doesn't exist
368
-
369
-
370
- ### v1.1.0
371
-
372
- * Add specific image param in animation
373
- * Add position param in animation
374
- * Add getStage method in Scene class
375
- * Add getEnabled method in Scene class
376
- * Add collision feature
377
- * Add Window feature
378
- * Add overlay scenes
379
- * Add moveArray method in CanvasEngine Object
380
- * Add offset method in Element Class
381
- * Add position method in Element Class
382
- * Add pack method in Element Class
383
- * Add unpack method in Element Class
384
- * Add detach method in Element Class
385
- * Add children method in Element Class
386
- * Add removeAttr method in Element Class
387
- * Add prepend method in Element Class
388
- * Add zIndex method in Element Class
389
- * Add zIndexBefore method in Element Class
390
- * Fix reload scene
391
- * Fix click on multi scene
392
- * Fix click on element witch opacity < 1
393
- * Improving draw performance
394
- * Improving documentation (markdown)
395
-
396
- ### v1.0.8
397
-
398
- * Add multi-tilemap in Tiled Class (robwalch)
399
- * Add origin points in Spritesheet Class (robwalch)
400
- * Fix keyUp method in Input Class (https://github.com/RSamaium/CanvasEngine/issues/4)
401
- * Fix NPM problem (https://github.com/RSamaium/CanvasEngine/issues/7)
402
- * Fix identifiers keys in Input class
403
- * Fix addKey method in Input class
404
- * Fix set method in Spritesheet class
405
-
406
- ### v1.0.7
407
-
408
- * Move clear method (Context class -> Canvas class)
409
- * Change exit method in Scene Class
410
- * Add multi scenes feature.
411
- * Add togglePause method in Scene Class
412
- * Add pause method in Scene Class
413
- * Add isEnabled method in Scene Class
414
- * Add exitAll method in Scene Class
415
- * Add eventExist method in Element Class
416
- * Add alias for new method : New
417
- * Improves the performance of clicks
418
- * Fix [Info of tile size](https://github.com/RSamaium/CanvasEngine/issues/2)
419
- * Fix "this_" in Marshal class
420
- * Improving documentation
421
-
422
- ### v1.0.6
423
-
424
- * Change addLoopListener method
425
- * Ignore loading music if the type is not supported
426
- * Add getExtension method in Materials class
427
- * Add remove method in Marshal class
428
- * Add special events defined by a namespace (methods: refresh)
429
- * Add moveTo, lineTo, quadraticCurveTo, bezierCurveTo in Context
430
- * Add addMethod method in Context Class
431
- * Addition to loading the canvas for CocoonJS)
432
- * Fix save and load (IE9+)
433
- * Fix reference of image loaded (for CocoonJS)
434
- * Fix click on element
435
- * Fix Gamepad (Google Chrome)
436
- * Fix extend Context Class
437
- * Fix positions of a element's children resized
438
- * Fix origin point of element's children
439
- * Improving documentation
440
-
441
- ### v1.0.5
442
-
443
- * Fix restart of animations (Animation Class)
444
- * Fix children elements opacity
445
- * Fix reading some element properties
446
- * Fix positions of a element resized
447
- * Add rgbToHex method in CanvasEngine object
448
- * Add pattern method in Spritesheet class
449
- * Add cropImage method in Materials class
450
- * Add transparentColor method in Materials class
451
- * Add imageToCanvas method in Materials class
452
- * Add getScene method in Element class
453
- * Add createPattern method in Canvas class
454
- * Add createLinearGradient method in Canvas class
455
- * Add createRadialGradient method in Canvas class
456
- * Add addColorStop method in Canvas class
457
- * Add measureText method in Canvas class
458
- * Improving performance click
459
- * Improving the get method in Materials class
460
- * Improving documentation
461
-
462
- ### v1.0.4
463
-
464
- * Fix animated images
465
- * Improving documentation
466
-
467
- ### v1.0.3
468
- Not indicated
469
- ### v1.0.2
470
- Not indicated
471
- ### v1.0.1
472
- Not indicated
473
- ### v1.0.0
474
-
475
- * Initial Release
476
-
477
- ## Examples and Demos
478
-
479
- http://rsamaium.github.com/CanvasEngine
480
-
481
- ## License
482
-
483
- MIT. Free for commercial use.