angry-pixel 2.0.1 → 2.0.3

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
@@ -33,7 +33,7 @@ yarn add angry-pixel
33
33
 
34
34
  ### Initialize
35
35
 
36
- First we create an instance of the Game class:
36
+ First we create an instance of the `Game` class:
37
37
 
38
38
  ```typescript
39
39
  import { Game, GameConfig } from "angry-pixel";
@@ -50,7 +50,7 @@ const game = new Game(config);
50
50
 
51
51
  ### Create a Scene
52
52
 
53
- Then we will create the MainScene class, which extends the Scene base class. This class represents a scene in our game, and has three main functions:
53
+ Then we will create the `MainScene` class, which extends the `Scene` base class. This class represents a scene in our game, and has three main functions:
54
54
 
55
55
  - To load assets.
56
56
  - To create the initial entities.
@@ -78,7 +78,7 @@ game.addScene(MainScene, "MainScene", true);
78
78
 
79
79
  ### Create a Component
80
80
 
81
- Then we will create the MoveAndBounce component which has the necessary attributes to define the movement of our entity.
81
+ Then we will create the `MoveAndBounce` component which has the necessary attributes to define the movement of our entity.
82
82
 
83
83
  ```typescript
84
84
  import { Vector2 } from "angry-pixel";
@@ -92,7 +92,7 @@ class MoveAndBounce {
92
92
 
93
93
  ### Create a System
94
94
 
95
- Once we have created our component, we will need a system that executes the business logic. Extending the base class GameSystem, we will create our MoveAndBounceSystem, which, using the EntityManager, obtains all the entities that have the MoveAndBounce component, and executes the business logic necessary for the entity to move by bouncing on the edges of the screen:
95
+ Once we have created our component, we will need a system that executes the business logic. Extending the base class `GameSystem`, we will create our `MoveAndBounceSystem`, which, using the `EntityManager`, obtains all the entities that have the `MoveAndBounce` component, and executes the business logic necessary for the entity to move by bouncing on the edges of the screen:
96
96
 
97
97
  ```typescript
98
98
  import { GameSystem, Transform } from "angry-pixel";
@@ -135,10 +135,10 @@ class MainScene extends Scene {
135
135
 
136
136
  ### Create the entities
137
137
 
138
- Finally, we need two entities, one that represents our logo, which we want to move, and another one that represents the camera of our game. To do this we will create the entities in the following way:
138
+ 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.
139
139
 
140
140
  ```typescript
141
- import { Camera, Component, Scene, SpriteRenderer, Transform } from "angry-pixel";
141
+ import { Camera, Scene, SpriteRenderer, Transform } from "angry-pixel";
142
142
 
143
143
  class MainScene extends Scene {
144
144
  public systems: SystemType<System>[] = [MoveAndBounceSystem];
@@ -150,25 +150,27 @@ class MainScene extends Scene {
150
150
  // within this method we create the entities
151
151
  public setup(): void {
152
152
  // camera
153
- const cameraArchetype: Component[] = [new Transform(), new Camera({ layers: ["Logo"] })];
154
- this.entityManager.createEntity(cameraArchetype);
153
+ const camera = [Transform, new Camera({ layers: ["Logo"] })];
154
+ this.entityManager.createEntity(camera);
155
155
 
156
156
  // logo
157
- const logoArchetype: Component[] = [
158
- new Transform(),
157
+ const logo = [
158
+ Transform,
159
+ MoveAndBounce,
159
160
  new SpriteRenderer({
160
161
  layer: "Logo",
161
162
  image: this.assetManager.getImage("logo.png"),
162
163
  }),
163
- new MoveAndBounce(),
164
164
  ];
165
- this.entityManager.createEntity(logoArchetype);
165
+ this.entityManager.createEntity(logo);
166
166
  }
167
167
  }
168
168
  ```
169
169
 
170
170
  ### Run the game
171
171
 
172
+ Now we can start the game:
173
+
172
174
  ```typescript
173
175
  game.run();
174
176
  ```