├── .gitignore
├── .npmignore
├── LICENSE.md
├── README.md
├── background.png
├── games-background.png
├── package-lock.json
├── package.json
├── src
├── EngineObject.js
├── Point.js
└── index.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | webpack.config.js
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Yaroslav Ivanov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Elpy.js - 2D JavaScript game engine.
2 |
3 | 
4 |
5 | [](https://github.com/space2pacman/elpy/blob/master/LICENSE.md)
6 | [](https://en.wikipedia.org/wiki/JavaScript)
7 | [](https://img.shields.io/bundlephobia/min/elpy?color=brightgreen&label=Size)
8 | [](https://img.shields.io/npm/dt/elpy?label=Downloads)
9 | [](https://www.npmjs.com/package/elpy)
10 |
11 | | [Demo](https://space2pacman-misc.github.io/elpy-examples/docs/) | [Game examples](https://space2pacman-misc.github.io/elpy-examples/docs/examples.html) |
12 | | :---: | :---: |
13 |
14 | ## Docs
15 | - Install
16 | - Basic usage example
17 | - Engine
18 | - create()
19 | - add()
20 | - key()
21 | - keydown()
22 | - keyup()
23 | - mousemove()
24 | - click()
25 | - tick()
26 | - nextTick()
27 | - checkObjectInViewport()
28 | - fixingCamera()
29 | - unfixingCamera()
30 | - destroy()
31 | - on()
32 | - Event `'load'`
33 | - Event `'animation'`
34 | - load()
35 | - Engine getters
36 | - Object
37 | - run()
38 | - move()
39 | - fly()
40 | - jump()
41 | - fall()
42 | - push()
43 | - rotate()
44 | - stop()
45 | - destroy()
46 | - collision()
47 | - on()
48 | - Event `'collision'`
49 | - Event `'move'`
50 | - Event `'rotate'`
51 | - Event `'destroy'`
52 | - Event `'state'`
53 | - Event `'jump'`
54 | - Event `'fall'`
55 | - Event `'fly'`
56 | - Event object
57 | - removeCollision()
58 | - Object getters
59 | - Object setters
60 | - Development
61 | - License
62 |
63 | 
64 |
65 | ## Install
66 | #### Download
67 | Latest builds are available in the project [releases page](https://github.com/space2pacman/elpy/releases/latest).
68 | #### CDN
69 | ```js
70 | https://unpkg.com/elpy/dist/elpy.min.js
71 | ```
72 | #### NPM
73 | ```js
74 | npm install elpy
75 | ```
76 | ## Basic usage example
77 | ```html
78 |
79 |
80 |
81 | Elpy.js
82 |
83 |
84 |
85 |
86 |
110 |
111 |
112 | ```
113 | ## Engine
114 | ### Create engine instance
115 | ```js
116 | const elpy = new Elpy(
117 | "#element", // id element canvas or HTML object element get by document.querySelector().
118 | 500, // width.
119 | 500, // height.
120 | // options.
121 | {
122 | preload, // default - true, enable / disable preloader.
123 | favicon // default - true, enable / disable favicon.
124 | }
125 | )
126 | ```
127 | ---
128 | ### create(name, x, y, width, height, options)
129 | | name | type | description |
130 | | :---: | :---: | :--- |
131 | | **`name`** | `` | The object name must be unique. |
132 | | **`x`** | `` | Position of the object along the x-axis. |
133 | | **`y`** | `` | Position of the object along the y-axis. |
134 | | **`width`** | `` | Object width in pixels. |
135 | | **`height`** | `` | Object height in pixels. |
136 | | **`options`** | `