angry-pixel 2.3.2 → 2.3.4

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/lib/index.d.ts CHANGED
@@ -3170,6 +3170,13 @@ interface RigidBodyOptions {
3170
3170
  * @public
3171
3171
  */
3172
3172
  acceleration: Vector2;
3173
+ /**
3174
+ * Collision layers for which this body behaves as static. When a Dynamic body whose collider layer
3175
+ * is listed here collides with this body, only the other body is repositioned, as if this one were static.
3176
+ * This body still behaves as its own type (e.g. Dynamic) for every other collision.
3177
+ * @public
3178
+ */
3179
+ staticForLayers: string[];
3173
3180
  }
3174
3181
  /**
3175
3182
  * The RigidBody component enables physics simulation for an entity, allowing it to interact with other physics-enabled objects in the game world.\
@@ -3235,6 +3242,13 @@ declare class RigidBody {
3235
3242
  * @public
3236
3243
  */
3237
3244
  acceleration: Vector2;
3245
+ /**
3246
+ * Collision layers for which this body behaves as static. When a Dynamic body whose collider layer
3247
+ * is listed here collides with this body, only the other body is repositioned, as if this one were static.
3248
+ * This body still behaves as its own type (e.g. Dynamic) for every other collision.
3249
+ * @public
3250
+ */
3251
+ staticForLayers: string[];
3238
3252
  /** @internal */
3239
3253
  static componentName: string;
3240
3254
  constructor(options?: Partial<RigidBodyOptions>);
@@ -3488,12 +3502,30 @@ interface TilemapRenderData extends RenderData {
3488
3502
  }
3489
3503
  type Tileset$1 = {
3490
3504
  image: HTMLImageElement;
3491
- width: number;
3492
3505
  tileWidth: number;
3493
3506
  tileHeight: number;
3494
- margin?: Vector2;
3495
- spacing?: Vector2;
3496
- correction?: Vector2;
3507
+ /** Space in pixels between the tiles and the four edges of the image */
3508
+ margin?: number;
3509
+ /** Space in pixels between adjacent tiles */
3510
+ spacing?: number;
3511
+ /** Maps each animated tile id to the tile id currently displayed. @internal */
3512
+ _animationState?: Map<number, number>;
3513
+ /** Tileset values in texture coordinates. Computed once by the renderer. @internal */
3514
+ _texData?: TilesetTexData;
3515
+ };
3516
+ /**
3517
+ * Tileset values expressed in texture coordinates (0 to 1), plus the number of columns of the tileset.
3518
+ * @internal
3519
+ */
3520
+ type TilesetTexData = {
3521
+ /** The width of the tileset (in tiles) */
3522
+ columns: number;
3523
+ /** The margin of the image */
3524
+ margin: Vector2;
3525
+ /** The distance between the origin of two adjacent tiles */
3526
+ step: Vector2;
3527
+ /** The size of a tile */
3528
+ tileSize: Vector2;
3497
3529
  };
3498
3530
  type Tilemap = {
3499
3531
  width: number;
@@ -4096,7 +4128,7 @@ declare const defaultTextureAtlasOptions: {
4096
4128
  * opacity: 0.5,
4097
4129
  * },
4098
4130
  * textureAtlas: {
4099
- * charRanges: [32, 126, 161, 255, 0x3040, 0x309f],
4131
+ * charRanges: [32, 132, 161, 255, 0x3040, 0x309f],
4100
4132
  * fontSize: 64,
4101
4133
  * spacing: 4,
4102
4134
  * },
@@ -4151,9 +4183,15 @@ interface TextRendererOptions {
4151
4183
  text: string;
4152
4184
  /** The texture atlas configuration */
4153
4185
  textureAtlas: {
4154
- /** Range of characters covered by the component defined in number pairs.
4155
- * The default value is [32, 126, 161, 255], this means that the component
4156
- * will render characters from 32 to 126 and from 161 to 255. */
4186
+ /** Ranges of characters covered by the component, defined as pairs of
4187
+ * Unicode code points (each pair is an inclusive from–to range).
4188
+ * The default value is [32, 132, 161, 255], which covers Basic Latin
4189
+ * (letters, digits and punctuation) and the Latin-1 Supplement
4190
+ * (accented letters and symbols used by Western European languages).
4191
+ * Additional pairs can be appended to render other alphabets, e.g.
4192
+ * [0x3040, 0x309F] for Japanese Hiragana or [0x0400, 0x04FF] for Cyrillic.
4193
+ * See the official Unicode Character Code Charts to find the range of
4194
+ * each alphabet: {@link https://www.unicode.org/charts/} */
4157
4195
  charRanges?: number[];
4158
4196
  /** The size of the font in pixels for bitmap fonts. */
4159
4197
  fontSize?: number;
@@ -4204,7 +4242,7 @@ interface TextRendererOptions {
4204
4242
  * opacity: 0.5,
4205
4243
  * },
4206
4244
  * textureAtlas: {
4207
- * charRanges: [32, 126, 161, 255, 0x3040, 0x309f],
4245
+ * charRanges: [32, 132, 161, 255, 0x3040, 0x309f],
4208
4246
  * fontSize: 64,
4209
4247
  * spacing: 4,
4210
4248
  * },
@@ -4261,9 +4299,15 @@ declare class TextRenderer {
4261
4299
  text: string;
4262
4300
  /** The texture atlas configuration */
4263
4301
  textureAtlas: {
4264
- /** Range of characters covered by the component defined in number pairs.
4265
- * The default value is [32, 126, 161, 255], this means that the component
4266
- * will render characters from 32 to 126 and from 161 to 255. */
4302
+ /** Ranges of characters covered by the component, defined as pairs of
4303
+ * Unicode code points (each pair is an inclusive from–to range).
4304
+ * The default value is [32, 132, 161, 255], which covers Basic Latin
4305
+ * (letters, digits and punctuation) and the Latin-1 Supplement
4306
+ * (accented letters and symbols used by Western European languages).
4307
+ * Additional pairs can be appended to render other alphabets, e.g.
4308
+ * [0x3040, 0x309F] for Japanese Hiragana or [0x0400, 0x04FF] for Cyrillic.
4309
+ * See the official Unicode Character Code Charts to find the range of
4310
+ * each alphabet: {@link https://www.unicode.org/charts/} */
4267
4311
  charRanges?: number[];
4268
4312
  /** The size of the font in pixels for bitmap fonts. */
4269
4313
  fontSize?: number;
@@ -4289,11 +4333,10 @@ declare class TextRenderer {
4289
4333
  * layer: "Default",
4290
4334
  * tileset: {
4291
4335
  * image: this.assetManager.getImage("tileset.png"),
4292
- * width: 10,
4293
4336
  * tileWidth: 32,
4294
4337
  * tileHeight: 32,
4295
- * margin: new Vector2(0, 0),
4296
- * spacing: new Vector2(0, 0)
4338
+ * margin: 0,
4339
+ * spacing: 0
4297
4340
  * },
4298
4341
  * data: [1, 2, 3, 4],
4299
4342
  * chunks: [],
@@ -4338,11 +4381,10 @@ interface TilemapRendererOptions {
4338
4381
  * layer: "Default",
4339
4382
  * tileset: {
4340
4383
  * image: this.assetManager.getImage("tileset.png"),
4341
- * width: 10,
4342
4384
  * tileWidth: 32,
4343
4385
  * tileHeight: 32,
4344
- * margin: new Vector2(0, 0),
4345
- * spacing: new Vector2(0, 0)
4386
+ * margin: 0,
4387
+ * spacing: 0
4346
4388
  * },
4347
4389
  * data: [1, 2, 3, 4],
4348
4390
  * chunks: [],
@@ -4393,24 +4435,87 @@ declare class TilemapRenderer {
4393
4435
  static componentName: string;
4394
4436
  constructor(options?: Partial<TilemapRendererOptions>);
4395
4437
  }
4438
+ /**
4439
+ * TileAnimation configuration
4440
+ * @public
4441
+ * @category Components Configuration
4442
+ * @example
4443
+ * ```js
4444
+ * const waterAnimation = new TileAnimation({
4445
+ * tiles: [5, 6, 7, 8],
4446
+ * fps: 6
4447
+ * });
4448
+ * ```
4449
+ */
4450
+ interface TileAnimationOptions {
4451
+ tiles: number[];
4452
+ fps?: number;
4453
+ }
4454
+ /**
4455
+ * TileAnimation cycles a tile through a sequence of tile ids from the tileset.\
4456
+ * It is assigned to a {@link Tileset} keyed by the tile id that should animate,\
4457
+ * so every tilemap using that tileset plays the animation in sync.
4458
+ * @public
4459
+ * @category Components Configuration
4460
+ * @example
4461
+ * ```js
4462
+ * const tilemapRenderer = new TilemapRenderer({
4463
+ * tileset: {
4464
+ * image: "tileset.png",
4465
+ * tileWidth: 32,
4466
+ * tileHeight: 32,
4467
+ * animations: new Map([
4468
+ * [3, new TileAnimation({ tiles: [3, 4, 5], fps: 6 })]
4469
+ * ])
4470
+ * },
4471
+ * data: [1, 2, 3, 4],
4472
+ * width: 2
4473
+ * });
4474
+ * ```
4475
+ */
4476
+ declare class TileAnimation {
4477
+ /** The sequence of tile ids to cycle through. */
4478
+ tiles: number[];
4479
+ /** The animation speed in frames per second. */
4480
+ fps: number;
4481
+ /** The current frame of the animation. */
4482
+ currentFrame: number;
4483
+ /** The current time of the animation. */
4484
+ currentTime: number;
4485
+ constructor(options?: TileAnimationOptions);
4486
+ }
4396
4487
  /**
4397
4488
  * The Tileset configuration defines the properties of a tileset used by the TilemapRenderer.\
4398
- * It specifies the source image containing the tiles, the dimensions of the tileset and individual tiles,\
4399
- * and optional margin and spacing between tiles. This configuration is essential for properly\
4400
- * slicing and rendering tiles from the tileset image.
4489
+ * It specifies the source image containing the tiles, the size of the individual tiles,\
4490
+ * and the optional margin and spacing of the image. The number of columns of the tileset\
4491
+ * is obtained from the image. The tileset cannot be updated at runtime.
4401
4492
  * @public
4402
4493
  * @category Components Configuration
4494
+ * @example
4495
+ * ```js
4496
+ * // a tileset of 16x16 tiles extruded by 1 pixel
4497
+ * const tileset = {
4498
+ * image: this.assetManager.getImage("tileset.png"),
4499
+ * tileWidth: 16,
4500
+ * tileHeight: 16,
4501
+ * margin: 1,
4502
+ * spacing: 2
4503
+ * };
4504
+ * ```
4403
4505
  */
4404
4506
  type Tileset = {
4405
4507
  /** The tileset image element */
4406
4508
  image: HTMLImageElement | string;
4407
- width: number;
4408
4509
  tileWidth: number;
4409
4510
  tileHeight: number;
4410
- /** Margin of the tile in pixels (space in the top and the left) */
4411
- margin?: Vector2;
4412
- /** Spacing of the tile in pixels (space in the bottom and the right) */
4413
- spacing?: Vector2;
4511
+ /** Space in pixels between the tiles and the four edges of the image */
4512
+ margin?: number;
4513
+ /** Space in pixels between adjacent tiles */
4514
+ spacing?: number;
4515
+ /** Animated tiles, keyed by the tile id to animate */
4516
+ animations?: Map<number, TileAnimation>;
4517
+ /** Maps each animated tile id to the tile id currently displayed. @internal */
4518
+ _animationState?: Map<number, number>;
4414
4519
  };
4415
4520
  /**
4416
4521
  * Chunk of tile data
@@ -5131,4 +5236,4 @@ declare const SYMBOLS: {
5131
5236
  TimeManager: symbol;
5132
5237
  };
5133
5238
 
5134
- export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerOptions, type AudioSource, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, DarknessRenderer, type DarknessRendererOptions, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, GeometricRenderer, type GeometricRendererOptions, GeometricShape, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, type PlaySfxOptions, Polygon, PolygonCollider, type PolygonColliderOptions, type PropertyKey, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, SYMBOLS, Scene, SceneManager, type SceneType, type SearchResult, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, type System, type SystemGroup, SystemManager, type SystemType, TextAlignment, TextRenderer, type TextRendererOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };
5239
+ export { Animation, type AnimationOptions, type AnimationSlice, Animator, type AnimatorOptions, type Archetype, AssetManager, AudioPlayer, type AudioPlayerOptions, type AudioSource, BallCollider, type BallColliderOptions, BoxCollider, type BoxColliderOptions, BroadPhaseMethods, Button, type ButtonOptions, ButtonShape, Camera, type CameraOptions, type Chunk, Circumference, type Collider, type Collision, type CollisionMatrix, CollisionMethods, CollisionRepository, type CollisionResolution, type Component, type ComponentType, DarknessRenderer, type DarknessRendererOptions, type DependencyName, type DependencyType, EdgeCollider, type EdgeColliderOptions, type Entity, EntityManager, Game, type GameConfig, GameSystem, GamepadController, GeometricRenderer, type GeometricRendererOptions, GeometricShape, InputManager, type IntervalOptions, Keyboard, LightRenderer, type LightRendererOptions, MaskRenderer, type MaskRendererOptions, MaskShape, Mouse, type PlaySfxOptions, Polygon, PolygonCollider, type PolygonColliderOptions, type PropertyKey, Rectangle, RigidBody, type RigidBodyOptions, RigidBodyType, SYMBOLS, Scene, SceneManager, type SceneType, type SearchResult, type Shape, type Slice, SpriteRenderer, type SpriteRendererOptions, type System, type SystemGroup, SystemManager, type SystemType, TextAlignment, TextRenderer, type TextRendererOptions, TileAnimation, type TileAnimationOptions, type TiledChunk, type TiledLayer, type TiledObject, type TiledObjectLayer, type TiledProperty, type TiledTilemap, TiledWrapper, type TiledWrapperOptions, TilemapCollider, type TilemapColliderOptions, TilemapOrientation, TilemapRenderer, type TilemapRendererOptions, type Tileset, TimeManager, type TouchInteraction, TouchScreen, Transform, type TransformOptions, Vector2, type VibrationInput, VideoRenderer, type VideoRendererOptions, between, clamp, debugRenderLayer, decorate, defaultRenderLayer, defaultTextureAtlasOptions, degreesToRadians, fixedRound, gameLogicSystem, gamePhysicsSystem, gamePreRenderSystem, inject, injectable, playSfx, radiansToDegrees, randomFloat, randomInt, range, rgbToHex, stopSfx };