Skip to content

Instantly share code, notes, and snippets.

@josefnpat
Last active October 27, 2019 10:50
Show Gist options
  • Save josefnpat/a0bf847547959211f84fff599a924d81 to your computer and use it in GitHub Desktop.
Save josefnpat/a0bf847547959211f84fff599a924d81 to your computer and use it in GitHub Desktop.
Notes on porting LÖVE games from 0.10.2 to 11.0.0

Here are some notes that I am keeping while porting RCS from 0.10.2 to 11.0.0.

love.audio.newSource

It seems that when making a new audio source, it either makes new SoundData from two strings (source,type) instead of defaulting to to the "stream" type. The simplist solution is the following:

While this monkey patch may not work in every case, I suspect it would work in most.

love.audio._newSource = love.audio.newSource
function love.audio.newSource(filename,type)
  return love.audio._newSource(filename,type or "stream")
end

love.graphics.setColor

New color system in 11.0.0 now uses 0..1 instead of 0.10.2's 0..255.

This monkey patch accounts for (r,g,b), (r,g,b,a), ({r,g,b}) and ({r,g,b,a}).

I also used love.graphics.getColor, so I have to monkeypatch that as well.

love.graphics._setColor = love.graphics.setColor
function love.graphics.setColor(r,g,b,a)
  if type(r) == "table" then
    r,g,b,a = r[1],r[2],r[3],r[4]
  end
  love.graphics._setColor(r/255,g/255,b/255,(a or 255)/255)
end

love.graphics._getColor = love.graphics.getColor
function love.graphics.getColor()
  local r,g,b,a = love.graphics._getColor()
  return r*255,g*255,b*255,(a and a*255 or nil)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment