angry-pixel 2.0.9 → 2.0.10

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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  ## What is Angry Pixel Engine?
9
9
 
10
- It is a 2D engine for browser games written in Typescript.
10
+ Angry Pixel Engine is a 2D game engine for browser written in Typescript.
11
11
 
12
12
  Main features:
13
13
 
@@ -15,9 +15,11 @@ Main features:
15
15
  - WebGL rendering
16
16
  - Sprite-based graphics and frame-by-frame animations
17
17
  - Text rendering based on bitmap fonts
18
- - Shadow/Lights rendering
19
- - Polygonal collisions and static/dynamic physical responses
18
+ - Basic 2D lightning system
19
+ - Polygonal collision detection and physical responses based on speed and acceleration.
20
20
  - Keyboard, mouse, gamepad and touch screen input support
21
+ - Ability to create desktop/mobile games using frameworks such as Electron.js
22
+ - Tilemaps: rendering based on comma separated values, and automatic collider generation. Support for JSON files exported from Tiled.
21
23
  - Dependency Injection
22
24
 
23
25
  ## Getting Started
@@ -68,7 +70,7 @@ import { Scene } from "angry-pixel";
68
70
 
69
71
  class MainScene extends Scene {
70
72
  // within this method we load the assets
71
- public loadAssets(): void {
73
+ loadAssets(): void {
72
74
  this.assetManager.loadImage("logo.png");
73
75
  }
74
76
  }
@@ -77,7 +79,7 @@ class MainScene extends Scene {
77
79
  And we add this scene to our game:
78
80
 
79
81
  ```typescript
80
- // arguments: the scene class, the scene name, and true because is the opening scene
82
+ // arguments: the scene class, the scene name, opening scene = true
81
83
  game.addScene(MainScene, "MainScene", true);
82
84
  ```
83
85
 
@@ -103,7 +105,7 @@ Once we have created our component, we will need a system that executes the busi
103
105
  import { GameSystem, Transform } from "angry-pixel";
104
106
 
105
107
  class MoveAndBounceSystem extends GameSystem {
106
- public onUpdate(): void {
108
+ onUpdate(): void {
107
109
  this.entityManager.search(MoveAndBounce).forEach(({ component, entity }) => {
108
110
  const transform = this.entityManager.getComponent(entity, Transform);
109
111
  const { boundaries, direction, speed } = component;
@@ -129,45 +131,47 @@ Once the system is created, we can add it to the scene
129
131
  import { Scene } from "angry-pixel";
130
132
 
131
133
  class MainScene extends Scene {
132
- // in this attribute we load the systems of the scene
133
- public systems: SystemType<System>[] = [MoveAndBounceSystem];
134
-
135
- public loadAssets(): void {
134
+ loadAssets(): void {
136
135
  this.assetManager.loadImage("logo.png");
137
136
  }
137
+
138
+ // within this method we load the systems of the scene
139
+ loadSystems(): void {
140
+ this.systems.push(MoveAndBounceSystem);
141
+ }
138
142
  }
139
143
  ```
140
144
 
141
145
  ### Create the entities
142
146
 
143
- Finally, we need to create two entities, one that represents our logo, to which we want to apply the behavior of moving and bouncing, and another one that represents the camera of our game. For it we will use the `EntityManager`, specifically the `createEntity` method. This method accepts both classes and instances of components.
147
+ Finally, we need to create two entities, one that represents our logo, to which we want to apply the behavior of moving and bouncing, and another one that represents the camera of our game. For this we will use the `EntityManager`, specifically the `createEntity` method. This method accepts an array of components, the components can be concrete instances (this is useful when it is necessary to pass parameters by constructor) or classes (if it is not necessary to pass parameters by constructor, we can pass only the class).
144
148
 
145
149
  ```typescript
146
150
  import { Camera, Scene, SpriteRenderer, Transform } from "angry-pixel";
147
151
 
148
152
  class MainScene extends Scene {
149
- public systems: SystemType<System>[] = [MoveAndBounceSystem];
150
-
151
- public loadAssets(): void {
153
+ loadAssets(): void {
152
154
  this.assetManager.loadImage("logo.png");
153
155
  }
154
156
 
157
+ loadSystems(): void {
158
+ this.systems.push(MoveAndBounceSystem);
159
+ }
160
+
155
161
  // within this method we create the entities
156
- public setup(): void {
162
+ setup(): void {
157
163
  // camera
158
- const camera = [Transform, new Camera({ layers: ["Logo"] })];
159
- this.entityManager.createEntity(camera);
164
+ this.entityManager.createEntity([new Transform(), new Camera({ layers: ["Logo"] })]);
160
165
 
161
166
  // logo
162
- const logo = [
163
- Transform,
164
- MoveAndBounce,
167
+ this.entityManager.createEntity([
168
+ new Transform(),
169
+ new MoveAndBounce(),
165
170
  new SpriteRenderer({
166
171
  layer: "Logo",
167
172
  image: this.assetManager.getImage("logo.png"),
168
173
  }),
169
- ];
170
- this.entityManager.createEntity(logo);
174
+ ]);
171
175
  }
172
176
  }
173
177
  ```