fix(vagrant): wrap world rendering in camera.begin/finish
Map + furniture + puppet now render via the 2D camera so the camera target (= puppet position) appears at screen-center. Without the wrap, world rendering happened in raw window-coords: puppet at world (320,240) appeared at screen upper-left, mouse-screen-to-world math was correct but mouse cursor over the visible puppet computed dx/dy from puppet's world position to mouse_world which was OFF-by-(w/2,h/2). Visual result: head pointed in wrong direction relative to actual mouse position. Spine-prototype already used this pattern (init.lua:128). Aligning vagrant-skeleton with that convention.
This commit is contained in:
2
init.lua
2
init.lua
@@ -193,6 +193,7 @@ function M.update(ctx, dt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.draw(ctx)
|
function M.draw(ctx)
|
||||||
|
camera.begin()
|
||||||
-- Sprite-tilemap (maps.draw_map with sprite-mode + tile_rotations).
|
-- Sprite-tilemap (maps.draw_map with sprite-mode + tile_rotations).
|
||||||
r_lib.draw_map()
|
r_lib.draw_map()
|
||||||
-- Hardcoded furniture placements (test-chamber spirit).
|
-- Hardcoded furniture placements (test-chamber spirit).
|
||||||
@@ -201,6 +202,7 @@ function M.draw(ctx)
|
|||||||
engine.render.draw_sprite_transform(state.backpack_tex, 350, 400, 0, 1, 1, 16, 16, 0xFFFFFFFF)
|
engine.render.draw_sprite_transform(state.backpack_tex, 350, 400, 0, 1, 1, 16, 16, 0xFFFFFFFF)
|
||||||
-- Puppet (sprite-mode via texture_handles populated by load_rig+load_textures).
|
-- Puppet (sprite-mode via texture_handles populated by load_rig+load_textures).
|
||||||
puppet.render(state.player)
|
puppet.render(state.player)
|
||||||
|
camera.finish()
|
||||||
if CI_FRAME_PERF then
|
if CI_FRAME_PERF then
|
||||||
engine.print("vagrant: render_frame_ok")
|
engine.print("vagrant: render_frame_ok")
|
||||||
if not ci_sprite_traced then
|
if not ci_sprite_traced then
|
||||||
|
|||||||
Reference in New Issue
Block a user