PhoenixAran / resolution_solution

Scale library, that help you add resolution support to your games in love2d!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolution Solution

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


Resolution Solution was inspired by:

Other similar libraries:

Video demonstration:

Basic setup:

  1. Drop library into your main.lua:
local rs = require("resolution_solution")
  1. Configure it:
rs.conf({game_width = 640, game_height = 480, scale_mode = 3})
  1. Make window resizable:
rs.setMode(rs.game_width, rs.game_height, {resizable = true})
  1. Update it:
love.resize = function(w, h)
  rs.resize()
end
  1. 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

Manual, examples, demo

Selling points of this library:

  • Library have 3 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.
  • 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.

Games made using this library

By togfoxy:

By Gunroar:

Announces

I will post announces when new update will be dropped here.

Contacts

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

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

About

Scale library, that help you add resolution support to your games in love2d!

License:The Unlicense


Languages

Language:Lua 100.0%