Skip to content

Vovkiv/resolution_solution

Repository files navigation

Resolution Solution

Yet another scaling library. Currently in maintenance-only mode.


Resolution Solution was inspired by:

Other similar scaling libraries that you might want to look into:

Video demonstration

Basic setup

  1. Require library:
local rs = require("resolution_solution")
  1. Configure library:
rs.conf({game_width = 640, game_height = 480, scale_mode = rs.PIXEL_PERFECT_MODE})
  1. Make window resizable (optionally, but stongly advised):
rs.setMode(rs.game_width, rs.game_height, {resizable = true})
  1. Hook into love.resize:
love.resize = function(w, h)
  rs.resize(w, h)
end
  1. Draw something:

(In this example we used scissors, but there another way 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

Manual, examples, demo

Selling points of this library

  • Library have 4 scale modes and you can switch between at any time:

    1. Aspect Scaling mode - scaling with preserved aspect.
    2. Stretching - stretch game to fill entire window.
    3. Pixel Perfect - will scale, using only integer scale factors and adds black bars if it can't. Must-have for pixel-art.
    4. No Scale - as name suggests, nothing will be scalled. Might be useful for debugging or if you make some kind of program (e.g, game engine) where you need to switch between scaling for game itself and no scaling when user editing game scripts.
  • Library doesn't force you to use any specific way to scale your content, unlike some libraries. You can choose canvas, scissors, draw rectangles on top of game, shader, etc. Pick whatever you like!

  • Library written with kikito's guide in mind, 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. Hack and slash your way to make library suitable for your game!

  • Library has .pdf manual, that includes some illustrations, examples, explanations, tips and tricks. Single file documentation, that can be opened in almost anything, including your browser!

  • Written with snake_case. Before it was camelCase.

  • Library licensed under The Unlicense. Do whatever you want with it with no restrictions!

Games made using this library

By togfoxy:

By Gunroar:

By Saxashitter:

If you made game/program using this library, fell free to ask via contacts to add your game in this list.

Announces

I will post announces when new update will be dropped here or will create new release here on GitHub.

Contacts

If you have any questions about this library, have ideas, etc, you can contact me via:

  1. Submit new issue.
  2. love forum.
  3. matrix.
  4. Email - volkovissocool@gmail.com