frigame3 3.0.0 → 3.0.1
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/Animation.d.ts +42 -0
- package/dist/Animation.js +189 -0
- package/dist/BaseSprite.d.ts +116 -0
- package/dist/BaseSprite.js +518 -0
- package/dist/Gradient.d.ts +31 -0
- package/dist/Gradient.js +89 -0
- package/dist/Playground.d.ts +48 -0
- package/dist/Playground.js +167 -0
- package/dist/Rect.d.ts +63 -0
- package/dist/Rect.js +155 -0
- package/dist/Rectangle.d.ts +31 -0
- package/dist/Rectangle.js +69 -0
- package/dist/Renderer.d.ts +23 -0
- package/dist/Renderer.js +1 -0
- package/dist/ResourceManager.d.ts +21 -0
- package/dist/ResourceManager.js +100 -0
- package/dist/Sprite.d.ts +56 -0
- package/dist/Sprite.js +437 -0
- package/dist/SpriteGroup.d.ts +39 -0
- package/dist/SpriteGroup.js +176 -0
- package/dist/canvasRenderer/renderGroup.d.ts +15 -0
- package/dist/canvasRenderer/renderGroup.js +134 -0
- package/dist/canvasRenderer/renderPlayground.d.ts +9 -0
- package/dist/canvasRenderer/renderPlayground.js +67 -0
- package/dist/canvasRenderer/renderRectangle.d.ts +15 -0
- package/dist/canvasRenderer/renderRectangle.js +287 -0
- package/dist/canvasRenderer/renderSprite.d.ts +4 -0
- package/dist/canvasRenderer/renderSprite.js +93 -0
- package/dist/canvasRenderer.d.ts +2 -0
- package/dist/canvasRenderer.js +19 -0
- package/dist/dummyRenderer.d.ts +2 -0
- package/dist/dummyRenderer.js +41 -0
- package/dist/plugins/GamepadTracker.d.ts +15 -0
- package/dist/plugins/GamepadTracker.js +74 -0
- package/dist/plugins/Tilemap.d.ts +26 -0
- package/dist/plugins/Tilemap.js +85 -0
- package/dist/plugins/Vec2.d.ts +69 -0
- package/dist/plugins/Vec2.js +296 -0
- package/dist/plugins/fx/Shaker.d.ts +46 -0
- package/dist/plugins/fx/Shaker.js +190 -0
- package/dist/plugins/fx/Tweener.d.ts +42 -0
- package/dist/plugins/fx/Tweener.js +166 -0
- package/dist/plugins/fx/easing.d.ts +32 -0
- package/dist/plugins/fx/easing.js +192 -0
- package/dist/plugins/isometric/ISOMixin.d.ts +138 -0
- package/dist/plugins/isometric/ISOMixin.js +322 -0
- package/dist/plugins/isometric/ISORectangle.d.ts +151 -0
- package/dist/plugins/isometric/ISORectangle.js +127 -0
- package/dist/plugins/isometric/ISOSprite.d.ts +157 -0
- package/dist/plugins/isometric/ISOSprite.js +176 -0
- package/dist/plugins/isometric/ISOSpriteGroup.d.ts +151 -0
- package/dist/plugins/isometric/ISOSpriteGroup.js +116 -0
- package/dist/plugins/isometric/ISOTilemap.d.ts +24 -0
- package/dist/plugins/isometric/ISOTilemap.js +85 -0
- package/dist/plugins/isometric/utils.d.ts +2 -0
- package/dist/plugins/isometric/utils.js +10 -0
- package/dist/plugins/keyTracker.d.ts +3 -0
- package/dist/plugins/keyTracker.js +23 -0
- package/dist/plugins/mixer.d.ts +72 -0
- package/dist/plugins/mixer.js +396 -0
- package/dist/plugins/sorted/SortedAnimation.d.ts +13 -0
- package/dist/plugins/sorted/SortedAnimation.js +27 -0
- package/dist/plugins/sorted/SortedGroup.d.ts +137 -0
- package/dist/plugins/sorted/SortedGroup.js +61 -0
- package/dist/plugins/sorted/SortedMixin.d.ts +122 -0
- package/dist/plugins/sorted/SortedMixin.js +153 -0
- package/dist/plugins/sorted/SortedRectangle.d.ts +127 -0
- package/dist/plugins/sorted/SortedRectangle.js +17 -0
- package/dist/plugins/sorted/SortedSprite.d.ts +130 -0
- package/dist/plugins/sorted/SortedSprite.js +35 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +33 -0
- package/package.json +6 -2
- package/CHANGELOG.md +0 -13
- package/biome.json +0 -93
- package/demo/package-lock.json +0 -515
- package/demo/package.json +0 -19
- package/demo/snake/index.html +0 -16
- package/demo/snake/index.ts +0 -110
- package/demo/tetris/index.html +0 -16
- package/demo/tetris/index.ts +0 -536
- package/demo/tsconfig.json +0 -53
- package/src/Animation.ts +0 -266
- package/src/BaseSprite.ts +0 -682
- package/src/Gradient.ts +0 -120
- package/src/Playground.ts +0 -247
- package/src/Rect.ts +0 -237
- package/src/Rectangle.ts +0 -108
- package/src/Renderer.ts +0 -28
- package/src/ResourceManager.ts +0 -145
- package/src/Sprite.ts +0 -484
- package/src/SpriteGroup.ts +0 -258
- package/src/canvasRenderer/renderGroup.ts +0 -194
- package/src/canvasRenderer/renderPlayground.ts +0 -103
- package/src/canvasRenderer/renderRectangle.ts +0 -421
- package/src/canvasRenderer/renderSprite.ts +0 -148
- package/src/canvasRenderer.ts +0 -38
- package/src/dummyRenderer.ts +0 -62
- package/src/plugins/GamepadTracker.ts +0 -97
- package/src/plugins/Tilemap.ts +0 -123
- package/src/plugins/Vec2.ts +0 -420
- package/src/plugins/fx/Shaker.ts +0 -293
- package/src/plugins/fx/Tweener.ts +0 -252
- package/src/plugins/fx/easing.ts +0 -276
- package/src/plugins/isometric/ISOMixin.ts +0 -444
- package/src/plugins/isometric/ISORectangle.ts +0 -183
- package/src/plugins/isometric/ISOSprite.ts +0 -228
- package/src/plugins/isometric/ISOSpriteGroup.ts +0 -155
- package/src/plugins/isometric/ISOTilemap.ts +0 -122
- package/src/plugins/isometric/utils.ts +0 -19
- package/src/plugins/keyTracker.ts +0 -31
- package/src/plugins/mixer.ts +0 -523
- package/src/plugins/sorted/SortedAnimation.ts +0 -53
- package/src/plugins/sorted/SortedGroup.ts +0 -94
- package/src/plugins/sorted/SortedMixin.ts +0 -203
- package/src/plugins/sorted/SortedRectangle.ts +0 -35
- package/src/plugins/sorted/SortedSprite.ts +0 -56
- package/src/utils.ts +0 -53
- package/test/animation/index.html +0 -20
- package/test/animation/index.ts +0 -253
- package/test/animation/mh.png +0 -0
- package/test/animation/moh.png +0 -0
- package/test/animation/mov.png +0 -0
- package/test/animation/mv.png +0 -0
- package/test/animation/rebound.png +0 -0
- package/test/animation/reboundm.png +0 -0
- package/test/animation/sh.png +0 -0
- package/test/animation/soh.png +0 -0
- package/test/animation/sov.png +0 -0
- package/test/animation/sv.png +0 -0
- package/test/isometric1/beach.png +0 -0
- package/test/isometric1/foglie.png +0 -0
- package/test/isometric1/grass.png +0 -0
- package/test/isometric1/index.html +0 -17
- package/test/isometric1/index.ts +0 -68
- package/test/isometric1/tronco.png +0 -0
- package/test/isometric1/untitled.tmx +0 -25
- package/test/isometric1/water.png +0 -0
- package/test/isometric2/banner.png +0 -0
- package/test/isometric2/books.png +0 -0
- package/test/isometric2/candlestick.png +0 -0
- package/test/isometric2/ice.png +0 -0
- package/test/isometric2/index.html +0 -16
- package/test/isometric2/index.ts +0 -129
- package/test/isometric2/knight_se.png +0 -0
- package/test/isometric2/tile.png +0 -0
- package/test/isometric2/untitled.tmx +0 -36
- package/test/isometric2/wall.png +0 -0
- package/test/layers/boy.png +0 -0
- package/test/layers/catgirl.png +0 -0
- package/test/layers/fri1.svg +0 -8
- package/test/layers/grassblock.png +0 -0
- package/test/layers/horngirl.png +0 -0
- package/test/layers/index.html +0 -17
- package/test/layers/index.ts +0 -191
- package/test/layers/pinkgirl.png +0 -0
- package/test/layers/render_ruler.py +0 -57
- package/test/layers/ruler.png +0 -0
- package/test/layers/sh.png +0 -0
- package/test/mixer/dieci.opus +0 -0
- package/test/mixer/dieci.wav +0 -0
- package/test/mixer/index.html +0 -33
- package/test/mixer/index.ts +0 -206
- package/test/mixer/news_intro.mp3 +0 -0
- package/test/mixer/news_intro.ogg +0 -0
- package/test/mixer/prova.mp3 +0 -0
- package/test/mixer/prova.ogg +0 -0
- package/test/package-lock.json +0 -515
- package/test/package.json +0 -19
- package/test/sorted/Brown Block.png +0 -0
- package/test/sorted/index.html +0 -16
- package/test/sorted/index.ts +0 -38
- package/test/transformation1/index.html +0 -17
- package/test/transformation1/index.ts +0 -51
- package/test/transformation1/sh.png +0 -0
- package/test/transformation2/index.html +0 -20
- package/test/transformation2/index.ts +0 -71
- package/test/transformation2/sh.png +0 -0
- package/test/tsconfig.json +0 -53
- package/tsconfig.json +0 -51
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import type { ColorArr, ColorObj, Gradient } from "../../Gradient.js";
|
|
2
|
-
import type { RectSizeX, RectSizeY } from "../../Rect.js";
|
|
3
|
-
import { Rectangle } from "../../Rectangle.js";
|
|
4
|
-
import type { SpriteRef } from "../../utils.js";
|
|
5
|
-
import { pick } from "../../utils.js";
|
|
6
|
-
import type { SortedRectangleOptions } from "../sorted/SortedRectangle.js";
|
|
7
|
-
import { SortedRectangle } from "../sorted/SortedRectangle.js";
|
|
8
|
-
import type { ISOOptions } from "./ISOMixin.js";
|
|
9
|
-
import { ISO } from "./ISOMixin.js";
|
|
10
|
-
import type { ISOSpriteGroup } from "./ISOSpriteGroup.js";
|
|
11
|
-
|
|
12
|
-
export interface ISORectangleOptions
|
|
13
|
-
extends SortedRectangleOptions,
|
|
14
|
-
ISOOptions {}
|
|
15
|
-
|
|
16
|
-
const ISOBaseRectangle = ISO(Rectangle);
|
|
17
|
-
|
|
18
|
-
export class ISORectangle
|
|
19
|
-
extends ISOBaseRectangle
|
|
20
|
-
implements ISORectangleOptions
|
|
21
|
-
{
|
|
22
|
-
override _screen_obj: SortedRectangle | null = null;
|
|
23
|
-
|
|
24
|
-
// Proxy getters & setters
|
|
25
|
-
|
|
26
|
-
override get background(): Gradient | null {
|
|
27
|
-
return super.background;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override set background(value:
|
|
31
|
-
| Gradient
|
|
32
|
-
| Partial<ColorObj>
|
|
33
|
-
| Partial<ColorArr>
|
|
34
|
-
| null) {
|
|
35
|
-
super.background = value;
|
|
36
|
-
|
|
37
|
-
if (this._screen_obj !== null) {
|
|
38
|
-
this._screen_obj.background = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
override get borderRadius(): number {
|
|
43
|
-
return super.borderRadius;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
override set borderRadius(value: number) {
|
|
47
|
-
super.borderRadius = value;
|
|
48
|
-
|
|
49
|
-
if (this._screen_obj !== null) {
|
|
50
|
-
this._screen_obj.borderRadius = value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
override get borderWidth(): number {
|
|
55
|
-
return super.borderWidth;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override set borderWidth(value: number) {
|
|
59
|
-
super.borderWidth = value;
|
|
60
|
-
|
|
61
|
-
if (this._screen_obj !== null) {
|
|
62
|
-
this._screen_obj.borderWidth = value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
override get borderColor(): Gradient | null {
|
|
67
|
-
return super.borderColor;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
override set borderColor(value:
|
|
71
|
-
| Gradient
|
|
72
|
-
| Partial<ColorObj>
|
|
73
|
-
| Partial<ColorArr>
|
|
74
|
-
| null) {
|
|
75
|
-
super.borderColor = value;
|
|
76
|
-
|
|
77
|
-
if (this._screen_obj !== null) {
|
|
78
|
-
this._screen_obj.borderColor = value;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
constructor(
|
|
83
|
-
options?: Partial<ISORectangleOptions> & { ref?: SpriteRef<ISORectangle> },
|
|
84
|
-
) {
|
|
85
|
-
super();
|
|
86
|
-
|
|
87
|
-
if (options !== undefined) {
|
|
88
|
-
Object.assign(
|
|
89
|
-
this,
|
|
90
|
-
pick(options, [
|
|
91
|
-
"left",
|
|
92
|
-
"right",
|
|
93
|
-
"centerx",
|
|
94
|
-
"top",
|
|
95
|
-
"bottom",
|
|
96
|
-
"centery",
|
|
97
|
-
"width",
|
|
98
|
-
"halfWidth",
|
|
99
|
-
"height",
|
|
100
|
-
"halfHeight",
|
|
101
|
-
"radius",
|
|
102
|
-
"transformOrigin",
|
|
103
|
-
"transformOriginx",
|
|
104
|
-
"transformOriginy",
|
|
105
|
-
"angle",
|
|
106
|
-
"scale",
|
|
107
|
-
"scalex",
|
|
108
|
-
"scaley",
|
|
109
|
-
"flip",
|
|
110
|
-
"fliph",
|
|
111
|
-
"flipv",
|
|
112
|
-
"opacity",
|
|
113
|
-
"hidden",
|
|
114
|
-
"blendMode",
|
|
115
|
-
"background",
|
|
116
|
-
"borderRadius",
|
|
117
|
-
"borderWidth",
|
|
118
|
-
"borderColor",
|
|
119
|
-
"originx",
|
|
120
|
-
"originy",
|
|
121
|
-
"referencex",
|
|
122
|
-
"referencey",
|
|
123
|
-
"elevation",
|
|
124
|
-
]),
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
if (options.ref !== undefined) {
|
|
128
|
-
options.ref.current = this;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this._move(null, 0);
|
|
133
|
-
this.teleport();
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Implementation details
|
|
137
|
-
|
|
138
|
-
override _resize(
|
|
139
|
-
prop: keyof RectSizeX | keyof RectSizeY,
|
|
140
|
-
value: number,
|
|
141
|
-
): void {
|
|
142
|
-
// TODO: I'm not sure that proxying the new size is the right approach here,
|
|
143
|
-
// as the screen object is merely a graphical representation of a projection.
|
|
144
|
-
// In theory the size of any ISO should be independent of the size of its
|
|
145
|
-
// screen object.
|
|
146
|
-
super._resize(prop, value);
|
|
147
|
-
|
|
148
|
-
this._screen_obj?._resize(prop, value);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
override _onReparent(): void {
|
|
152
|
-
// The screen rectangle must be created in the screen layer
|
|
153
|
-
const parent = this.parent as ISOSpriteGroup;
|
|
154
|
-
const parent_screen_obj = parent._screen_obj!;
|
|
155
|
-
|
|
156
|
-
// TODO: Is the newly created screen object in the correct drawing order?
|
|
157
|
-
this._screen_obj = parent_screen_obj.addChild(
|
|
158
|
-
new SortedRectangle({
|
|
159
|
-
width: this.width,
|
|
160
|
-
height: this.height,
|
|
161
|
-
transformOriginx: this.transformOriginx,
|
|
162
|
-
transformOriginy: this.transformOriginy,
|
|
163
|
-
angle: this.angle,
|
|
164
|
-
scalex: this.scalex,
|
|
165
|
-
scaley: this.scaley,
|
|
166
|
-
fliph: this.fliph,
|
|
167
|
-
flipv: this.flipv,
|
|
168
|
-
opacity: this.opacity,
|
|
169
|
-
hidden: this.hidden,
|
|
170
|
-
blendMode: this.blendMode,
|
|
171
|
-
background: this.background,
|
|
172
|
-
borderRadius: this.borderRadius,
|
|
173
|
-
borderWidth: this.borderWidth,
|
|
174
|
-
borderColor: this.borderColor,
|
|
175
|
-
originx: this.originx,
|
|
176
|
-
originy: this.originy,
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
this._move("elevation", this.elevation);
|
|
181
|
-
this.teleport();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { Sprite } from "../../Sprite.js";
|
|
2
|
-
import type { SpriteRef } from "../../utils.js";
|
|
3
|
-
import { pick } from "../../utils.js";
|
|
4
|
-
import type { SortedAnimation } from "../sorted/SortedAnimation.js";
|
|
5
|
-
import type { SortedSpriteOptions } from "../sorted/SortedSprite.js";
|
|
6
|
-
import { SortedSprite } from "../sorted/SortedSprite.js";
|
|
7
|
-
import type { ISOOptions } from "./ISOMixin.js";
|
|
8
|
-
import { ISO } from "./ISOMixin.js";
|
|
9
|
-
import type { ISOSpriteGroup } from "./ISOSpriteGroup.js";
|
|
10
|
-
|
|
11
|
-
export interface ISOSpriteOptions extends SortedSpriteOptions, ISOOptions {}
|
|
12
|
-
|
|
13
|
-
const ISOBaseSprite = ISO(Sprite);
|
|
14
|
-
|
|
15
|
-
export class ISOSprite extends ISOBaseSprite implements ISOSpriteOptions {
|
|
16
|
-
override _screen_obj: SortedSprite | null = null;
|
|
17
|
-
|
|
18
|
-
// Proxy getters & setters
|
|
19
|
-
|
|
20
|
-
override get animation(): SortedAnimation | null {
|
|
21
|
-
return super.animation as SortedAnimation | null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
override set animation(value: SortedAnimation | null) {
|
|
25
|
-
if (value !== super.animation) {
|
|
26
|
-
const width = super.width;
|
|
27
|
-
const height = super.height;
|
|
28
|
-
|
|
29
|
-
super.animation = value;
|
|
30
|
-
|
|
31
|
-
super.width = width;
|
|
32
|
-
super.height = height;
|
|
33
|
-
|
|
34
|
-
if (this._screen_obj !== null) {
|
|
35
|
-
this._screen_obj.animation = value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Given that changing the animation changes the originy,
|
|
39
|
-
// we need to update the originy *after* changing the animation
|
|
40
|
-
// on the screen obj
|
|
41
|
-
if (value !== null) {
|
|
42
|
-
this.originx = value.originx;
|
|
43
|
-
this.originy = value.originy;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
override get animationIndex(): number {
|
|
49
|
-
return super.animationIndex;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
override set animationIndex(value: number) {
|
|
53
|
-
super.animationIndex = value;
|
|
54
|
-
|
|
55
|
-
if (this._screen_obj !== null) {
|
|
56
|
-
this._screen_obj.animationIndex = value;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
override get callback(): (() => void) | null {
|
|
61
|
-
return super.callback;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
override set callback(value: (() => void) | null) {
|
|
65
|
-
super.callback = value;
|
|
66
|
-
|
|
67
|
-
if (this._screen_obj !== null) {
|
|
68
|
-
this._screen_obj.callback = value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
override get paused(): boolean {
|
|
73
|
-
return super.paused;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
override set paused(value: boolean) {
|
|
77
|
-
super.paused = value;
|
|
78
|
-
|
|
79
|
-
if (this._screen_obj !== null) {
|
|
80
|
-
this._screen_obj.paused = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
override get rate(): number {
|
|
85
|
-
return super.rate;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
override set rate(value: number) {
|
|
89
|
-
super.rate = value;
|
|
90
|
-
|
|
91
|
-
if (this._screen_obj !== null) {
|
|
92
|
-
this._screen_obj.rate = value;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
override get once(): boolean {
|
|
97
|
-
return super.once;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
override set once(value: boolean) {
|
|
101
|
-
super.once = value;
|
|
102
|
-
|
|
103
|
-
if (this._screen_obj !== null) {
|
|
104
|
-
this._screen_obj.once = value;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
override get pingpong(): boolean {
|
|
109
|
-
return super.pingpong;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
override set pingpong(value: boolean) {
|
|
113
|
-
super.pingpong = value;
|
|
114
|
-
|
|
115
|
-
if (this._screen_obj !== null) {
|
|
116
|
-
this._screen_obj.pingpong = value;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
override get backwards(): boolean {
|
|
121
|
-
return super.backwards;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
override set backwards(value: boolean) {
|
|
125
|
-
super.backwards = value;
|
|
126
|
-
|
|
127
|
-
if (this._screen_obj !== null) {
|
|
128
|
-
this._screen_obj.backwards = value;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
constructor(
|
|
133
|
-
options?: Partial<ISOSpriteOptions> & { ref?: SpriteRef<ISOSprite> },
|
|
134
|
-
) {
|
|
135
|
-
super();
|
|
136
|
-
|
|
137
|
-
if (options !== undefined) {
|
|
138
|
-
Object.assign(
|
|
139
|
-
this,
|
|
140
|
-
pick(options, [
|
|
141
|
-
"left",
|
|
142
|
-
"right",
|
|
143
|
-
"centerx",
|
|
144
|
-
"top",
|
|
145
|
-
"bottom",
|
|
146
|
-
"centery",
|
|
147
|
-
"width",
|
|
148
|
-
"halfWidth",
|
|
149
|
-
"height",
|
|
150
|
-
"halfHeight",
|
|
151
|
-
"radius",
|
|
152
|
-
"transformOrigin",
|
|
153
|
-
"transformOriginx",
|
|
154
|
-
"transformOriginy",
|
|
155
|
-
"angle",
|
|
156
|
-
"scale",
|
|
157
|
-
"scalex",
|
|
158
|
-
"scaley",
|
|
159
|
-
"flip",
|
|
160
|
-
"fliph",
|
|
161
|
-
"flipv",
|
|
162
|
-
"opacity",
|
|
163
|
-
"hidden",
|
|
164
|
-
"blendMode",
|
|
165
|
-
"animation",
|
|
166
|
-
"animationIndex",
|
|
167
|
-
"callback",
|
|
168
|
-
"paused",
|
|
169
|
-
"rate",
|
|
170
|
-
"once",
|
|
171
|
-
"pingpong",
|
|
172
|
-
"backwards",
|
|
173
|
-
"originx",
|
|
174
|
-
"originy",
|
|
175
|
-
"referencex",
|
|
176
|
-
"referencey",
|
|
177
|
-
"elevation",
|
|
178
|
-
]),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
if (options.ref !== undefined) {
|
|
182
|
-
options.ref.current = this;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
this._move(null, 0);
|
|
187
|
-
this.teleport();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// The _resize function has been deliberately omitted,
|
|
191
|
-
// as the screen object automatically gets the size of the animation
|
|
192
|
-
// and the size of the ISOSprite is independent of it
|
|
193
|
-
|
|
194
|
-
override _onReparent(): void {
|
|
195
|
-
// The screen sprite must be created in the screen layer
|
|
196
|
-
const parent = this.parent as ISOSpriteGroup;
|
|
197
|
-
const parent_screen_obj = parent._screen_obj!;
|
|
198
|
-
|
|
199
|
-
// TODO: Is the newly created screen object in the correct drawing order?
|
|
200
|
-
this._screen_obj = parent_screen_obj.addChild(
|
|
201
|
-
new SortedSprite({
|
|
202
|
-
transformOriginx: this.transformOriginx,
|
|
203
|
-
transformOriginy: this.transformOriginy,
|
|
204
|
-
angle: this.angle,
|
|
205
|
-
scalex: this.scalex,
|
|
206
|
-
scaley: this.scaley,
|
|
207
|
-
fliph: this.fliph,
|
|
208
|
-
flipv: this.flipv,
|
|
209
|
-
opacity: this.opacity,
|
|
210
|
-
hidden: this.hidden,
|
|
211
|
-
blendMode: this.blendMode,
|
|
212
|
-
animation: this.animation,
|
|
213
|
-
animationIndex: this.animationIndex,
|
|
214
|
-
callback: this.callback,
|
|
215
|
-
paused: this.paused,
|
|
216
|
-
rate: this.rate,
|
|
217
|
-
once: this.once,
|
|
218
|
-
pingpong: this.pingpong,
|
|
219
|
-
backwards: this.backwards,
|
|
220
|
-
originx: this.originx,
|
|
221
|
-
originy: this.originy,
|
|
222
|
-
}),
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
this._move("elevation", this.elevation);
|
|
226
|
-
this.teleport();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import type { RectSizeX, RectSizeY } from "../../Rect.js";
|
|
2
|
-
import { SpriteGroup } from "../../SpriteGroup.js";
|
|
3
|
-
import type { SpriteRef } from "../../utils.js";
|
|
4
|
-
import { pick } from "../../utils.js";
|
|
5
|
-
import type { SortedGroupOptions } from "../sorted/SortedGroup.js";
|
|
6
|
-
import { SortedGroup } from "../sorted/SortedGroup.js";
|
|
7
|
-
import type { ISOOptions } from "./ISOMixin.js";
|
|
8
|
-
import { ISO } from "./ISOMixin.js";
|
|
9
|
-
|
|
10
|
-
export interface ISOGroupOptions extends SortedGroupOptions, ISOOptions {}
|
|
11
|
-
|
|
12
|
-
const ISOBaseGroup = ISO(SpriteGroup);
|
|
13
|
-
|
|
14
|
-
export class ISOSpriteGroup extends ISOBaseGroup {
|
|
15
|
-
override _originx: keyof RectSizeX | number = 0;
|
|
16
|
-
override _originy: keyof RectSizeY | number = 0;
|
|
17
|
-
override _referencex: keyof RectSizeX | number = 0;
|
|
18
|
-
override _referencey: keyof RectSizeY | number = 0;
|
|
19
|
-
override _screen_obj: SortedGroup | null = null;
|
|
20
|
-
|
|
21
|
-
// Proxy getters & setters
|
|
22
|
-
|
|
23
|
-
override get crop(): boolean {
|
|
24
|
-
return super.crop;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override set crop(value: boolean) {
|
|
28
|
-
super.crop = value;
|
|
29
|
-
|
|
30
|
-
if (this._screen_obj !== null) {
|
|
31
|
-
this._screen_obj.crop = value;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
override get borderRadius(): number {
|
|
36
|
-
return super.borderRadius;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
override set borderRadius(value: number) {
|
|
40
|
-
super.borderRadius = value;
|
|
41
|
-
|
|
42
|
-
if (this._screen_obj !== null) {
|
|
43
|
-
this._screen_obj.borderRadius = value;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
constructor(
|
|
48
|
-
options?: Partial<ISOGroupOptions> & { ref?: SpriteRef<ISOSpriteGroup> },
|
|
49
|
-
) {
|
|
50
|
-
super();
|
|
51
|
-
|
|
52
|
-
if (options !== undefined) {
|
|
53
|
-
Object.assign(
|
|
54
|
-
this,
|
|
55
|
-
pick(options, [
|
|
56
|
-
"left",
|
|
57
|
-
"right",
|
|
58
|
-
"centerx",
|
|
59
|
-
"top",
|
|
60
|
-
"bottom",
|
|
61
|
-
"centery",
|
|
62
|
-
"width",
|
|
63
|
-
"halfWidth",
|
|
64
|
-
"height",
|
|
65
|
-
"halfHeight",
|
|
66
|
-
"radius",
|
|
67
|
-
"transformOrigin",
|
|
68
|
-
"transformOriginx",
|
|
69
|
-
"transformOriginy",
|
|
70
|
-
"angle",
|
|
71
|
-
"scale",
|
|
72
|
-
"scalex",
|
|
73
|
-
"scaley",
|
|
74
|
-
"flip",
|
|
75
|
-
"fliph",
|
|
76
|
-
"flipv",
|
|
77
|
-
"opacity",
|
|
78
|
-
"hidden",
|
|
79
|
-
"blendMode",
|
|
80
|
-
"crop",
|
|
81
|
-
"borderRadius",
|
|
82
|
-
"originx",
|
|
83
|
-
"originy",
|
|
84
|
-
"referencex",
|
|
85
|
-
"referencey",
|
|
86
|
-
"elevation",
|
|
87
|
-
]),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
if (options.children !== undefined) {
|
|
91
|
-
this.addChildren(options.children);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (options.ref !== undefined) {
|
|
95
|
-
options.ref.current = this;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this._move(null, 0);
|
|
100
|
-
this.teleport();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Implementation details
|
|
104
|
-
|
|
105
|
-
override _resize(
|
|
106
|
-
prop: keyof RectSizeX | keyof RectSizeY,
|
|
107
|
-
value: number,
|
|
108
|
-
): void {
|
|
109
|
-
// TODO: I'm not sure that proxying the new size is the right approach here,
|
|
110
|
-
// as the screen object is merely a graphical representation of a projection.
|
|
111
|
-
// In theory the size of any ISO should be independent of the size of its
|
|
112
|
-
// screen object.
|
|
113
|
-
super._resize(prop, value);
|
|
114
|
-
|
|
115
|
-
this._screen_obj?._resize(prop, value);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
override _onReparent(): void {
|
|
119
|
-
// The screen sprite group must be created in the screen layer
|
|
120
|
-
const parent = this.parent!;
|
|
121
|
-
const parent_screen_obj =
|
|
122
|
-
"_screen_obj" in parent ? (parent._screen_obj as SortedGroup) : parent;
|
|
123
|
-
|
|
124
|
-
// TODO: Is the newly created screen object in the correct drawing order?
|
|
125
|
-
this._screen_obj = parent_screen_obj.addChild(
|
|
126
|
-
new SortedGroup({
|
|
127
|
-
width: this.width,
|
|
128
|
-
height: this.height,
|
|
129
|
-
transformOriginx: this.transformOriginx,
|
|
130
|
-
transformOriginy: this.transformOriginy,
|
|
131
|
-
angle: this.angle,
|
|
132
|
-
scalex: this.scalex,
|
|
133
|
-
scaley: this.scaley,
|
|
134
|
-
fliph: this.fliph,
|
|
135
|
-
flipv: this.flipv,
|
|
136
|
-
opacity: this.opacity,
|
|
137
|
-
hidden: this.hidden,
|
|
138
|
-
blendMode: this.blendMode,
|
|
139
|
-
crop: this.crop,
|
|
140
|
-
borderRadius: this.borderRadius,
|
|
141
|
-
originx: this.originx,
|
|
142
|
-
originy: this.originy,
|
|
143
|
-
}),
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
this._move("elevation", this.elevation);
|
|
147
|
-
this.teleport();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
override _remove(): void {
|
|
151
|
-
super._remove();
|
|
152
|
-
|
|
153
|
-
this.clear();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { BaseSprite } from "../../BaseSprite.js";
|
|
2
|
-
import type { SpriteRef } from "../../utils.js";
|
|
3
|
-
import type { ISORectangleOptions } from "./ISORectangle.js";
|
|
4
|
-
import { ISORectangle } from "./ISORectangle.js";
|
|
5
|
-
import type { ISOSpriteOptions } from "./ISOSprite.js";
|
|
6
|
-
import { ISOSprite } from "./ISOSprite.js";
|
|
7
|
-
import type { ISOGroupOptions } from "./ISOSpriteGroup.js";
|
|
8
|
-
import { ISOSpriteGroup } from "./ISOSpriteGroup.js";
|
|
9
|
-
|
|
10
|
-
// animationList MUST have at least `animation` or `background`
|
|
11
|
-
export type ISOTileOptions =
|
|
12
|
-
| (Pick<ISOSpriteOptions, "animation"> & Partial<ISOSpriteOptions>)
|
|
13
|
-
| (Pick<ISORectangleOptions, "background"> & Partial<ISORectangleOptions>);
|
|
14
|
-
|
|
15
|
-
export interface ISOTilemapOptions {
|
|
16
|
-
sizex: number; // Num tiles
|
|
17
|
-
sizey: number; // Num tiles
|
|
18
|
-
tileSize: number; // Pixel
|
|
19
|
-
data: number[]; // (sizex * sizey) members, indices of animationList
|
|
20
|
-
animationList: Record<number, ISOTileOptions>;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class ISOTilemap extends ISOSpriteGroup {
|
|
24
|
-
sizex = 0;
|
|
25
|
-
sizey = 0;
|
|
26
|
-
tileSize = 0;
|
|
27
|
-
|
|
28
|
-
_locations: Uint32Array;
|
|
29
|
-
|
|
30
|
-
constructor(
|
|
31
|
-
options: ISOTilemapOptions &
|
|
32
|
-
Partial<ISOGroupOptions> & { ref?: SpriteRef<ISOTilemap> },
|
|
33
|
-
) {
|
|
34
|
-
super(options);
|
|
35
|
-
|
|
36
|
-
const { sizex, sizey, tileSize } = options;
|
|
37
|
-
|
|
38
|
-
this.sizex = sizex;
|
|
39
|
-
this.sizey = sizey;
|
|
40
|
-
this.tileSize = tileSize;
|
|
41
|
-
|
|
42
|
-
const locations = new Uint32Array(sizex * sizey).fill(0xffffffff);
|
|
43
|
-
this._locations = locations;
|
|
44
|
-
const layers = this._layers;
|
|
45
|
-
|
|
46
|
-
if (
|
|
47
|
-
options.width === undefined &&
|
|
48
|
-
options.halfWidth === undefined &&
|
|
49
|
-
options.radius === undefined
|
|
50
|
-
) {
|
|
51
|
-
this.width = sizex * tileSize;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
options.height === undefined &&
|
|
56
|
-
options.halfHeight === undefined &&
|
|
57
|
-
options.radius === undefined
|
|
58
|
-
) {
|
|
59
|
-
this.height = sizey * tileSize;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const animationList = options.animationList;
|
|
63
|
-
|
|
64
|
-
let i_location = 0;
|
|
65
|
-
let row = 0;
|
|
66
|
-
let col = 0;
|
|
67
|
-
let left = 0;
|
|
68
|
-
let top = 0;
|
|
69
|
-
for (const data of options.data) {
|
|
70
|
-
const animation_options = animationList[data];
|
|
71
|
-
if (animation_options !== undefined && "animation" in animation_options) {
|
|
72
|
-
// Sprite
|
|
73
|
-
const sprite_options = Object.assign({}, animation_options, {
|
|
74
|
-
left,
|
|
75
|
-
top,
|
|
76
|
-
width: tileSize,
|
|
77
|
-
height: tileSize,
|
|
78
|
-
});
|
|
79
|
-
this.addChild(new ISOSprite(sprite_options));
|
|
80
|
-
locations[i_location] = layers.length - 1;
|
|
81
|
-
} else if (
|
|
82
|
-
animation_options !== undefined &&
|
|
83
|
-
"background" in animation_options
|
|
84
|
-
) {
|
|
85
|
-
// Rectangle
|
|
86
|
-
const rectangle_options = Object.assign({}, animation_options, {
|
|
87
|
-
left,
|
|
88
|
-
top,
|
|
89
|
-
width: tileSize,
|
|
90
|
-
height: tileSize,
|
|
91
|
-
});
|
|
92
|
-
this.addChild(new ISORectangle(rectangle_options));
|
|
93
|
-
locations[i_location] = layers.length - 1;
|
|
94
|
-
} else {
|
|
95
|
-
// TODO: Invalid
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
i_location += 1;
|
|
99
|
-
left += tileSize;
|
|
100
|
-
col += 1;
|
|
101
|
-
if (col >= sizex) {
|
|
102
|
-
col = 0;
|
|
103
|
-
left = 0;
|
|
104
|
-
row += 1;
|
|
105
|
-
top += tileSize;
|
|
106
|
-
if (row >= sizey) {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getAt(row: number, col: number): BaseSprite | undefined {
|
|
114
|
-
const i = row * this.sizex + col;
|
|
115
|
-
|
|
116
|
-
if (i < this._locations.length) {
|
|
117
|
-
return this._layers[this._locations[i]!];
|
|
118
|
-
} else {
|
|
119
|
-
return undefined;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function screenFromGrid(
|
|
2
|
-
grid_x: number,
|
|
3
|
-
grid_y: number,
|
|
4
|
-
): [screen_x: number, screen_y: number] {
|
|
5
|
-
const screen_x = grid_x - grid_y;
|
|
6
|
-
const screen_y = (grid_x + grid_y) / 2;
|
|
7
|
-
|
|
8
|
-
return [screen_x, screen_y];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function gridFromScreen(
|
|
12
|
-
screen_x: number,
|
|
13
|
-
screen_y: number,
|
|
14
|
-
): [grid_x: number, grid_y: number] {
|
|
15
|
-
const grid_x = screen_y + screen_x / 2;
|
|
16
|
-
const grid_y = screen_y - screen_x / 2;
|
|
17
|
-
|
|
18
|
-
return [grid_x, grid_y];
|
|
19
|
-
}
|