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,203 +0,0 @@
|
|
|
1
|
-
import type { BaseSprite } from "../../BaseSprite.js";
|
|
2
|
-
import type { RectSizeX, RectSizeY } from "../../Rect.js";
|
|
3
|
-
import type { GConstructor } from "../../utils.js";
|
|
4
|
-
import { SortedGroup } from "./SortedGroup.js";
|
|
5
|
-
|
|
6
|
-
export interface SortedOptions {
|
|
7
|
-
originx: keyof RectSizeX | number;
|
|
8
|
-
originy: keyof RectSizeY | number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// biome-ignore lint/nursery/useExplicitReturnType: reason
|
|
12
|
-
export function Sorted<TBase extends GConstructor<BaseSprite>>(Base: TBase) {
|
|
13
|
-
return class SortedMixin extends Base {
|
|
14
|
-
_originx: keyof RectSizeX | number = "halfWidth";
|
|
15
|
-
_originy: keyof RectSizeY | number = "height";
|
|
16
|
-
_sort_y = 0;
|
|
17
|
-
|
|
18
|
-
get originx(): keyof RectSizeX | number {
|
|
19
|
-
return this._originx;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
set originx(value: keyof RectSizeX | number) {
|
|
23
|
-
this._originx = value;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
get originy(): keyof RectSizeY | number {
|
|
27
|
-
return this._originy;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
set originy(value: keyof RectSizeY | number) {
|
|
31
|
-
if (value !== this._originy) {
|
|
32
|
-
const parent = this.parent;
|
|
33
|
-
if (parent instanceof SortedGroup) {
|
|
34
|
-
parent._needsSorting = true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
this._originy = value;
|
|
38
|
-
this._sort_y = this._calcSortY();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
override get top(): number {
|
|
43
|
-
return super.top;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
override set top(value: number) {
|
|
47
|
-
if (value !== super.top) {
|
|
48
|
-
const parent = this.parent;
|
|
49
|
-
if (parent instanceof SortedGroup) {
|
|
50
|
-
parent._needsSorting = true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
super.top = value;
|
|
54
|
-
this._sort_y = this._calcSortY();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override get bottom(): number {
|
|
59
|
-
return super.bottom;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
override set bottom(value: number) {
|
|
63
|
-
if (value !== super.bottom) {
|
|
64
|
-
const parent = this.parent;
|
|
65
|
-
if (parent instanceof SortedGroup) {
|
|
66
|
-
parent._needsSorting = true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
super.bottom = value;
|
|
70
|
-
this._sort_y = this._calcSortY();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
override get centery(): number {
|
|
75
|
-
return super.centery;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
override set centery(value: number) {
|
|
79
|
-
if (value !== super.centery) {
|
|
80
|
-
const parent = this.parent;
|
|
81
|
-
if (parent instanceof SortedGroup) {
|
|
82
|
-
parent._needsSorting = true;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
super.centery = value;
|
|
86
|
-
this._sort_y = this._calcSortY();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
override get height(): number {
|
|
91
|
-
return super.height;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
override set height(value: number) {
|
|
95
|
-
if (value !== super.height) {
|
|
96
|
-
const parent = this.parent;
|
|
97
|
-
if (parent instanceof SortedGroup) {
|
|
98
|
-
parent._needsSorting = true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
super.height = value;
|
|
102
|
-
this._sort_y = this._calcSortY();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
override get halfHeight(): number {
|
|
107
|
-
return super.halfHeight;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
override set halfHeight(value: number) {
|
|
111
|
-
if (value !== super.halfHeight) {
|
|
112
|
-
const parent = this.parent;
|
|
113
|
-
if (parent instanceof SortedGroup) {
|
|
114
|
-
parent._needsSorting = true;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
super.halfHeight = value;
|
|
118
|
-
this._sort_y = this._calcSortY();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
override get radius(): number {
|
|
123
|
-
return super.radius;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
override set radius(value: number) {
|
|
127
|
-
if (value !== super.halfWidth || value !== super.halfHeight) {
|
|
128
|
-
const parent = this.parent;
|
|
129
|
-
if (parent instanceof SortedGroup) {
|
|
130
|
-
parent._needsSorting = true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
super.radius = value;
|
|
134
|
-
this._sort_y = this._calcSortY();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
override drawFirst(): this {
|
|
139
|
-
super.drawFirst();
|
|
140
|
-
|
|
141
|
-
const parent = this.parent;
|
|
142
|
-
if (parent instanceof SortedGroup) {
|
|
143
|
-
parent._needsSorting = true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
override drawLast(): this {
|
|
150
|
-
super.drawLast();
|
|
151
|
-
|
|
152
|
-
const parent = this.parent;
|
|
153
|
-
if (parent instanceof SortedGroup) {
|
|
154
|
-
parent._needsSorting = true;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return this;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
override drawTo(index: number): this {
|
|
161
|
-
super.drawTo(index);
|
|
162
|
-
|
|
163
|
-
const parent = this.parent;
|
|
164
|
-
if (parent instanceof SortedGroup) {
|
|
165
|
-
parent._needsSorting = true;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
override drawBefore(sprite: BaseSprite): this {
|
|
172
|
-
super.drawBefore(sprite);
|
|
173
|
-
|
|
174
|
-
const parent = this.parent;
|
|
175
|
-
if (parent instanceof SortedGroup) {
|
|
176
|
-
parent._needsSorting = true;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
override drawAfter(sprite: BaseSprite): this {
|
|
183
|
-
super.drawAfter(sprite);
|
|
184
|
-
|
|
185
|
-
const parent = this.parent;
|
|
186
|
-
if (parent instanceof SortedGroup) {
|
|
187
|
-
parent._needsSorting = true;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
_calcSortY(): number {
|
|
194
|
-
let originy = this._originy;
|
|
195
|
-
|
|
196
|
-
if (typeof originy === "string") {
|
|
197
|
-
originy = this[originy];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return this.top + originy;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { RectangleOptions } from "../../Rectangle.js";
|
|
2
|
-
import { Rectangle } from "../../Rectangle.js";
|
|
3
|
-
import type { SpriteRef } from "../../utils.js";
|
|
4
|
-
import type { SortedOptions } from "./SortedMixin.js";
|
|
5
|
-
import { Sorted } from "./SortedMixin.js";
|
|
6
|
-
|
|
7
|
-
export interface SortedRectangleOptions
|
|
8
|
-
extends RectangleOptions,
|
|
9
|
-
SortedOptions {}
|
|
10
|
-
|
|
11
|
-
const SortedBaseRectangle = Sorted(Rectangle);
|
|
12
|
-
|
|
13
|
-
export class SortedRectangle
|
|
14
|
-
extends SortedBaseRectangle
|
|
15
|
-
implements SortedRectangleOptions
|
|
16
|
-
{
|
|
17
|
-
constructor(
|
|
18
|
-
options?: Partial<SortedRectangleOptions> & {
|
|
19
|
-
ref?: SpriteRef<SortedRectangle>;
|
|
20
|
-
},
|
|
21
|
-
) {
|
|
22
|
-
super(options);
|
|
23
|
-
|
|
24
|
-
if (options !== undefined) {
|
|
25
|
-
if (options.originx !== undefined) {
|
|
26
|
-
this.originx = options.originx;
|
|
27
|
-
}
|
|
28
|
-
if (options.originy !== undefined) {
|
|
29
|
-
this.originy = options.originy;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this._sort_y = this._calcSortY();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { SpriteOptions } from "../../Sprite.js";
|
|
2
|
-
import { Sprite } from "../../Sprite.js";
|
|
3
|
-
import type { SpriteRef } from "../../utils.js";
|
|
4
|
-
import type { SortedAnimation } from "./SortedAnimation.js";
|
|
5
|
-
import { SortedGroup } from "./SortedGroup.js";
|
|
6
|
-
import type { SortedOptions } from "./SortedMixin.js";
|
|
7
|
-
import { Sorted } from "./SortedMixin.js";
|
|
8
|
-
|
|
9
|
-
export interface SortedSpriteOptions extends SpriteOptions, SortedOptions {}
|
|
10
|
-
|
|
11
|
-
const SortedBaseSprite = Sorted(Sprite);
|
|
12
|
-
|
|
13
|
-
export class SortedSprite
|
|
14
|
-
extends SortedBaseSprite
|
|
15
|
-
implements SortedSpriteOptions
|
|
16
|
-
{
|
|
17
|
-
override get animation(): SortedAnimation | null {
|
|
18
|
-
return super.animation as SortedAnimation | null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
override set animation(value: SortedAnimation | null) {
|
|
22
|
-
if (value !== super.animation) {
|
|
23
|
-
const parent = this.parent;
|
|
24
|
-
|
|
25
|
-
if (parent instanceof SortedGroup) {
|
|
26
|
-
parent._needsSorting = true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
super.animation = value;
|
|
30
|
-
|
|
31
|
-
if (value !== null) {
|
|
32
|
-
this._originx = value.originx;
|
|
33
|
-
this._originy = value.originy;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
this._sort_y = this._calcSortY();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
constructor(
|
|
41
|
-
options?: Partial<SortedSpriteOptions> & { ref?: SpriteRef<SortedSprite> },
|
|
42
|
-
) {
|
|
43
|
-
super(options);
|
|
44
|
-
|
|
45
|
-
if (options !== undefined) {
|
|
46
|
-
if (options.originx !== undefined) {
|
|
47
|
-
this.originx = options.originx;
|
|
48
|
-
}
|
|
49
|
-
if (options.originy !== undefined) {
|
|
50
|
-
this.originy = options.originy;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this._sort_y = this._calcSortY();
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// biome-ignore lint/suspicious/noExplicitAny: reason
|
|
2
|
-
export type GConstructor<T extends object> = new (...args: any[]) => T;
|
|
3
|
-
|
|
4
|
-
export function noop(): void {
|
|
5
|
-
// no-op
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function isEmptyObject<T extends object>(obj: T): boolean {
|
|
9
|
-
for (const _name in obj) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Return a new object with only the keys defined in the keys array parameter
|
|
17
|
-
export function pick<T extends object, U extends keyof T>(
|
|
18
|
-
obj: T,
|
|
19
|
-
keys: readonly U[],
|
|
20
|
-
): Partial<Pick<T, U>> {
|
|
21
|
-
const result: Partial<Pick<T, U>> = {};
|
|
22
|
-
|
|
23
|
-
for (const key of keys) {
|
|
24
|
-
const val = obj[key];
|
|
25
|
-
|
|
26
|
-
if (val !== undefined) {
|
|
27
|
-
result[key] = val;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function clamp(n: number, minVal: number, maxVal: number): number {
|
|
35
|
-
return Math.min(Math.max(n, minVal), maxVal);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function mod(n: number, m: number): number {
|
|
39
|
-
return ((n % m) + m) % m;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// t = (x - x0) / (x1 - x0)
|
|
43
|
-
export function lerp(y0: number, y1: number, t: number): number {
|
|
44
|
-
return y0 + t * (y1 - y0);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface SpriteRef<T> {
|
|
48
|
-
current?: T;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function spriteRef<T>(): SpriteRef<T> {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
|
|
6
|
-
<link rel="stylesheet" type="text/css" href="../../frigame.css">
|
|
7
|
-
</head>
|
|
8
|
-
<body style="position: relative;">
|
|
9
|
-
<h2>
|
|
10
|
-
All of the following sprites should look the same, without any red
|
|
11
|
-
visible:
|
|
12
|
-
</h2>
|
|
13
|
-
<div
|
|
14
|
-
id="playground"
|
|
15
|
-
style="position: relative; width: 542px; height: 64px; background: white;"
|
|
16
|
-
></div>
|
|
17
|
-
|
|
18
|
-
<script src="bundle.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
package/test/animation/index.ts
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { Animation } from "frigame3/dist/Animation.js";
|
|
2
|
-
import { canvasRenderer } from "frigame3/dist/canvasRenderer.js";
|
|
3
|
-
import { Playground } from "frigame3/dist/Playground.js";
|
|
4
|
-
import { ResourceManager } from "frigame3/dist/ResourceManager.js";
|
|
5
|
-
import { Sprite } from "frigame3/dist/Sprite.js";
|
|
6
|
-
|
|
7
|
-
void (async (): Promise<void> => {
|
|
8
|
-
const rm = new ResourceManager();
|
|
9
|
-
|
|
10
|
-
const simpleVerticalAnimation = rm.addResource(
|
|
11
|
-
new Animation({
|
|
12
|
-
imageURL: "sv.png",
|
|
13
|
-
type: "vertical",
|
|
14
|
-
numberOfFrame: 4,
|
|
15
|
-
rate: 300,
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const simpleHorizontalAnimation = rm.addResource(
|
|
20
|
-
new Animation({
|
|
21
|
-
imageURL: "sh.png",
|
|
22
|
-
type: "horizontal",
|
|
23
|
-
numberOfFrame: 4,
|
|
24
|
-
rate: 300,
|
|
25
|
-
}),
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const multiVerticalAnimation = rm.addResource(
|
|
29
|
-
new Animation({
|
|
30
|
-
imageURL: "mv.png",
|
|
31
|
-
type: "vertical",
|
|
32
|
-
numberOfFrame: 4,
|
|
33
|
-
rate: 300,
|
|
34
|
-
frameWidth: 32,
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const multiHorizontalAnimation = rm.addResource(
|
|
39
|
-
new Animation({
|
|
40
|
-
imageURL: "mh.png",
|
|
41
|
-
type: "horizontal",
|
|
42
|
-
numberOfFrame: 4,
|
|
43
|
-
rate: 300,
|
|
44
|
-
frameHeight: 32,
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const simpleOffsetVerticalAnimation = rm.addResource(
|
|
49
|
-
new Animation({
|
|
50
|
-
imageURL: "sov.png",
|
|
51
|
-
type: "vertical",
|
|
52
|
-
numberOfFrame: 4,
|
|
53
|
-
rate: 300,
|
|
54
|
-
offsetx: 100,
|
|
55
|
-
offsety: 100,
|
|
56
|
-
}),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const simpleOffsetHorizontalAnimation = rm.addResource(
|
|
60
|
-
new Animation({
|
|
61
|
-
imageURL: "soh.png",
|
|
62
|
-
type: "horizontal",
|
|
63
|
-
numberOfFrame: 4,
|
|
64
|
-
rate: 300,
|
|
65
|
-
offsetx: 100,
|
|
66
|
-
offsety: 100,
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const multiOffsetVerticalAnimation = rm.addResource(
|
|
71
|
-
new Animation({
|
|
72
|
-
imageURL: "mov.png",
|
|
73
|
-
type: "vertical",
|
|
74
|
-
numberOfFrame: 4,
|
|
75
|
-
rate: 300,
|
|
76
|
-
offsetx: 100,
|
|
77
|
-
offsety: 100,
|
|
78
|
-
frameWidth: 32,
|
|
79
|
-
}),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const multiOffsetHorizontalAnimation = rm.addResource(
|
|
83
|
-
new Animation({
|
|
84
|
-
imageURL: "moh.png",
|
|
85
|
-
type: "horizontal",
|
|
86
|
-
numberOfFrame: 4,
|
|
87
|
-
rate: 300,
|
|
88
|
-
offsetx: 100,
|
|
89
|
-
offsety: 100,
|
|
90
|
-
frameHeight: 32,
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const pingpongAnimation = rm.addResource(
|
|
95
|
-
new Animation({
|
|
96
|
-
imageURL: "rebound.png",
|
|
97
|
-
type: "horizontal",
|
|
98
|
-
once: true,
|
|
99
|
-
pingpong: true,
|
|
100
|
-
numberOfFrame: 9,
|
|
101
|
-
//rate: 60
|
|
102
|
-
rate: 600,
|
|
103
|
-
}),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
const multiPingpongAnimation = rm.addResource(
|
|
107
|
-
new Animation({
|
|
108
|
-
imageURL: "reboundm.png",
|
|
109
|
-
type: "horizontal",
|
|
110
|
-
pingpong: true,
|
|
111
|
-
numberOfFrame: 9,
|
|
112
|
-
rate: 60,
|
|
113
|
-
frameHeight: 64,
|
|
114
|
-
}),
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const pingpongBackwardsAnimation = rm.addResource(
|
|
118
|
-
new Animation({
|
|
119
|
-
imageURL: "rebound.png",
|
|
120
|
-
type: "horizontal",
|
|
121
|
-
once: true,
|
|
122
|
-
pingpong: true,
|
|
123
|
-
backwards: true,
|
|
124
|
-
numberOfFrame: 9,
|
|
125
|
-
//rate: 60
|
|
126
|
-
rate: 600,
|
|
127
|
-
}),
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const multiPingpongBackwardsAnimation = rm.addResource(
|
|
131
|
-
new Animation({
|
|
132
|
-
imageURL: "reboundm.png",
|
|
133
|
-
type: "horizontal",
|
|
134
|
-
pingpong: true,
|
|
135
|
-
backwards: true,
|
|
136
|
-
numberOfFrame: 9,
|
|
137
|
-
rate: 60,
|
|
138
|
-
frameHeight: 64,
|
|
139
|
-
}),
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
await rm.preload();
|
|
143
|
-
|
|
144
|
-
const playground = new Playground(canvasRenderer);
|
|
145
|
-
const sg = playground.scenegraph;
|
|
146
|
-
|
|
147
|
-
// simpleVertical
|
|
148
|
-
sg.addChild(
|
|
149
|
-
new Sprite({
|
|
150
|
-
animation: simpleVerticalAnimation,
|
|
151
|
-
left: 0,
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
// simpleHorizontal
|
|
156
|
-
sg.addChild(
|
|
157
|
-
new Sprite({
|
|
158
|
-
animation: simpleHorizontalAnimation,
|
|
159
|
-
backwards: true,
|
|
160
|
-
left: 34,
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
|
-
const multiVertical = sg.addChild(
|
|
164
|
-
new Sprite({
|
|
165
|
-
animation: multiVerticalAnimation,
|
|
166
|
-
left: 75,
|
|
167
|
-
}),
|
|
168
|
-
);
|
|
169
|
-
const multiHorizontal = sg.addChild(
|
|
170
|
-
new Sprite({
|
|
171
|
-
animation: multiHorizontalAnimation,
|
|
172
|
-
left: 109,
|
|
173
|
-
}),
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
// simpleOffsetVertical
|
|
177
|
-
sg.addChild(
|
|
178
|
-
new Sprite({
|
|
179
|
-
animation: simpleOffsetVerticalAnimation,
|
|
180
|
-
left: 150,
|
|
181
|
-
}),
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
// simpleOffsetHorizontal
|
|
185
|
-
sg.addChild(
|
|
186
|
-
new Sprite({
|
|
187
|
-
animation: simpleOffsetHorizontalAnimation,
|
|
188
|
-
left: 184,
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
// multiOffsetVertical
|
|
193
|
-
sg.addChild(
|
|
194
|
-
new Sprite({
|
|
195
|
-
animation: multiOffsetVerticalAnimation,
|
|
196
|
-
animationIndex: 1,
|
|
197
|
-
left: 225,
|
|
198
|
-
}),
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
// multiOffsetHorizontal
|
|
202
|
-
sg.addChild(
|
|
203
|
-
new Sprite({
|
|
204
|
-
animation: multiOffsetHorizontalAnimation,
|
|
205
|
-
animationIndex: 1,
|
|
206
|
-
left: 259,
|
|
207
|
-
}),
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
const pingpong = sg.addChild(
|
|
211
|
-
new Sprite({
|
|
212
|
-
animation: pingpongAnimation,
|
|
213
|
-
left: 286,
|
|
214
|
-
}),
|
|
215
|
-
);
|
|
216
|
-
const multiPingpong = sg.addChild(
|
|
217
|
-
new Sprite({
|
|
218
|
-
animation: multiPingpongAnimation,
|
|
219
|
-
left: 350,
|
|
220
|
-
}),
|
|
221
|
-
);
|
|
222
|
-
const backPingpong = sg.addChild(
|
|
223
|
-
new Sprite({
|
|
224
|
-
animation: pingpongBackwardsAnimation,
|
|
225
|
-
left: 414,
|
|
226
|
-
}),
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
// multiBackPingpong
|
|
230
|
-
sg.addChild(
|
|
231
|
-
new Sprite({
|
|
232
|
-
animation: multiPingpongBackwardsAnimation,
|
|
233
|
-
animationIndex: 1,
|
|
234
|
-
left: 478,
|
|
235
|
-
}),
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
multiVertical.animationIndex = 1;
|
|
239
|
-
multiHorizontal.animationIndex = 1;
|
|
240
|
-
multiPingpong.animationIndex = 1;
|
|
241
|
-
pingpong.callback = (): void => {
|
|
242
|
-
const p = document.createElement("p");
|
|
243
|
-
p.innerHTML = "Forwards Done";
|
|
244
|
-
Object.assign(p.style, { position: "absolute", top: "64px" });
|
|
245
|
-
document.getElementById("playground")!.append(p);
|
|
246
|
-
};
|
|
247
|
-
backPingpong.callback = (): void => {
|
|
248
|
-
const p = document.createElement("p");
|
|
249
|
-
p.innerHTML = "Backwards Done";
|
|
250
|
-
Object.assign(p.style, { position: "absolute", top: "88px" });
|
|
251
|
-
document.getElementById("playground")!.append(p);
|
|
252
|
-
};
|
|
253
|
-
})();
|
package/test/animation/mh.png
DELETED
|
Binary file
|
package/test/animation/moh.png
DELETED
|
Binary file
|
package/test/animation/mov.png
DELETED
|
Binary file
|
package/test/animation/mv.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/animation/sh.png
DELETED
|
Binary file
|
package/test/animation/soh.png
DELETED
|
Binary file
|
package/test/animation/sov.png
DELETED
|
Binary file
|
package/test/animation/sv.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
|
|
6
|
-
<link rel="stylesheet" type="text/css" href="../../frigame.css">
|
|
7
|
-
</head>
|
|
8
|
-
<body style="position: relative;">
|
|
9
|
-
<h2>Tile Engine Test:</h2>
|
|
10
|
-
<div
|
|
11
|
-
id="playground"
|
|
12
|
-
style="position: relative; width: 960px; height: 576px; background: #ff00ff;"
|
|
13
|
-
></div>
|
|
14
|
-
|
|
15
|
-
<script src="bundle.js"></script>
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|