dino-ge 1.2.13 → 1.2.15
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/dist/Circle.js +1 -1
- package/dist/Circle.js.map +1 -1
- package/dist/GameObject.d.ts +38 -3
- package/dist/GameObject.js +58 -2
- package/dist/GameObject.js.map +1 -1
- package/dist/LineComponent.js +9 -0
- package/dist/LineComponent.js.map +1 -1
- package/dist/Physics.js +8 -8
- package/dist/Physics.js.map +1 -1
- package/dist/PhysicsSystem.js +3 -3
- package/dist/PhysicsSystem.js.map +1 -1
- package/dist/Rectangle.js +1 -1
- package/dist/Rectangle.js.map +1 -1
- package/dist/ShapeComponent.js +10 -5
- package/dist/ShapeComponent.js.map +1 -1
- package/dist/Sprite.js +1 -1
- package/dist/Sprite.js.map +1 -1
- package/dist/SpriteComponent.js +9 -3
- package/dist/SpriteComponent.js.map +1 -1
- package/dist/Text.js +1 -1
- package/dist/Text.js.map +1 -1
- package/dist/TextComponent.js +9 -3
- package/dist/TextComponent.js.map +1 -1
- package/dist/Tilemap.js +1 -1
- package/dist/Tilemap.js.map +1 -1
- package/dist/TilemapComponent.js +9 -2
- package/dist/TilemapComponent.js.map +1 -1
- package/dist/TransformComponent.d.ts +21 -4
- package/dist/TransformComponent.js +49 -4
- package/dist/TransformComponent.js.map +1 -1
- package/package.json +1 -1
- package/src/Circle.ts +1 -1
- package/src/GameObject.ts +62 -4
- package/src/LineComponent.ts +11 -0
- package/src/Physics.ts +8 -8
- package/src/PhysicsSystem.ts +3 -3
- package/src/Rectangle.ts +1 -1
- package/src/ShapeComponent.ts +12 -5
- package/src/Sprite.ts +1 -1
- package/src/SpriteComponent.ts +10 -4
- package/src/Text.ts +3 -3
- package/src/TextComponent.ts +12 -5
- package/src/Tilemap.ts +1 -1
- package/src/TilemapComponent.ts +10 -3
- package/src/TransformComponent.ts +65 -4
package/dist/Circle.js
CHANGED
|
@@ -28,7 +28,7 @@ export default class Circle extends GameObject {
|
|
|
28
28
|
throw new Error('You must provide a radius for Circle');
|
|
29
29
|
}
|
|
30
30
|
this.tag = defaultedProps.tag;
|
|
31
|
-
this.
|
|
31
|
+
this.localPosition = defaultedProps.position;
|
|
32
32
|
this.radius = defaultedProps.radius;
|
|
33
33
|
this.colour = defaultedProps.colour;
|
|
34
34
|
this.zIndex = defaultedProps.zIndex;
|
package/dist/Circle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Circle.js","sourceRoot":"","sources":["../src/Circle.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAkBjD,MAAM,YAAY,GAAG;IACnB,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,OAAO;IACf,MAAM,EAAE,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAM5C,wCAAwC;IACxC,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IACvC,yCAAyC;IACzC,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAExC,kCAAkC;IAClC,IAAI,MAAM;QACR,OAAO,IAAI,OAAO,CAChB,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAC7B,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAC9B,CAAC;IACJ,CAAC;IAED,YAAY,KAAkB;QAC5B,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAE1E,MAAM,cAAc,mCACf,YAAY,GACZ,KAAK,CACT,CAAC;QAEF,IAAI,CAAC,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,CACT,CAAC;QAEF,IAAI,CAAC,CAAC,cAAc,CAAC,QAAQ,YAAY,OAAO,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC,QAAQ,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QAEpC,IAAI,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAE1E,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;CACF"}
|
package/dist/GameObject.d.ts
CHANGED
|
@@ -53,10 +53,45 @@ export default abstract class GameObject {
|
|
|
53
53
|
set visible(val: boolean);
|
|
54
54
|
/**
|
|
55
55
|
* The world-space position of the object.
|
|
56
|
-
*
|
|
56
|
+
* Getter returns world position, setter sets local position.
|
|
57
57
|
*/
|
|
58
58
|
get position(): Vector2;
|
|
59
59
|
set position(val: Vector2);
|
|
60
|
+
/**
|
|
61
|
+
* The local position relative to the parent.
|
|
62
|
+
*/
|
|
63
|
+
get localPosition(): Vector2;
|
|
64
|
+
set localPosition(val: Vector2);
|
|
65
|
+
/**
|
|
66
|
+
* The world-space rotation in radians.
|
|
67
|
+
*/
|
|
68
|
+
get rotation(): number;
|
|
69
|
+
set rotation(val: number);
|
|
70
|
+
/**
|
|
71
|
+
* The local rotation in radians relative to the parent.
|
|
72
|
+
*/
|
|
73
|
+
get localRotation(): number;
|
|
74
|
+
set localRotation(val: number);
|
|
75
|
+
/**
|
|
76
|
+
* The local scale relative to the parent.
|
|
77
|
+
*/
|
|
78
|
+
get scale(): Vector2;
|
|
79
|
+
set scale(val: Vector2);
|
|
80
|
+
/**
|
|
81
|
+
* Adds a child GameObject to this entity.
|
|
82
|
+
* @param child The child entity to add.
|
|
83
|
+
*/
|
|
84
|
+
addChild(child: GameObject): void;
|
|
85
|
+
/**
|
|
86
|
+
* Removes a child GameObject from this entity.
|
|
87
|
+
* @param child The child entity to remove.
|
|
88
|
+
*/
|
|
89
|
+
removeChild(child: GameObject): void;
|
|
90
|
+
/**
|
|
91
|
+
* Gets or sets the parent GameObject.
|
|
92
|
+
*/
|
|
93
|
+
get parent(): GameObject | undefined;
|
|
94
|
+
set parent(val: GameObject | undefined);
|
|
60
95
|
/**
|
|
61
96
|
* Current velocity in pixels per second.
|
|
62
97
|
* @deprecated Use getComponent(PhysicsComponent).velocity
|
|
@@ -107,9 +142,9 @@ export default abstract class GameObject {
|
|
|
107
142
|
prototype: T;
|
|
108
143
|
}): T | undefined;
|
|
109
144
|
/** The width of the object in pixels. */
|
|
110
|
-
|
|
145
|
+
get width(): number;
|
|
111
146
|
/** The height of the object in pixels. */
|
|
112
|
-
|
|
147
|
+
get height(): number;
|
|
113
148
|
/**
|
|
114
149
|
* Registers the object with the active scene or global engine loop.
|
|
115
150
|
*/
|
package/dist/GameObject.js
CHANGED
|
@@ -70,10 +70,62 @@ export default class GameObject {
|
|
|
70
70
|
set visible(val) { this._visibility.visible = val; }
|
|
71
71
|
/**
|
|
72
72
|
* The world-space position of the object.
|
|
73
|
-
*
|
|
73
|
+
* Getter returns world position, setter sets local position.
|
|
74
74
|
*/
|
|
75
|
-
get position() { return this._transform.
|
|
75
|
+
get position() { return this._transform.worldPosition; }
|
|
76
76
|
set position(val) { this._transform.position = val; }
|
|
77
|
+
/**
|
|
78
|
+
* The local position relative to the parent.
|
|
79
|
+
*/
|
|
80
|
+
get localPosition() { return this._transform.position; }
|
|
81
|
+
set localPosition(val) { this._transform.position = val; }
|
|
82
|
+
/**
|
|
83
|
+
* The world-space rotation in radians.
|
|
84
|
+
*/
|
|
85
|
+
get rotation() { return this._transform.worldRotation; }
|
|
86
|
+
set rotation(val) { this._transform.rotation = val; }
|
|
87
|
+
/**
|
|
88
|
+
* The local rotation in radians relative to the parent.
|
|
89
|
+
*/
|
|
90
|
+
get localRotation() { return this._transform.rotation; }
|
|
91
|
+
set localRotation(val) { this._transform.rotation = val; }
|
|
92
|
+
/**
|
|
93
|
+
* The local scale relative to the parent.
|
|
94
|
+
*/
|
|
95
|
+
get scale() { return this._transform.scale; }
|
|
96
|
+
set scale(val) { this._transform.scale = val; }
|
|
97
|
+
/**
|
|
98
|
+
* Adds a child GameObject to this entity.
|
|
99
|
+
* @param child The child entity to add.
|
|
100
|
+
*/
|
|
101
|
+
addChild(child) {
|
|
102
|
+
child._transform.parent = this._transform;
|
|
103
|
+
this._transform.children.add(child._transform);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Removes a child GameObject from this entity.
|
|
107
|
+
* @param child The child entity to remove.
|
|
108
|
+
*/
|
|
109
|
+
removeChild(child) {
|
|
110
|
+
if (child._transform.parent === this._transform) {
|
|
111
|
+
child._transform.parent = undefined;
|
|
112
|
+
this._transform.children.delete(child._transform);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets or sets the parent GameObject.
|
|
117
|
+
*/
|
|
118
|
+
get parent() {
|
|
119
|
+
var _a;
|
|
120
|
+
return (_a = this._transform.parent) === null || _a === void 0 ? void 0 : _a.gameObject;
|
|
121
|
+
}
|
|
122
|
+
set parent(val) {
|
|
123
|
+
if (this._transform.parent) {
|
|
124
|
+
this._transform.parent.children.delete(this._transform);
|
|
125
|
+
}
|
|
126
|
+
this._transform.parent = val === null || val === void 0 ? void 0 : val._transform;
|
|
127
|
+
val === null || val === void 0 ? void 0 : val._transform.children.add(this._transform);
|
|
128
|
+
}
|
|
77
129
|
/**
|
|
78
130
|
* Current velocity in pixels per second.
|
|
79
131
|
* @deprecated Use getComponent(PhysicsComponent).velocity
|
|
@@ -134,6 +186,10 @@ export default class GameObject {
|
|
|
134
186
|
getComponent(componentClass) {
|
|
135
187
|
return this._components.get(componentClass.name);
|
|
136
188
|
}
|
|
189
|
+
/** The width of the object in pixels. */
|
|
190
|
+
get width() { return 0; }
|
|
191
|
+
/** The height of the object in pixels. */
|
|
192
|
+
get height() { return 0; }
|
|
137
193
|
/**
|
|
138
194
|
* Registers the object with the active scene or global engine loop.
|
|
139
195
|
*/
|
package/dist/GameObject.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GameObject.js","sourceRoot":"","sources":["../src/GameObject.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAGjC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,OAAO,kBAAkB,MAAM,yBAAyB,CAAC;AACzD,OAAO,YAAY,MAAM,mBAAmB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,iBAAiB,MAAM,wBAAwB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAgB,UAAU;IAWtC,YAAY,GAAW,EAAE,MAAc;QAVvC,wDAAwD;QAChD,gBAAW,GAA2B,IAAI,GAAG,EAAE,CAAC;QAUtD,8EAA8E;QAC9E,sDAAsD;QACtD,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7B,IAAI,CAAC,WAAW,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC7C,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEpC,IAAI,CAAC,QAAQ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21 @@ export default class LineComponent extends RenderComponent {
|
|
|
14
14
|
* @param ctx The canvas 2D rendering context.
|
|
15
15
|
*/
|
|
16
16
|
draw(ctx) {
|
|
17
|
+
if (!this.gameObject)
|
|
18
|
+
return;
|
|
19
|
+
const { position, rotation, scale } = this.gameObject;
|
|
20
|
+
ctx.save();
|
|
21
|
+
ctx.translate(position.x, position.y);
|
|
22
|
+
if (rotation !== 0)
|
|
23
|
+
ctx.rotate(rotation);
|
|
24
|
+
ctx.scale(scale.x, scale.y);
|
|
17
25
|
ctx.beginPath();
|
|
18
26
|
ctx.lineWidth = this.strokeWidth;
|
|
19
27
|
ctx.moveTo(this.p1.x, this.p1.y);
|
|
20
28
|
ctx.lineTo(this.p2.x, this.p2.y);
|
|
21
29
|
ctx.stroke();
|
|
22
30
|
ctx.closePath();
|
|
31
|
+
ctx.restore();
|
|
23
32
|
}
|
|
24
33
|
}
|
|
25
34
|
//# sourceMappingURL=LineComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineComponent.js","sourceRoot":"","sources":["../src/LineComponent.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,eAAe;IAQxD,YAAY,WAAmB,EAAE,EAAW,EAAE,EAAW;QACvD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,GAA6B;QAChC,GAAG,CAAC,SAAS,EAAE,CAAC;QAChB,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC;QACjC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CA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C,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACjC,GAAG,CAAC,MAAM,EAAE,CAAC;QACb,GAAG,CAAC,SAAS,EAAE,CAAC;QAEhB,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF"}
|
package/dist/Physics.js
CHANGED
|
@@ -47,29 +47,29 @@ export default class Physics {
|
|
|
47
47
|
if (overlapX < overlapY) {
|
|
48
48
|
if (obj1.position.x < obj2.position.x) {
|
|
49
49
|
if (!obj1.isStatic)
|
|
50
|
-
obj1.
|
|
50
|
+
obj1.localPosition.x -= overlapX / 2;
|
|
51
51
|
if (!obj2.isStatic)
|
|
52
|
-
obj2.
|
|
52
|
+
obj2.localPosition.x += overlapX / 2;
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
55
|
if (!obj1.isStatic)
|
|
56
|
-
obj1.
|
|
56
|
+
obj1.localPosition.x += overlapX / 2;
|
|
57
57
|
if (!obj2.isStatic)
|
|
58
|
-
obj2.
|
|
58
|
+
obj2.localPosition.x -= overlapX / 2;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
if (obj1.position.y < obj2.position.y) {
|
|
63
63
|
if (!obj1.isStatic)
|
|
64
|
-
obj1.
|
|
64
|
+
obj1.localPosition.y -= overlapY / 2;
|
|
65
65
|
if (!obj2.isStatic)
|
|
66
|
-
obj2.
|
|
66
|
+
obj2.localPosition.y += overlapY / 2;
|
|
67
67
|
}
|
|
68
68
|
else {
|
|
69
69
|
if (!obj1.isStatic)
|
|
70
|
-
obj1.
|
|
70
|
+
obj1.localPosition.y += overlapY / 2;
|
|
71
71
|
if (!obj2.isStatic)
|
|
72
|
-
obj2.
|
|
72
|
+
obj2.localPosition.y -= overlapY / 2;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
package/dist/Physics.js.map
CHANGED
|
@@ -1 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AAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;gBACzD,IAAI,CAAC,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;gBACtC,IAAI,CAAC,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;gBACzD,IAAI,CAAC,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;gBACzD,IAAI,CAAC,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,QAAQ,GAAG,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/PhysicsSystem.js
CHANGED
|
@@ -17,9 +17,9 @@ export default class PhysicsSystem extends System {
|
|
|
17
17
|
// Apply acceleration to velocity
|
|
18
18
|
physics.velocity.x += physics.acceleration.x * fixedDelta;
|
|
19
19
|
physics.velocity.y += physics.acceleration.y * fixedDelta;
|
|
20
|
-
// Apply velocity to position
|
|
21
|
-
object.
|
|
22
|
-
object.
|
|
20
|
+
// Apply velocity to local position
|
|
21
|
+
object.localPosition.x += physics.velocity.x * fixedDelta;
|
|
22
|
+
object.localPosition.y += physics.velocity.y * fixedDelta;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhysicsSystem.js","sourceRoot":"","sources":["../src/PhysicsSystem.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,MAAM;IAC/C;;;;OAIG;IACa,WAAW,CAAC,QAAyB,EAAE,UAAkB;QACvE,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;YACtD,IAAI,OAAO,EAAE,CAAC;gBACZ,iCAAiC;gBACjC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,UAAU,CAAC;gBAC1D,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,UAAU,CAAC;gBAE1D,
|
|
1
|
+
{"version":3,"file":"PhysicsSystem.js","sourceRoot":"","sources":["../src/PhysicsSystem.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,MAAM;IAC/C;;;;OAIG;IACa,WAAW,CAAC,QAAyB,EAAE,UAAkB;QACvE,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;YACtD,IAAI,OAAO,EAAE,CAAC;gBACZ,iCAAiC;gBACjC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,UAAU,CAAC;gBAC1D,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,UAAU,CAAC;gBAE1D,mCAAmC;gBACnC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC;gBAC1D,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,CAAC;YAC5D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/Rectangle.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class Rectangle extends GameObject {
|
|
|
24
24
|
throw new Error('You must provide a width and height for Rectangle');
|
|
25
25
|
}
|
|
26
26
|
this.tag = defaultedProps.tag;
|
|
27
|
-
this.
|
|
27
|
+
this.localPosition = defaultedProps.position;
|
|
28
28
|
this._width = defaultedProps.width;
|
|
29
29
|
this._height = defaultedProps.height;
|
|
30
30
|
this.colour = defaultedProps.colour;
|
package/dist/Rectangle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rectangle.js","sourceRoot":"","sources":["../src/Rectangle.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,cAAc,MAAM,qBAAqB,CAAC;AAoBjD,MAAM,YAAY,GAAG;IACnB,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;CACxC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,UAAU;IAM/C,8BAA8B;IAC9B,IAAI,KAAK,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC;IACrC,+BAA+B;IAC/B,IAAI,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;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
|
20
|
-
const { position } = this.gameObject;
|
|
20
|
+
const { position, rotation, scale } = this.gameObject;
|
|
21
|
+
ctx.save();
|
|
22
|
+
ctx.translate(position.x, position.y);
|
|
23
|
+
if (rotation !== 0)
|
|
24
|
+
ctx.rotate(rotation);
|
|
25
|
+
ctx.scale(scale.x, scale.y);
|
|
21
26
|
ctx.fillStyle = this.colour;
|
|
22
27
|
if (this.type === 'rect') {
|
|
23
|
-
ctx.fillRect(
|
|
28
|
+
ctx.fillRect(0, 0, this.width, this.height);
|
|
24
29
|
}
|
|
25
30
|
else if (this.type === 'circle') {
|
|
26
31
|
ctx.beginPath();
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ctx.arc(centerX, centerY, this.width, 0, Math.PI * 2);
|
|
32
|
+
// width is radius. In local space center is at (radius, radius)
|
|
33
|
+
ctx.arc(this.width, this.width, this.width, 0, Math.PI * 2);
|
|
30
34
|
ctx.fill();
|
|
31
35
|
ctx.closePath();
|
|
32
36
|
}
|
|
37
|
+
ctx.restore();
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
40
|
//# sourceMappingURL=ShapeComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeComponent.js","sourceRoot":"","sources":["../src/ShapeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAOnD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,eAAe;IAUzD,YAAY,IAAe,EAAE,MAAc,EAAE,KAAa,EAAE,SAAiB,CAAC;QAC5E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,GAA6B;QAChC,IAAI,CAAC,IA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AAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAClC,GAAG,CAAC,SAAS,EAAE,CAAC;YAChB,gEAAgE;YAChE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC5D,GAAG,CAAC,IAAI,EAAE,CAAC;YACX,GAAG,CAAC,SAAS,EAAE,CAAC;QAClB,CAAC;QAED,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF"}
|
package/dist/Sprite.js
CHANGED
|
@@ -62,7 +62,7 @@ export default class Sprite extends GameObject {
|
|
|
62
62
|
}
|
|
63
63
|
this._spriteComponent = new SpriteComponent(img, props.rows, props.cols, props.startCol, props.endCol);
|
|
64
64
|
this.addComponent(this._spriteComponent);
|
|
65
|
-
this.
|
|
65
|
+
this.localPosition = props.position;
|
|
66
66
|
this.registered = false;
|
|
67
67
|
}
|
|
68
68
|
/**
|
package/dist/Sprite.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sprite.js","sourceRoot":"","sources":["../src/Sprite.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,OAAO,cAAc,MAAM,aAAa,CAAC;AACzC,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAwBnD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAI5C,uCAAuC;IACvC,IAAI,GAAG,KAAuB,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,IAAI,GAAG,CAAC,GAAqB,IAAI,IAAI,CAAC,gBAAgB,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;IAEnE,yCAAyC;IACzC,I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EAAkE;QAClE,eAAU,GAAY,KAAK,CAAC;QAmC1B,IAAI,GAAqB,CAAC;QAC1B,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YAClC,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,CACzC,GAAG,EACH,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,MAAM,CACb,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,IAAI,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,gBAAgB,CAAC,OAAO,GAAG,KAAK,CAAC;QACtC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/SpriteComponent.js
CHANGED
|
@@ -60,7 +60,7 @@ class SpriteComponent extends RenderComponent {
|
|
|
60
60
|
__classPrivateFieldSet(this, _SpriteComponent_lastFrameUpdate, now, "f");
|
|
61
61
|
}
|
|
62
62
|
const { img, cols, frameWidth, frameHeight, startCol, endCol, } = this;
|
|
63
|
-
const { position } = this.gameObject;
|
|
63
|
+
const { position, rotation, scale } = this.gameObject;
|
|
64
64
|
ctx.imageSmoothingEnabled = true;
|
|
65
65
|
ctx.imageSmoothingQuality = 'high';
|
|
66
66
|
const maxFrame = endCol - 1;
|
|
@@ -74,13 +74,19 @@ class SpriteComponent extends RenderComponent {
|
|
|
74
74
|
const column = this.currentFrame % cols;
|
|
75
75
|
const row = Math.floor(this.currentFrame / cols);
|
|
76
76
|
ctx.save();
|
|
77
|
+
// Apply world transform
|
|
78
|
+
ctx.translate(position.x, position.y);
|
|
79
|
+
if (rotation !== 0)
|
|
80
|
+
ctx.rotate(rotation);
|
|
81
|
+
ctx.scale(scale.x, scale.y);
|
|
77
82
|
if (this.flip) {
|
|
78
|
-
ctx.translate(
|
|
83
|
+
ctx.translate(frameWidth * 3, 0);
|
|
79
84
|
ctx.scale(-1, 1);
|
|
80
85
|
ctx.drawImage(img, column * frameWidth, row * frameHeight, frameWidth, frameHeight, 0, 0, frameWidth * 3, frameHeight * 3);
|
|
81
86
|
}
|
|
82
87
|
else {
|
|
83
|
-
ctx.drawImage(img, column * frameWidth, row * frameHeight, frameWidth, frameHeight,
|
|
88
|
+
ctx.drawImage(img, column * frameWidth, row * frameHeight, frameWidth, frameHeight, 0, // Drawing at 0,0 relative to transform
|
|
89
|
+
0, frameWidth * 3, frameHeight * 3);
|
|
84
90
|
}
|
|
85
91
|
ctx.restore();
|
|
86
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpriteComponent.js","sourceRoot":"","sources":["../src/SpriteComponent.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,MAAqB,eAAgB,SAAQ,eAAe;IA0B1D,YAAY,GAAqB,EAAE,IAAY,EAAE,IAAY,EAAE,QAAgB,EAAE,MAAc;QAC7F,KAAK,EAAE,CAAC;QAhBV,mDAAmD;QACnD,eAAU,GAAW,CAAC,CAAC;QACvB,oDAAoD;QACpD,gB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AAO,EAAE,CAAC;IAChB,CAAC;CACF;;eA5HoB,eAAe"}
|
package/dist/Text.js
CHANGED
|
@@ -74,7 +74,7 @@ class Text extends GameObject {
|
|
|
74
74
|
const font = `${this.fontSize}px ${defaultedProps.font}`;
|
|
75
75
|
const text = defaultedProps.text;
|
|
76
76
|
this.length = defaultedProps.text.length;
|
|
77
|
-
this.
|
|
77
|
+
this.localPosition = defaultedProps.position;
|
|
78
78
|
const horizontalAlign = defaultedProps.horizontalAlign;
|
|
79
79
|
const verticalAlign = defaultedProps.verticalAlign;
|
|
80
80
|
const width = defaultedProps.width || this.fontSize * this.length;
|
package/dist/Text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","sourceRoot":"","sources":["../src/Text.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,aAAa,MAAM,oBAAoB,CAAC;AA+C/C,MAAM,YAAY,GAAG;IACnB,GAAG,EAAE,MAAM;IACX,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,IAAI,EAAE,KAAK;IACrB,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,EAAE;IACR,eAAe,EAAE,QAAQ;IACzB,aAAa,EAAE,QAAQ;IACvB,QAAQ,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAqB,IAAK,SAAQ,UAAU;IAK1C,wBAAwB;IACxB,IAAI,MAAM,KAAa,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,IAAI,MAAM,CAAC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B,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,YAAY;QACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,KAAK,CAAC,gBAAgB,CAAC,uBAAA,IAAI,0BAAc,CAAC,CAAC;YAC3C,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;IAED,+CAA+C;IAC/C,WAAW;QACT,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,KAAK,CAAC,mBAAmB,CAAC,uBAAA,IAAI,0BAAc,CAAC,CAAC;YAC9C,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAC1B,CAAC;IACH,CAAC;CAcF;kHAZa,GAAY;IACtB,IACE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;QACpC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EACrC,CAAC;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC;eA7HkB,IAAI"}
|
package/dist/TextComponent.js
CHANGED
|
@@ -23,16 +23,22 @@ export default class TextComponent extends RenderComponent {
|
|
|
23
23
|
draw(ctx) {
|
|
24
24
|
if (!this.gameObject)
|
|
25
25
|
return;
|
|
26
|
-
const { position } = this.gameObject;
|
|
26
|
+
const { position, rotation, scale } = this.gameObject;
|
|
27
|
+
ctx.save();
|
|
28
|
+
ctx.translate(position.x, position.y);
|
|
29
|
+
if (rotation !== 0)
|
|
30
|
+
ctx.rotate(rotation);
|
|
31
|
+
ctx.scale(scale.x, scale.y);
|
|
27
32
|
if (this.backgroundColour) {
|
|
28
33
|
ctx.fillStyle = this.backgroundColour;
|
|
29
|
-
ctx.fillRect(
|
|
34
|
+
ctx.fillRect(0, 0, this.width, this.height);
|
|
30
35
|
}
|
|
31
36
|
ctx.font = this.font;
|
|
32
37
|
ctx.fillStyle = this.colour;
|
|
33
38
|
ctx.textAlign = this.horizontalAlign;
|
|
34
39
|
ctx.textBaseline = this.verticalAlign;
|
|
35
|
-
ctx.fillText(this.text,
|
|
40
|
+
ctx.fillText(this.text, this.width / 2, this.height / 2);
|
|
41
|
+
ctx.restore();
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
//# sourceMappingURL=TextComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextComponent.js","sourceRoot":"","sources":["../src/TextComponent.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,eAAe;IAkBxD,YACE,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,eAAgC,EAChC,aAA4B,EAC5B,KAAa,EACb,MAAc,EACd,mBAA2B,EAAE;QAE7B,KAAK,EAAE,CAAC;QAzBV,6BAA6B;QAC7B,qBAAgB,GAAW,EAAE,CAAC;QAyB5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CA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QACtC,IAAI,QAAQ,KAAK,CAAC;YAAE,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC;YACtC,GAAG,CAAC,QAAQ,CACV,CAAC,EACD,CAAC,EACD,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,CACZ,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACrB,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;QAC5B,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,eAAe,CAAC;QACrC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC;QACtC,GAAG,CAAC,QAAQ,CACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,KAAK,GAAG,CAAC,EACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAChB,CAAC;QAEF,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF"}
|
package/dist/Tilemap.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class Tilemap extends GameObject {
|
|
|
24
24
|
this.data = props.data;
|
|
25
25
|
this.tileSize = props.tileSize;
|
|
26
26
|
this.tilesetCols = props.tilesetCols;
|
|
27
|
-
this.
|
|
27
|
+
this.localPosition = props.position;
|
|
28
28
|
this.addComponent(new TilemapComponent(this.tileset, this.data, this.tileSize, this.tilesetCols));
|
|
29
29
|
this.registerSelf();
|
|
30
30
|
}
|
package/dist/Tilemap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tilemap.js","sourceRoot":"","sources":["../src/Tilemap.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MA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AO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC7C,CAAC;IAED,gDAAgD;IAChD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC1C,CAAC;IAED,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAE/B,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACtC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC/B,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC;QAEpC,IAAI,CAAC,YAAY,CAAC,IAAI,gBAAgB,CACpC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,WAAW,CACjB,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;CACF"}
|
package/dist/TilemapComponent.js
CHANGED
|
@@ -17,7 +17,12 @@ export default class TilemapComponent extends RenderComponent {
|
|
|
17
17
|
draw(ctx) {
|
|
18
18
|
if (!this.gameObject)
|
|
19
19
|
return;
|
|
20
|
-
const { position } = this.gameObject;
|
|
20
|
+
const { position, rotation, scale } = this.gameObject;
|
|
21
|
+
ctx.save();
|
|
22
|
+
ctx.translate(position.x, position.y);
|
|
23
|
+
if (rotation !== 0)
|
|
24
|
+
ctx.rotate(rotation);
|
|
25
|
+
ctx.scale(scale.x, scale.y);
|
|
21
26
|
for (let y = 0; y < this.data.length; y++) {
|
|
22
27
|
for (let x = 0; x < this.data[y].length; x++) {
|
|
23
28
|
const tileIndex = this.data[y][x];
|
|
@@ -25,9 +30,11 @@ export default class TilemapComponent extends RenderComponent {
|
|
|
25
30
|
continue; // Empty tile
|
|
26
31
|
const sourceX = (tileIndex % this.tilesetCols) * this.tileSize;
|
|
27
32
|
const sourceY = Math.floor(tileIndex / this.tilesetCols) * this.tileSize;
|
|
28
|
-
ctx.drawImage(this.tileset, sourceX, sourceY, this.tileSize, this.tileSize,
|
|
33
|
+
ctx.drawImage(this.tileset, sourceX, sourceY, this.tileSize, this.tileSize, x * this.tileSize, // Drawn relative to translated context
|
|
34
|
+
y * this.tileSize, this.tileSize, this.tileSize);
|
|
29
35
|
}
|
|
30
36
|
}
|
|
37
|
+
ctx.restore();
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
//# sourceMappingURL=TilemapComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TilemapComponent.js","sourceRoot":"","sources":["../src/TilemapComponent.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,eAAe;IAU3D,YAAY,OAAyB,EAAE,IAAgB,EAAE,QAAgB,EAAE,WAAmB;QAC5F,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,IAAI,CAAC,GAA6B;QAChC,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE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C;gBAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClC,IAAI,SAAS,KAAK,CAAC,CAAC;oBAAE,SAAS,CAAC,aAAa;gBAE7C,MAAM,OAAO,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAC/D,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAEzE,GAAG,CAAC,SAAS,CACX,IAAI,CAAC,OAAO,EACZ,OAAO,EACP,OAAO,EACP,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,uCAAuC;gBAC1D,CAAC,GAAG,IAAI,CAAC,QAAQ,EACjB,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,CACd,CAAC;YACJ,CAAC;QACH,CAAC;QAED,GAAG,CAAC,OAAO,EAAE,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import Component from './Component.js';
|
|
2
2
|
import Vector2 from './Vector2.js';
|
|
3
3
|
/**
|
|
4
|
-
* Component that holds the
|
|
4
|
+
* Component that holds the position, rotation, and scale of an entity.
|
|
5
|
+
* Supports hierarchical transformations (parent-child relationships).
|
|
5
6
|
*/
|
|
6
7
|
export default class TransformComponent extends Component {
|
|
7
|
-
/**
|
|
8
|
+
/** Local position relative to the parent. */
|
|
8
9
|
position: Vector2;
|
|
9
|
-
/**
|
|
10
|
+
/** Local rotation in radians relative to the parent. */
|
|
10
11
|
rotation: number;
|
|
11
|
-
/**
|
|
12
|
+
/** Local scale relative to the parent. */
|
|
12
13
|
scale: Vector2;
|
|
14
|
+
/** Reference to the parent transform. */
|
|
15
|
+
parent?: TransformComponent;
|
|
16
|
+
/** List of children transforms. */
|
|
17
|
+
children: Set<TransformComponent>;
|
|
18
|
+
/**
|
|
19
|
+
* Calculates the world-space position.
|
|
20
|
+
*/
|
|
21
|
+
get worldPosition(): Vector2;
|
|
22
|
+
/**
|
|
23
|
+
* Calculates the world-space rotation.
|
|
24
|
+
*/
|
|
25
|
+
get worldRotation(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Calculates the world-space scale.
|
|
28
|
+
*/
|
|
29
|
+
get worldScale(): Vector2;
|
|
13
30
|
}
|
|
@@ -1,17 +1,62 @@
|
|
|
1
1
|
import Component from './Component.js';
|
|
2
2
|
import Vector2 from './Vector2.js';
|
|
3
3
|
/**
|
|
4
|
-
* Component that holds the
|
|
4
|
+
* Component that holds the position, rotation, and scale of an entity.
|
|
5
|
+
* Supports hierarchical transformations (parent-child relationships).
|
|
5
6
|
*/
|
|
6
7
|
export default class TransformComponent extends Component {
|
|
7
8
|
constructor() {
|
|
8
9
|
super(...arguments);
|
|
9
|
-
/**
|
|
10
|
+
/** Local position relative to the parent. */
|
|
10
11
|
this.position = new Vector2(0, 0);
|
|
11
|
-
/**
|
|
12
|
+
/** Local rotation in radians relative to the parent. */
|
|
12
13
|
this.rotation = 0;
|
|
13
|
-
/**
|
|
14
|
+
/** Local scale relative to the parent. */
|
|
14
15
|
this.scale = new Vector2(1, 1);
|
|
16
|
+
/** List of children transforms. */
|
|
17
|
+
this.children = new Set();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Calculates the world-space position.
|
|
21
|
+
*/
|
|
22
|
+
get worldPosition() {
|
|
23
|
+
if (!this.parent) {
|
|
24
|
+
return new Vector2(this.position.x, this.position.y);
|
|
25
|
+
}
|
|
26
|
+
const parentWorldPos = this.parent.worldPosition;
|
|
27
|
+
const parentWorldRot = this.parent.worldRotation;
|
|
28
|
+
const parentWorldScale = this.parent.worldScale;
|
|
29
|
+
// Apply parent's scale and rotation to local position
|
|
30
|
+
let localX = this.position.x * parentWorldScale.x;
|
|
31
|
+
let localY = this.position.y * parentWorldScale.y;
|
|
32
|
+
if (parentWorldRot !== 0) {
|
|
33
|
+
const cos = Math.cos(parentWorldRot);
|
|
34
|
+
const sin = Math.sin(parentWorldRot);
|
|
35
|
+
const rotatedX = localX * cos - localY * sin;
|
|
36
|
+
const rotatedY = localX * sin + localY * cos;
|
|
37
|
+
localX = rotatedX;
|
|
38
|
+
localY = rotatedY;
|
|
39
|
+
}
|
|
40
|
+
return new Vector2(parentWorldPos.x + localX, parentWorldPos.y + localY);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the world-space rotation.
|
|
44
|
+
*/
|
|
45
|
+
get worldRotation() {
|
|
46
|
+
if (!this.parent) {
|
|
47
|
+
return this.rotation;
|
|
48
|
+
}
|
|
49
|
+
return this.parent.worldRotation + this.rotation;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Calculates the world-space scale.
|
|
53
|
+
*/
|
|
54
|
+
get worldScale() {
|
|
55
|
+
if (!this.parent) {
|
|
56
|
+
return new Vector2(this.scale.x, this.scale.y);
|
|
57
|
+
}
|
|
58
|
+
const parentScale = this.parent.worldScale;
|
|
59
|
+
return new Vector2(parentScale.x * this.scale.x, parentScale.y * this.scale.y);
|
|
15
60
|
}
|
|
16
61
|
}
|
|
17
62
|
//# sourceMappingURL=TransformComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransformComponent.js","sourceRoot":"","sources":["../src/TransformComponent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"TransformComponent.js","sourceRoot":"","sources":["../src/TransformComponent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAmB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C;YAClB,MAAM,GAAG,QAAQ,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,OAAO,CAChB,cAAc,CAAC,CAAC,GAAG,MAAM,EACzB,cAAc,CAAC,CAAC,GAAG,MAAM,CAC1B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAC3C,OAAO,IAAI,OAAO,CAChB,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAC5B,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAC7B,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/Circle.ts
CHANGED
|
@@ -63,7 +63,7 @@ export default class Circle extends GameObject {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
this.tag = defaultedProps.tag;
|
|
66
|
-
this.
|
|
66
|
+
this.localPosition = defaultedProps.position;
|
|
67
67
|
this.radius = defaultedProps.radius;
|
|
68
68
|
this.colour = defaultedProps.colour;
|
|
69
69
|
this.zIndex = defaultedProps.zIndex;
|
package/src/GameObject.ts
CHANGED
|
@@ -92,11 +92,69 @@ export default abstract class GameObject {
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
* The world-space position of the object.
|
|
95
|
-
*
|
|
95
|
+
* Getter returns world position, setter sets local position.
|
|
96
96
|
*/
|
|
97
|
-
get position(): Vector2 { return this._transform.
|
|
97
|
+
get position(): Vector2 { return this._transform.worldPosition; }
|
|
98
98
|
set position(val: Vector2) { this._transform.position = val; }
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* The local position relative to the parent.
|
|
102
|
+
*/
|
|
103
|
+
get localPosition(): Vector2 { return this._transform.position; }
|
|
104
|
+
set localPosition(val: Vector2) { this._transform.position = val; }
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The world-space rotation in radians.
|
|
108
|
+
*/
|
|
109
|
+
get rotation(): number { return this._transform.worldRotation; }
|
|
110
|
+
set rotation(val: number) { this._transform.rotation = val; }
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The local rotation in radians relative to the parent.
|
|
114
|
+
*/
|
|
115
|
+
get localRotation(): number { return this._transform.rotation; }
|
|
116
|
+
set localRotation(val: number) { this._transform.rotation = val; }
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The local scale relative to the parent.
|
|
120
|
+
*/
|
|
121
|
+
get scale(): Vector2 { return this._transform.scale; }
|
|
122
|
+
set scale(val: Vector2) { this._transform.scale = val; }
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Adds a child GameObject to this entity.
|
|
126
|
+
* @param child The child entity to add.
|
|
127
|
+
*/
|
|
128
|
+
addChild(child: GameObject) {
|
|
129
|
+
child._transform.parent = this._transform;
|
|
130
|
+
this._transform.children.add(child._transform);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Removes a child GameObject from this entity.
|
|
135
|
+
* @param child The child entity to remove.
|
|
136
|
+
*/
|
|
137
|
+
removeChild(child: GameObject) {
|
|
138
|
+
if (child._transform.parent === this._transform) {
|
|
139
|
+
child._transform.parent = undefined;
|
|
140
|
+
this._transform.children.delete(child._transform);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Gets or sets the parent GameObject.
|
|
146
|
+
*/
|
|
147
|
+
get parent(): GameObject | undefined {
|
|
148
|
+
return this._transform.parent?.gameObject;
|
|
149
|
+
}
|
|
150
|
+
set parent(val: GameObject | undefined) {
|
|
151
|
+
if (this._transform.parent) {
|
|
152
|
+
this._transform.parent.children.delete(this._transform);
|
|
153
|
+
}
|
|
154
|
+
this._transform.parent = val?._transform;
|
|
155
|
+
val?._transform.children.add(this._transform);
|
|
156
|
+
}
|
|
157
|
+
|
|
100
158
|
/**
|
|
101
159
|
* Current velocity in pixels per second.
|
|
102
160
|
* @deprecated Use getComponent(PhysicsComponent).velocity
|
|
@@ -168,9 +226,9 @@ export default abstract class GameObject {
|
|
|
168
226
|
}
|
|
169
227
|
|
|
170
228
|
/** The width of the object in pixels. */
|
|
171
|
-
|
|
229
|
+
get width(): number { return 0; }
|
|
172
230
|
/** The height of the object in pixels. */
|
|
173
|
-
|
|
231
|
+
get height(): number { return 0; }
|
|
174
232
|
|
|
175
233
|
/**
|
|
176
234
|
* Registers the object with the active scene or global engine loop.
|
package/src/LineComponent.ts
CHANGED
|
@@ -24,11 +24,22 @@ export default class LineComponent extends RenderComponent {
|
|
|
24
24
|
* @param ctx The canvas 2D rendering context.
|
|
25
25
|
*/
|
|
26
26
|
draw(ctx: CanvasRenderingContext2D) {
|
|
27
|
+
if (!this.gameObject) return;
|
|
28
|
+
|
|
29
|
+
const { position, rotation, scale } = this.gameObject;
|
|
30
|
+
|
|
31
|
+
ctx.save();
|
|
32
|
+
ctx.translate(position.x, position.y);
|
|
33
|
+
if (rotation !== 0) ctx.rotate(rotation);
|
|
34
|
+
ctx.scale(scale.x, scale.y);
|
|
35
|
+
|
|
27
36
|
ctx.beginPath();
|
|
28
37
|
ctx.lineWidth = this.strokeWidth;
|
|
29
38
|
ctx.moveTo(this.p1.x, this.p1.y);
|
|
30
39
|
ctx.lineTo(this.p2.x, this.p2.y);
|
|
31
40
|
ctx.stroke();
|
|
32
41
|
ctx.closePath();
|
|
42
|
+
|
|
43
|
+
ctx.restore();
|
|
33
44
|
}
|
|
34
45
|
}
|
package/src/Physics.ts
CHANGED
|
@@ -58,19 +58,19 @@ export default class Physics {
|
|
|
58
58
|
// Push apart
|
|
59
59
|
if (overlapX < overlapY) {
|
|
60
60
|
if (obj1.position.x < obj2.position.x) {
|
|
61
|
-
if (!obj1.isStatic) obj1.
|
|
62
|
-
if (!obj2.isStatic) obj2.
|
|
61
|
+
if (!obj1.isStatic) obj1.localPosition.x -= overlapX / 2;
|
|
62
|
+
if (!obj2.isStatic) obj2.localPosition.x += overlapX / 2;
|
|
63
63
|
} else {
|
|
64
|
-
if (!obj1.isStatic) obj1.
|
|
65
|
-
if (!obj2.isStatic) obj2.
|
|
64
|
+
if (!obj1.isStatic) obj1.localPosition.x += overlapX / 2;
|
|
65
|
+
if (!obj2.isStatic) obj2.localPosition.x -= overlapX / 2;
|
|
66
66
|
}
|
|
67
67
|
} else {
|
|
68
68
|
if (obj1.position.y < obj2.position.y) {
|
|
69
|
-
if (!obj1.isStatic) obj1.
|
|
70
|
-
if (!obj2.isStatic) obj2.
|
|
69
|
+
if (!obj1.isStatic) obj1.localPosition.y -= overlapY / 2;
|
|
70
|
+
if (!obj2.isStatic) obj2.localPosition.y += overlapY / 2;
|
|
71
71
|
} else {
|
|
72
|
-
if (!obj1.isStatic) obj1.
|
|
73
|
-
if (!obj2.isStatic) obj2.
|
|
72
|
+
if (!obj1.isStatic) obj1.localPosition.y += overlapY / 2;
|
|
73
|
+
if (!obj2.isStatic) obj2.localPosition.y -= overlapY / 2;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
}
|
package/src/PhysicsSystem.ts
CHANGED
|
@@ -20,9 +20,9 @@ export default class PhysicsSystem extends System {
|
|
|
20
20
|
physics.velocity.x += physics.acceleration.x * fixedDelta;
|
|
21
21
|
physics.velocity.y += physics.acceleration.y * fixedDelta;
|
|
22
22
|
|
|
23
|
-
// Apply velocity to position
|
|
24
|
-
object.
|
|
25
|
-
object.
|
|
23
|
+
// Apply velocity to local position
|
|
24
|
+
object.localPosition.x += physics.velocity.x * fixedDelta;
|
|
25
|
+
object.localPosition.y += physics.velocity.y * fixedDelta;
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
28
|
}
|
package/src/Rectangle.ts
CHANGED
|
@@ -57,7 +57,7 @@ export default class Rectangle extends GameObject {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
this.tag = defaultedProps.tag;
|
|
60
|
-
this.
|
|
60
|
+
this.localPosition = defaultedProps.position;
|
|
61
61
|
this._width = defaultedProps.width;
|
|
62
62
|
this._height = defaultedProps.height;
|
|
63
63
|
this.colour = defaultedProps.colour;
|
package/src/ShapeComponent.ts
CHANGED
|
@@ -33,18 +33,25 @@ export default class ShapeComponent extends RenderComponent {
|
|
|
33
33
|
draw(ctx: CanvasRenderingContext2D) {
|
|
34
34
|
if (!this.gameObject) return;
|
|
35
35
|
|
|
36
|
-
const { position } = this.gameObject;
|
|
36
|
+
const { position, rotation, scale } = this.gameObject;
|
|
37
|
+
|
|
38
|
+
ctx.save();
|
|
39
|
+
ctx.translate(position.x, position.y);
|
|
40
|
+
if (rotation !== 0) ctx.rotate(rotation);
|
|
41
|
+
ctx.scale(scale.x, scale.y);
|
|
42
|
+
|
|
37
43
|
ctx.fillStyle = this.colour;
|
|
38
44
|
|
|
39
45
|
if (this.type === 'rect') {
|
|
40
|
-
ctx.fillRect(
|
|
46
|
+
ctx.fillRect(0, 0, this.width, this.height);
|
|
41
47
|
} else if (this.type === 'circle') {
|
|
42
48
|
ctx.beginPath();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
ctx.arc(centerX, centerY, this.width, 0, Math.PI * 2);
|
|
49
|
+
// width is radius. In local space center is at (radius, radius)
|
|
50
|
+
ctx.arc(this.width, this.width, this.width, 0, Math.PI * 2);
|
|
46
51
|
ctx.fill();
|
|
47
52
|
ctx.closePath();
|
|
48
53
|
}
|
|
54
|
+
|
|
55
|
+
ctx.restore();
|
|
49
56
|
}
|
|
50
57
|
}
|
package/src/Sprite.ts
CHANGED
package/src/SpriteComponent.ts
CHANGED
|
@@ -72,7 +72,7 @@ export default class SpriteComponent extends RenderComponent {
|
|
|
72
72
|
endCol,
|
|
73
73
|
} = this;
|
|
74
74
|
|
|
75
|
-
const { position } = this.gameObject;
|
|
75
|
+
const { position, rotation, scale } = this.gameObject;
|
|
76
76
|
|
|
77
77
|
ctx.imageSmoothingEnabled = true;
|
|
78
78
|
ctx.imageSmoothingQuality = 'high';
|
|
@@ -92,8 +92,14 @@ export default class SpriteComponent extends RenderComponent {
|
|
|
92
92
|
const row = Math.floor(this.currentFrame / cols);
|
|
93
93
|
|
|
94
94
|
ctx.save();
|
|
95
|
+
|
|
96
|
+
// Apply world transform
|
|
97
|
+
ctx.translate(position.x, position.y);
|
|
98
|
+
if (rotation !== 0) ctx.rotate(rotation);
|
|
99
|
+
ctx.scale(scale.x, scale.y);
|
|
100
|
+
|
|
95
101
|
if (this.flip) {
|
|
96
|
-
ctx.translate(
|
|
102
|
+
ctx.translate(frameWidth * 3, 0);
|
|
97
103
|
ctx.scale(-1, 1);
|
|
98
104
|
ctx.drawImage(
|
|
99
105
|
img,
|
|
@@ -113,8 +119,8 @@ export default class SpriteComponent extends RenderComponent {
|
|
|
113
119
|
row * frameHeight,
|
|
114
120
|
frameWidth,
|
|
115
121
|
frameHeight,
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
0, // Drawing at 0,0 relative to transform
|
|
123
|
+
0,
|
|
118
124
|
frameWidth * 3,
|
|
119
125
|
frameHeight * 3
|
|
120
126
|
);
|
package/src/Text.ts
CHANGED
|
@@ -105,11 +105,11 @@ export default class Text extends GameObject {
|
|
|
105
105
|
set verticalAlign(val: VerticalAlign) { this._textComponent.verticalAlign = val; }
|
|
106
106
|
|
|
107
107
|
/** Width of the background box or interaction area. */
|
|
108
|
-
get width(): number { return this._textComponent.width; }
|
|
108
|
+
override get width(): number { return this._textComponent.width; }
|
|
109
109
|
set width(val: number) { this._textComponent.width = val; }
|
|
110
110
|
|
|
111
111
|
/** Height of the background box or interaction area. */
|
|
112
|
-
get height(): number { return this._textComponent.height; }
|
|
112
|
+
override get height(): number { return this._textComponent.height; }
|
|
113
113
|
set height(val: number) { this._textComponent.height = val; }
|
|
114
114
|
|
|
115
115
|
/** Whether the object should be registered. */
|
|
@@ -132,7 +132,7 @@ export default class Text extends GameObject {
|
|
|
132
132
|
const font = `${this.fontSize}px ${defaultedProps.font}`;
|
|
133
133
|
const text = defaultedProps.text;
|
|
134
134
|
this.length = defaultedProps.text.length;
|
|
135
|
-
this.
|
|
135
|
+
this.localPosition = defaultedProps.position;
|
|
136
136
|
const horizontalAlign = defaultedProps.horizontalAlign;
|
|
137
137
|
const verticalAlign = defaultedProps.verticalAlign;
|
|
138
138
|
const width = defaultedProps.width || this.fontSize * this.length;
|
package/src/TextComponent.ts
CHANGED
|
@@ -50,13 +50,18 @@ export default class TextComponent extends RenderComponent {
|
|
|
50
50
|
draw(ctx: CanvasRenderingContext2D) {
|
|
51
51
|
if (!this.gameObject) return;
|
|
52
52
|
|
|
53
|
-
const { position } = this.gameObject;
|
|
53
|
+
const { position, rotation, scale } = this.gameObject;
|
|
54
|
+
|
|
55
|
+
ctx.save();
|
|
56
|
+
ctx.translate(position.x, position.y);
|
|
57
|
+
if (rotation !== 0) ctx.rotate(rotation);
|
|
58
|
+
ctx.scale(scale.x, scale.y);
|
|
54
59
|
|
|
55
60
|
if (this.backgroundColour) {
|
|
56
61
|
ctx.fillStyle = this.backgroundColour;
|
|
57
62
|
ctx.fillRect(
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
60
65
|
this.width,
|
|
61
66
|
this.height
|
|
62
67
|
);
|
|
@@ -68,8 +73,10 @@ export default class TextComponent extends RenderComponent {
|
|
|
68
73
|
ctx.textBaseline = this.verticalAlign;
|
|
69
74
|
ctx.fillText(
|
|
70
75
|
this.text,
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
this.width / 2,
|
|
77
|
+
this.height / 2
|
|
73
78
|
);
|
|
79
|
+
|
|
80
|
+
ctx.restore();
|
|
74
81
|
}
|
|
75
82
|
}
|
package/src/Tilemap.ts
CHANGED
|
@@ -58,7 +58,7 @@ export default class Tilemap extends GameObject {
|
|
|
58
58
|
this.data = props.data;
|
|
59
59
|
this.tileSize = props.tileSize;
|
|
60
60
|
this.tilesetCols = props.tilesetCols;
|
|
61
|
-
this.
|
|
61
|
+
this.localPosition = props.position;
|
|
62
62
|
|
|
63
63
|
this.addComponent(new TilemapComponent(
|
|
64
64
|
this.tileset,
|
package/src/TilemapComponent.ts
CHANGED
|
@@ -28,7 +28,12 @@ export default class TilemapComponent extends RenderComponent {
|
|
|
28
28
|
draw(ctx: CanvasRenderingContext2D) {
|
|
29
29
|
if (!this.gameObject) return;
|
|
30
30
|
|
|
31
|
-
const { position } = this.gameObject;
|
|
31
|
+
const { position, rotation, scale } = this.gameObject;
|
|
32
|
+
|
|
33
|
+
ctx.save();
|
|
34
|
+
ctx.translate(position.x, position.y);
|
|
35
|
+
if (rotation !== 0) ctx.rotate(rotation);
|
|
36
|
+
ctx.scale(scale.x, scale.y);
|
|
32
37
|
|
|
33
38
|
for (let y = 0; y < this.data.length; y++) {
|
|
34
39
|
for (let x = 0; x < this.data[y].length; x++) {
|
|
@@ -44,12 +49,14 @@ export default class TilemapComponent extends RenderComponent {
|
|
|
44
49
|
sourceY,
|
|
45
50
|
this.tileSize,
|
|
46
51
|
this.tileSize,
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
x * this.tileSize, // Drawn relative to translated context
|
|
53
|
+
y * this.tileSize,
|
|
49
54
|
this.tileSize,
|
|
50
55
|
this.tileSize
|
|
51
56
|
);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
59
|
+
|
|
60
|
+
ctx.restore();
|
|
54
61
|
}
|
|
55
62
|
}
|
|
@@ -2,13 +2,74 @@ import Component from './Component.js';
|
|
|
2
2
|
import Vector2 from './Vector2.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Component that holds the
|
|
5
|
+
* Component that holds the position, rotation, and scale of an entity.
|
|
6
|
+
* Supports hierarchical transformations (parent-child relationships).
|
|
6
7
|
*/
|
|
7
8
|
export default class TransformComponent extends Component {
|
|
8
|
-
/**
|
|
9
|
+
/** Local position relative to the parent. */
|
|
9
10
|
position: Vector2 = new Vector2(0, 0);
|
|
10
|
-
/**
|
|
11
|
+
/** Local rotation in radians relative to the parent. */
|
|
11
12
|
rotation: number = 0;
|
|
12
|
-
/**
|
|
13
|
+
/** Local scale relative to the parent. */
|
|
13
14
|
scale: Vector2 = new Vector2(1, 1);
|
|
15
|
+
|
|
16
|
+
/** Reference to the parent transform. */
|
|
17
|
+
parent?: TransformComponent;
|
|
18
|
+
/** List of children transforms. */
|
|
19
|
+
children: Set<TransformComponent> = new Set();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Calculates the world-space position.
|
|
23
|
+
*/
|
|
24
|
+
get worldPosition(): Vector2 {
|
|
25
|
+
if (!this.parent) {
|
|
26
|
+
return new Vector2(this.position.x, this.position.y);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const parentWorldPos = this.parent.worldPosition;
|
|
30
|
+
const parentWorldRot = this.parent.worldRotation;
|
|
31
|
+
const parentWorldScale = this.parent.worldScale;
|
|
32
|
+
|
|
33
|
+
// Apply parent's scale and rotation to local position
|
|
34
|
+
let localX = this.position.x * parentWorldScale.x;
|
|
35
|
+
let localY = this.position.y * parentWorldScale.y;
|
|
36
|
+
|
|
37
|
+
if (parentWorldRot !== 0) {
|
|
38
|
+
const cos = Math.cos(parentWorldRot);
|
|
39
|
+
const sin = Math.sin(parentWorldRot);
|
|
40
|
+
const rotatedX = localX * cos - localY * sin;
|
|
41
|
+
const rotatedY = localX * sin + localY * cos;
|
|
42
|
+
localX = rotatedX;
|
|
43
|
+
localY = rotatedY;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return new Vector2(
|
|
47
|
+
parentWorldPos.x + localX,
|
|
48
|
+
parentWorldPos.y + localY
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Calculates the world-space rotation.
|
|
54
|
+
*/
|
|
55
|
+
get worldRotation(): number {
|
|
56
|
+
if (!this.parent) {
|
|
57
|
+
return this.rotation;
|
|
58
|
+
}
|
|
59
|
+
return this.parent.worldRotation + this.rotation;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Calculates the world-space scale.
|
|
64
|
+
*/
|
|
65
|
+
get worldScale(): Vector2 {
|
|
66
|
+
if (!this.parent) {
|
|
67
|
+
return new Vector2(this.scale.x, this.scale.y);
|
|
68
|
+
}
|
|
69
|
+
const parentScale = this.parent.worldScale;
|
|
70
|
+
return new Vector2(
|
|
71
|
+
parentScale.x * this.scale.x,
|
|
72
|
+
parentScale.y * this.scale.y
|
|
73
|
+
);
|
|
74
|
+
}
|
|
14
75
|
}
|