Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- interpolated value - [0.5, 1]
- local zoom = 1
- -- discrete value - either 0.5 or 1
- local zoom_target = 1
- function _update()
- -- write any game update logic here
- -- end game update logic
- if btnp(5) then
- zoom_target = zoom_target == 1 and 0.5 or 1
- end
- zoom = lerp(zoom, zoom_target, 0.2)
- end
- function lerp(from, to, amount)
- local dist = to - from
- if abs(dist) <= 0.01 then return to end
- return from + (dist * amount)
- end
- function _draw()
- -- set video mode to 128x128
- poke(0x5f2c, 0)
- -- do your game draw operations here as normal
- -- end game draw operations
- -- set video mode to 64x64
- poke(0x5f2c, 3)
- -- video remapping (screen is now treated as the spritesheet for draw operations)
- poke(0x5f54, 0x60)
- -- draw screen to screen
- -- (originx,originy) is the coordinate center of the zoom.
- -- (-32,-32) will put the center of the 128x128 canvas on the center of the 64x64 screen.
- local sx = originx * (zoom - 0.5) * 2
- local sy = originy * (zoom - 0.5) * 2
- local sw = 128 * zoom
- local sh = 128 * zoom
- -- treat the screen as a spritesheet when drawing to the screen (thanks video remapping)
- sspr(0, 0, 128, 128, sx, sy, sw, sh)
- -- video remap back to defaults (screen is the screen, spritesheet is the spritesheet)
- poke(0x5f54, 0x00)
- end
Advertisement
Add Comment
Please, Sign In to add comment