Separate sprites into their own files

This commit is contained in:
2026-02-25 15:33:00 -03:00
parent 8867e36489
commit 36fc3869a2
54 changed files with 143 additions and 16 deletions
-5
View File
@@ -4,8 +4,3 @@ export interface SpriteRegion {
x: number;
y: number;
}
export const ITEM_SPRITES: Record<string, SpriteRegion> = {
"bworld:pickaxe": { x: 7, y: 9 },
"bworld:bomb": { x: 9, y: 8 },
};
+6 -2
View File
@@ -1,4 +1,5 @@
import { ITEM_SPRITES, SpriteRegion } from "./constants.ts";
import { AssetManager } from "../client/assets.ts";
import { SpriteRegion } from "./constants.ts";
export function point_inside_rec(
point_x: number,
@@ -14,6 +15,9 @@ export function point_inside_rec(
point_y < rec_y + rec_h;
}
type TexturesInfo = Record<string, { x: number; y: number }>;
export function get_sprite_region(id: string): SpriteRegion {
return ITEM_SPRITES[id] ?? { x: 0, y: 0 };
const textures_info = AssetManager.instance.get<TexturesInfo>("bworld:textures_info");
return textures_info?.[id] ?? { x: 0, y: 0 };
}