Separate sprites into their own files
This commit is contained in:
@@ -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
@@ -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 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user