All Projects → oniietzschan → terebi

oniietzschan / terebi

Licence: other
A simple library to handle pixel-perfect scaling of window content in Love2D.

Programming Languages

lua
6591 projects
GLSL
2045 projects

Projects that are alternatives of or similar to terebi

lovelive
💕 Live coding framework for LÖVE(2D Game Engine)
Stars: ✭ 27 (+12.5%)
Mutual labels:  love2d
CodenameLT
A pixelart game where you have to run without getting caught by evil agents made originally for GGJ2018
Stars: ✭ 19 (-20.83%)
Mutual labels:  love2d
susse
super ültra sweet sprite editor
Stars: ✭ 22 (-8.33%)
Mutual labels:  love2d
love-atom
Smart autocompletion for the LÖVE framework in Atom.
Stars: ✭ 34 (+41.67%)
Mutual labels:  love2d
helium
No description or website provided.
Stars: ✭ 74 (+208.33%)
Mutual labels:  love2d
lovedebug
A fixed and updated repo of LOVEDEBUG
Stars: ✭ 22 (-8.33%)
Mutual labels:  love2d
catui
A very light-weight GUI library for the Löve2D
Stars: ✭ 84 (+250%)
Mutual labels:  love2d
golflike
A golf roguelike
Stars: ✭ 19 (-20.83%)
Mutual labels:  love2d
OpenNefia
(Archived) Moddable engine reimplementation of the Japanese roguelike Elona.
Stars: ✭ 103 (+329.17%)
Mutual labels:  love2d
love-playdate-emulation
A basic template for previewing games built with LÖVE in a Playdate-like environment.
Stars: ✭ 24 (+0%)
Mutual labels:  love2d
Love-Debug-Graph
An fps/memory/misc graph utillity for Löve2D
Stars: ✭ 29 (+20.83%)
Mutual labels:  love2d
learn2love
Book for learning programming with Lua and LÖVE.
Stars: ✭ 34 (+41.67%)
Mutual labels:  love2d
lovector
A pure-lua vector graphics processing and rendering library for LÖVE 2D
Stars: ✭ 29 (+20.83%)
Mutual labels:  love2d
iqm-exm
IQM & EXM model format specs, Blender exporter, and LÖVE loader.
Stars: ✭ 35 (+45.83%)
Mutual labels:  love2d
awesome-playdate
A list of awesome resources for Playdate (https://play.date) game development and the Playdate SDK (https://play.date/dev/)
Stars: ✭ 149 (+520.83%)
Mutual labels:  love2d
shaderview
A GLSL shader development tool for the LÖVE game framework.
Stars: ✭ 22 (-8.33%)
Mutual labels:  love2d
itchy
A simple version checker for LÖVE games on itch.io
Stars: ✭ 15 (-37.5%)
Mutual labels:  love2d
super-sphere
A minimal action game by Kenneth Reitz.
Stars: ✭ 37 (+54.17%)
Mutual labels:  love2d
neon-phase
NEON PHASE, a colorful platformer made for a week-long jam
Stars: ✭ 21 (-12.5%)
Mutual labels:  love2d
WildWorld
Sandbox freestyle multiplayer game/engine in LÖVE/LUA.
Stars: ✭ 35 (+45.83%)
Mutual labels:  love2d

terebi

Build Status Codecov Love Versions Public Domain

A simple library to handle pixel-perfect scaling of window content in Love2D. Its features are:

  • Simple interface for switching between fullscreen and windowed modes.
  • Centers and letterboxes the view when scaled content does not exactly fit fullscreen resolution, with configurable letterbox color.
  • HighDPI support with no additional code changes.
  • A handful of utility functions for converting window coordinates to game coordinates, and vice versa.

Example

local Terebi = require 'terebi'
local screen

function love.load(arg)
  -- Set nearest-neighbour scaling. (Optional)
  Terebi.initializeLoveDefaults()

  -- Parameters: game width, game height, starting scale factor
  screen = Terebi.newScreen(320, 240, 2)
    -- This color will used for fullscreen letterboxing when content doesn't fit exactly. (Optional)
    :setBackgroundColor(0.25, 0.25, 0.25)
end

function love.keypressed(key)
  local isAltDown = love.keyboard.isDown('ralt') or love.keyboard.isDown('lalt')
  if     key == '+' then
    screen:increaseScale()
  elseif key == '-' then
    screen:decreaseScale()
  elseif key == 'f11' or (isAltDown and key == 'return') then
    screen:toggleFullscreen()
  end
end

local function drawFn()
  -- <Your drawing logic goes here.>
end

function love.draw()
  screen:draw(drawFn) -- Additional arguments will be passed to drawFn.
end

function love.resize(w, h)
  screen:handleResize()
end

Additional Functionality

-- Sets the scale factor.
screen:setScale(3)

-- Gets the current scale factor.
screen:getScale()

-- Sets scale to the largest factor which can fit on the current monitor.
screen:setMaxScale()

-- Gets the position of the mouse cursor in virtual screen (game) coordinates.
local mouseX, mouseY = screen:getMousePosition()

-- Converts window coordinates to virtual screen (game) coordinates.
local gameX, gameY = screen:windowToScreen(windowX, windowY)

-- Converts virtual screen (game) coordinates to window coordinates.
local windowX, windowY = screen:screenToWindow(gameX, gameY)

Installation

Copy terebi.lua into your game directory and require 'terebi'.

Todo

  • Support the ability to start the game at the highest scale window which will fit on the screen.
    • "You can also prevent the window from being created before main.lua is loaded, by doing t.window = false in love.conf. You will need to call love.window.setMode before calling any love.graphics functions though."
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].