Yet another scaling library. Currently in maintenance-only mode.
Resolution Solution was inspired by:
Other similar libraries:
- Drop library into your
main.lua
:
local rs = require("resolution_solution")
- Configure it:
rs.conf({game_width = 640, game_height = 480, scale_mode = 3})
- Make window resizable:
rs.setMode(rs.game_width, rs.game_height, {resizable = true})
- Update it:
love.resize = function(w, h)
rs.resize()
end
- Draw something:
(In this example we used scissors, but there another ways to achieve this. Read manual or check examples for more info.)
love.draw = function()
rs.push()
local old_x, old_y, old_w, old_h = love.graphics.getScissor()
love.graphics.setScissor(rs.get_game_zone())
love.graphics.setColor(1, 1, 1)
love.graphics.print("Hello, world!", rs.game_width / 2, rs.game_height / 2)
love.graphics.setScissor(old_x, old_y, old_w, old_h)
rs.pop()
end
-
Library have 3 scale modes and you can switch between at any time:
- Aspect Scaling mode - scaling with preserved aspect.
- Stretching - stretch game to fill entire window.
- Pixel Perfect - will scale, using only integer scale factors and adds black bars if it can't. Must-have for pixel-art.
-
Library doesn't force you to use any specific way to scale your content, unlike some libraries. You can choose canvases, scissor, draw rectangles on top of game, shaders... whatever you want!
-
Library written according to kikito's guide, which resulted in very monkey-patchable library! No unreachable locals, no globals, nothing like that! Everything that library produces during calculations can be reached by simple accessing library table:
rs.game_width
,rs.scale_mode
,rs.game_zone.x
, etc. -
Comes with .PDF manual, that includes some illustrations and examples. Includes "Tips and Tricks" chapter where you could found interesting code snippets for you game related to this scaling library (more snippets will come out later). Sadly, most libraries that I used as inspiration doesn't comes with manuals, or at least good ones.
-
Written with
snake_case
. -
Licensed under
Unlicense license
. Do whatever you want with it.
By togfoxy:
By Gunroar:
I will post announces when new update will be dropped here.
If you have any questions about this library, have ideas, etc, you can contact me via: