Trying the new stuff in 0.11.0

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Trying the new stuff in 0.11.0

Post 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?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Trying the new stuff in 0.11.0

Post 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
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Trying the new stuff in 0.11.0

Post 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Trying the new stuff in 0.11.0

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Trying the new stuff in 0.11.0

Post 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 6679 times
HellzoneByron
Prole
Posts: 5
Joined: Sat Jul 01, 2017 5:58 pm
Contact:

Re: Trying the new stuff in 0.11.0

Post 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",})

Code: Select all

room = {"Saskatoon","Poulsbo","Benettsville","Palmyra"}
Chicago = not Chicago
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Trying the new stuff in 0.11.0

Post 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 143 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'
User avatar
Stifu
Party member
Posts: 106
Joined: Mon Mar 14, 2016 9:53 am
Contact:

Re: Trying the new stuff in 0.11.0

Post 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.
Zabuyaki, our upcoming beat 'em up: https://www.zabuyaki.com
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Trying the new stuff in 0.11.0

Post 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. :)
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Trying the new stuff in 0.11.0

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 58 guests