Skip to content

Commit 76084c2

Browse files
committed
Added resizing box and circles as components attached to entity
1 parent e310176 commit 76084c2

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

packages/assets/src/index.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { SpriteSheetAnimation } from "@serbanghita-gamedev/component";
2-
import { EntityDeclaration } from "@serbanghita-gamedev/ecs";
3-
import { TiledMapFile } from "@serbanghita-gamedev/tiled";
4-
import { PhysicsBodyPropsDeclaration } from "@serbanghita-gamedev/component/PhysicsBody";
5-
import { SpriteSheetPropsDeclaration } from "@serbanghita-gamedev/component/SpriteSheet";
2+
import { TiledMapFileContents } from "@serbanghita-gamedev/tiled";
3+
import { PhysicsBodyPropsDeclaration, SpriteSheetPropsDeclaration } from "@serbanghita-gamedev/component";
64

75
export async function loadLocalImage(data: string): Promise<HTMLImageElement> {
86
const img = new Image();
@@ -25,7 +23,7 @@ export type Assets = {
2523
"entities/animations": { [key: string]: { [key: string]: SpriteSheetAnimation } };
2624
"entities/declarations": EntityDeclaration[];
2725
"maps/images": { [key: string]: HTMLImageElement };
28-
"maps/declarations": { [key: string]: TiledMapFile };
26+
"maps/declarations": { [key: string]: TiledMapFileContents };
2927
};
3028

3129
export type EntityDeclaration = {

packages/component/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ export { default as TiledMapFile } from "./TiledMapFile";
88
export { default as Position } from "./Position";
99
export { default as Tile } from "./Tile";
1010
export { default as TileMatrix } from "./TileMatrix";
11+
export { default as PhysicsBody, PhysicsBodyPropsDeclaration } from "./PhysicsBody";

packages/ecs/src/World.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import Entity, { EntityDeclaration } from "./Entity";
2-
import System, { SystemSettings } from "./System";
1+
import Entity from "./Entity";
2+
import System from "./System";
33
import Query, { IQueryFilters } from "./Query";
44
import Component from "./Component";
55
import { hasBit } from "@serbanghita-gamedev/bitmask";
66
import ComponentRegistry from "./ComponentRegistry";
7+
import { EntityDeclaration } from "@serbanghita-gamedev/assets";
78

89
export default class World {
910
public declarations = {

packages/ecs/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
import Component from "./Component";
77
import ComponentRegistry from "./ComponentRegistry";
8-
import Entity, {EntityDeclaration} from "./Entity";
8+
import Entity from "./Entity";
99
import Query from "./Query";
1010
import System from "./System";
1111
import World from "./World";
1212

1313
export {
1414
Component, ComponentRegistry,
15-
Entity, EntityDeclaration, Query,
15+
Entity, Query,
1616
System, World
1717
}

packages/geometry/src/Rectangle.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ export default class Rectangle {
7474
return !(this.topRightX < rectangle.topLeftX || this.bottomLeftY < rectangle.topLeftY || this.topLeftX > rectangle.topRightX || this.topLeftY > rectangle.bottomLeftY);
7575
}
7676

77-
public intersectsWithPoint(point: Point): boolean {
78-
return point.x >= this.topLeftX && point.x <= this.topRightX && point.y >= this.topLeftY && point.y <= this.bottomLeftY;
77+
public intersectsWithPoint(point: Point, tolerance:number = 0): boolean {
78+
return point.x >= this.topLeftX - tolerance && point.x <= this.topRightX + tolerance && point.y >= this.topLeftY - tolerance && point.y <= this.bottomLeftY + tolerance;
7979
}
80+
8081
}

0 commit comments

Comments
 (0)