Page 3 of 5

Re: Trying the new stuff in 0.11.0

Posted: Sun Jul 30, 2017 7:25 am
by Davidobot
raidho36 wrote: Sat Jul 29, 2017 4:03 pm And make sure you use forward-compatible wrapper so you remove it once new version is out, not backwards compatible wrapper that'll stay there forever.
A bit off topic, but I could never wrap my head around how one would go about making a wrapper or this sort.
Would one replace the declaration for love.graphics.setColor, or just make a separate function that then called setColor? If the latter, won't one have to replace all instances of setColor to the separate function?

Re: Trying the new stuff in 0.11.0

Posted: Sun Jul 30, 2017 9:08 am
by raidho36

Code: Select all

local _oldsetcolor = love.graphics.setColor
function love.graphics.setColor ( r, g, b, a )
    return _oldsetcolor ( r * 255, g * 255, b * 255, a * 255 )
end

Re: Trying the new stuff in 0.11.0

Posted: Sun Jul 30, 2017 12:58 pm
by Davidobot
raidho36 wrote: Sun Jul 30, 2017 9:08 am ..code..
Ah, I thought assigning functions like that worked using pointers, so the _oldsetcolor would get turned into recursive function with your code. That's neat.

Re: Trying the new stuff in 0.11.0

Posted: Sun Jul 30, 2017 1:11 pm
by zorg
Davidobot wrote: Sun Jul 30, 2017 12:58 pm
raidho36 wrote: Sun Jul 30, 2017 9:08 am ..code..
Ah, I thought assigning functions like that worked using pointers, so the _oldsetcolor would get turned into recursive function with your code. That's neat.
They do work with pointers, that's why that works; you copied a reference to a function from one variable (love.graphics.setColor) into another (_oldsetcolor), then set the former to a new function reference; that doesn't modify the original function _oldsetcolor is referring to.

Re: Trying the new stuff in 0.11.0

Posted: Tue Aug 01, 2017 12:23 pm
by Santos
The new compatibility warning is now a window which pops up before the game starts. I like it!

Except for the lack of umlauts. :(

compatibility_warning.png
compatibility_warning.png (2.5 KiB) Viewed 6775 times

Re: Trying the new stuff in 0.11.0

Posted: Wed Aug 02, 2017 12:49 pm
by HellzoneByron
I've (very quickly) written a library for this purpose:

Code: Select all

-- 0.11.0 color compatibility library

TwoFiftyFive = {
	Functions = {},
	Init = function(t) for i = 1, #t do TwoFiftyFive.Make(t[i]) end end,
	Make = function(x)
		TwoFiftyFive.Functions[x] = love.graphics[x]
		love.graphics[x] = function(r,g,b,a)
			return TwoFiftyFive.Functions[x]( r * 255, g * 255, b * 255, a * 255 )
		end
	end
}
	
return TwoFiftyFive.Init({"setColor","setBackgroundColor",})

Re: Trying the new stuff in 0.11.0

Posted: Sun Aug 06, 2017 3:10 pm
by Santos
New ParticleSystem stuff!

(I'm no expert, so please correct me if I say something wrong!)

There is AreaSpreadAngle, which rotates the emission area rectangle/ellipse.

There are two new AreaSpread distributions, 'borderrectangle' and 'borderellipse', which emit particles from the border of the rectangle/ellipse instead of within it.

There is AreaSpreadIsRelativeDirection, which (I think) gives particles a direction based on where they were emitted in the emission area, i.e. if the particle was emitted in the upper-left of the emission area it will move up and left. The direction set by setDirection will set a direction relative to this direction, i.e. if the direction is 0 radians then the particles will move outward from the emitter as described before, and a direction of pi radians will move the particles inward toward the emitter.

ps.love
(1.56 KiB) Downloaded 149 times

Code: Select all

function love.load()
    square = love.graphics.newImage('square.png')

    ps = love.graphics.newParticleSystem(square, 1000)
    ps:setPosition(400, 300)
    ps:setEmissionRate(200)
    ps:setParticleLifetime(2)
    ps:setSizes(1, 0)
    ps:setSpeed(100)

    areaX = 160
    areaY = 80
    areaAngle = 1

    ps:setAreaSpread('borderrectangle', areaX, areaY)
    ps:setAreaSpreadAngle(areaAngle)
    ps:setDirection(0)
    ps:setAreaSpreadIsRelativeDirection(true)
end


function love.update(dt)
    ps:update(dt)
end

function love.draw()
    love.graphics.draw(ps, 0, 0)
end

Image by lognz, which you'll probably need to right click on and open in a new tab to read clearly.

Image



love.mousepressed and love.mousereleased now have a click count argument which is the number of clicks in quick succession.

Code: Select all

function love.mousepressed(x, y, button, isTouch, clickCount)
  print(clickCount)
end
I think this uses the system's "double click" speed, so I guess its main use case is checking for double clicks.


Making an Image from an ImageData errors for me (it works fine in 0.10.2):

Code: Select all

image = love.graphics.newImage('image.png') -- This is fine
imagedata = love.image.newImageData('image.png')
image = love.graphics.newImage(imagedata) -- This errors

Code: Select all

Error

main.lua:3: Could not decode data to ImageData: unsupported encoded format


Traceback

[C]: in function 'newImage'
main.lua:3: in main chunk
[C]: in function 'require'
[C]: in function 'xpcall'

Re: Trying the new stuff in 0.11.0

Posted: Mon Aug 07, 2017 8:14 pm
by Stifu
raidho36 wrote: Fri Jul 28, 2017 2:07 pm All of this have been discussed thoroughly in the pull request feed and in other appropriate places; there's a reason all of those things are made that way. Maybe the "getEffects" is a better option than "getEffectsList" but nobody objected in the review process.
Sorry for chiming in as it may not be my place to do so, but I'd still like to give my opinion. If at this time everyone agrees that a new name is better, then it'd make sense to consider making this change before a new LÖVE version is released with the worse / less consistent naming. Even though everything has passed through peer reviews, these reviews just don't spot everything. Some things will always pass through the cracks. It's human. But it doesn't mean you can't fix it afterward.

After all, that 0-255 -> 0-1 color logic change is also a change to something that had probably been reviewed and accepted a long time ago, no? Or maybe it wasn't actually reviewed back then, I don't know. But still, you get the idea: nothing is set in stone, and it's never too late to fix stuff. It can be a tough choice when you have to break backward compatibility, but it's not the case here, as the concerned API isn't part of a public LÖVE release yet.

Re: Trying the new stuff in 0.11.0

Posted: Mon Aug 07, 2017 9:56 pm
by slime
Santos wrote: Sun Aug 06, 2017 3:10 pmMaking an Image from an ImageData errors for me (it works fine in 0.10.2)
Fixed, thanks!

Stifu wrote: Mon Aug 07, 2017 8:14 pm Sorry for chiming in as it may not be my place to do so, but I'd still like to give my opinion. If at this time everyone agrees that a new name is better, then it'd make sense to consider making this change before a new LÖVE version is released with the worse / less consistent naming. Even though everything has passed through peer reviews, these reviews just don't spot everything. Some things will always pass through the cracks. It's human. But it doesn't mean you can't fix it afterward.
It's already been renamed to getActiveEffects. :)

Re: Trying the new stuff in 0.11.0

Posted: Tue Aug 08, 2017 6:44 am
by raidho36
Stifu wrote: Mon Aug 07, 2017 8:14 pmnothing is set in stone, and it's never too late to fix stuff
Which is why the audio API works the way it does now. It's been changed a few times to improve its usability. As for naming - it's already been highlighted that there isn't a whole lot of consistency either way so yeah.