Created
July 17, 2017 15:18
-
-
Save The0x539/730e6e2ecd898e2ced3c03c18ea42ed8 to your computer and use it in GitHub Desktop.
Make SMBX's screen smaller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local viewport = {} | |
viewport.width, viewport.height = 640,480 | |
local cam = Camera.get()[1] | |
local buffer = Graphics.CaptureBuffer(cam.width,cam.height) | |
function viewport.onInitAPI() | |
registerEvent(viewport,"onCameraUpdate") | |
end | |
function viewport.onCameraUpdate() | |
local boundary = player.sectionObj.boundary | |
local pHeight = player:getCurrentPlayerSetting().hitboxHeight | |
local midX = player.x + player.width/2 | |
local midY = player.y + player.height - pHeight/2 | |
local x = {min = midX - viewport.width /2, max = midX + viewport.width /2} | |
local y = {min = midY - viewport.height/2, max = midY + viewport.height/2} | |
if x.min < boundary.left then | |
x.max = x.max + (boundary.left - x.min) | |
x.min = boundary.left | |
elseif x.max > boundary.right then | |
x.min = x.min - (x.max - boundary.right) | |
x.max = boundary.right | |
end | |
if y.min < boundary.top then | |
y.max = y.max + (boundary.top - y.min) | |
y.min = boundary.top | |
elseif y.max > boundary.bottom then | |
y.min = y.min - (y.max - boundary.bottom) | |
y.max = boundary.bottom | |
end | |
x.min = (x.min - cam.x)/cam.width | |
x.max = (x.max - cam.x)/cam.width | |
y.min = (y.min - cam.y)/cam.height | |
y.max = (y.max - cam.y)/cam.height | |
buffer:captureAt(-0.2) | |
Graphics.glDraw{ | |
texture = buffer, | |
vertexCoords = { | |
0, 0, | |
cam.width, 0, | |
cam.width, cam.height, | |
0, cam.height | |
}, | |
textureCoords = { | |
x.min, y.min, | |
x.max, y.min, | |
x.max, y.max, | |
x.min, y.max | |
}, | |
primitive = Graphics.GL_TRIANGLE_FAN, | |
priority = -0.1 | |
} | |
end | |
return viewport |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment