mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 08:11:35 +02:00
initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- Camera centered on the player. At the default 160x144 view this is
|
||||
-- the original framing (player sprite at screen tile (8,8) -> pixel
|
||||
-- (64, 60) after the -4px sprite offset); wider/taller world-pass views
|
||||
-- (window-filling survey on phones, wheel zoom-out) keep the player at
|
||||
-- the same relative center.
|
||||
|
||||
local Camera = {}
|
||||
Camera.__index = Camera
|
||||
|
||||
function Camera.new()
|
||||
return setmetatable({ x = 0, y = 0 }, Camera)
|
||||
end
|
||||
|
||||
function Camera:follow(px, py, viewW, viewH)
|
||||
viewW, viewH = viewW or 160, viewH or 144
|
||||
self.x = px - (viewW / 2 - 16)
|
||||
self.y = py - (viewH / 2 - 8)
|
||||
end
|
||||
|
||||
return Camera
|
||||
Reference in New Issue
Block a user