Unfinished webgl renderer
This commit is contained in:
@@ -3,14 +3,14 @@ import { AssetManager } from "$/client/assets.ts";
|
||||
import { PlayerInventory } from "$/client/components/inventory.ts";
|
||||
import { InputManager } from "$/client/input_manager.ts";
|
||||
import { draw_item, draw_nine_slice } from "./render_utils.ts";
|
||||
import { Texture } from "$/client/renderer.ts";
|
||||
|
||||
export function render_player_inventory(ctx: CanvasRenderingContext2D, player_inventory: PlayerInventory) {
|
||||
export function render_player_inventory(player_inventory: PlayerInventory) {
|
||||
const PADDING = 10;
|
||||
const ui = AssetManager.instance.get<HTMLImageElement>("bworld:ui");
|
||||
const ui = AssetManager.instance.get<Texture>("bworld:ui");
|
||||
const layout = player_inventory.layout.slots;
|
||||
|
||||
draw_nine_slice(
|
||||
ctx,
|
||||
ui,
|
||||
160,
|
||||
0,
|
||||
@@ -30,7 +30,6 @@ export function render_player_inventory(ctx: CanvasRenderingContext2D, player_in
|
||||
const x = slot.x + PADDING;
|
||||
const y = slot.y + PADDING;
|
||||
draw_nine_slice(
|
||||
ctx,
|
||||
ui,
|
||||
player_inventory.hovering_slot === index ? 19 * 16 : 160 + 32,
|
||||
player_inventory.hovering_slot === index ? 16 : 0,
|
||||
@@ -51,12 +50,12 @@ export function render_player_inventory(ctx: CanvasRenderingContext2D, player_in
|
||||
const y = slot.y + PADDING;
|
||||
const item = player_inventory.container.get_item(index);
|
||||
if (item) {
|
||||
draw_item(ctx, item, x, y);
|
||||
draw_item(item, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
if (player_inventory.holding_item) {
|
||||
const mouse = InputManager.get_mouse_position();
|
||||
draw_item(ctx, player_inventory.holding_item, mouse.x, mouse.y);
|
||||
draw_item(player_inventory.holding_item, mouse.x, mouse.y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user