Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions example/pong/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const main = async (options: IRunOptions) => {

await app.init(options);

const ball = ecsLibrary.createEntity();
const ball = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(ball, new Velocity(0.04, 0));
ecsLibrary.addComponent(ball, new Position(0.5, 0));
ecsLibrary.addComponent(ball, new Bounce());
Expand All @@ -45,7 +45,7 @@ export const main = async (options: IRunOptions) => {
),
);

const bg = ecsLibrary.createEntity();
const bg = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(
bg,
new RectangleComponent(
Expand All @@ -57,7 +57,7 @@ export const main = async (options: IRunOptions) => {
),
);

const topWall = ecsLibrary.createEntity();
const topWall = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(
topWall,
new RectangleComponent(
Expand All @@ -69,7 +69,7 @@ export const main = async (options: IRunOptions) => {
ecsLibrary.addComponent(topWall, new Position(-1.8, 0.91));
ecsLibrary.addComponent(topWall, new Hitbox(3.6, 0.1));

const botWall = ecsLibrary.createEntity();
const botWall = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(
botWall,
new RectangleComponent(
Expand All @@ -81,7 +81,7 @@ export const main = async (options: IRunOptions) => {
ecsLibrary.addComponent(botWall, new Position(-1.8, -1));
ecsLibrary.addComponent(botWall, new Hitbox(3.6, 0.1));

const player1 = ecsLibrary.createEntity();
const player1 = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(player1, new Position(-1.8, -0.3));
ecsLibrary.addComponent(player1, new Velocity(0, 0.1));
ecsLibrary.addComponent(player1, new Hitbox(0.1, 0.5));
Expand All @@ -95,7 +95,7 @@ export const main = async (options: IRunOptions) => {
),
);

const player2 = ecsLibrary.createEntity();
const player2 = ecsLibrary.spawnEntity();
ecsLibrary.addComponent(player2, new Position(1.7, -0.3));
ecsLibrary.addComponent(player2, new Velocity(0, 0.1));
ecsLibrary.addComponent(player2, new Hitbox(0.1, 0.5));
Expand Down
2 changes: 1 addition & 1 deletion packages/ecs/src/ecs-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ECSLibrary extends BaseComponentSystemLibrary {
this.registry.addComponent(entity, component);
}

createEntity(): Entity {
spawnEntity(): Entity {
return this.registry.spawnEntity();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ecs/test/ecs-library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ describe("ECSLibrary", () => {
});

test("init and spawn entity", async () => {
const entity = ecs.createEntity();
const entity = ecs.spawnEntity();
expect(entity).toBeDefined();
expect(entity.getId()).toBe(0);
});

test("add component to entity", async () => {
const entity = ecs.createEntity();
const entity = ecs.spawnEntity();
const pos = new Position(1, 2);
ecs.addComponent(entity, pos);
const components = ecs.getComponents(Position);
Expand Down
Loading