Page 83 of 91

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Nov 29, 2016 8:47 pm
by paul54000
i read this on reddit, but i don't undertand :
https://www.reddit.com/r/gamedev/commen ... e/cpyw8en/
I never heard of Overlap2d, but it looks excellent. I've been trying to do something similar in a very bootleg way using Gimp layers and paths and exporting to a format that preserves metadata.

What is the output format of Overlap2d? If it doesn't work with Love2d already, I'd like to work on an integration if possible.

perma-lienembed

[–]azakhary[S] 1 point il y a 1 an

It would be awesome to have a runtime for love2d, you can use this: https://github.com/UnderwaterApps/overl ... ime-libgdx

And make it work with love2d instead. By utilizing same principles.

perma-lienembedparent

[–]akciom@akciom 1 point il y a 1 an

So does Overlap2D integrate directly into existing code? Tiled Map Editor for example outputs to a custom documented XML format which is way more flexible. Please correct me if I'm wrong.

perma-lienembedparent

[–]azakhary[S] 1 point il y a 1 an

Overlap2D outputs to a custom documented JSON format, and there is an open source runtime to parse it and render.

Re: "Questions that don't deserve their own thread" thread

Posted: Tue Nov 29, 2016 11:48 pm
by zorg
paul54000 wrote:i read this on reddit, but i don't undertand :
https://www.reddit.com/r/gamedev/commen ... e/cpyw8en/
Basically, someone would need to write a Löve runtime for it, if one wanted to use it in Löve.

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 30, 2016 12:27 am
by paul54000
zorg wrote:
paul54000 wrote:i read this on reddit, but i don't undertand :
https://www.reddit.com/r/gamedev/commen ... e/cpyw8en/
Basically, someone would need to write a Löve runtime for it, if one wanted to use it in Löve.
A good programmer of this forum can do it? It's very difficult ?


Because overlap2d is a good software, so it would be nice that it is compatible with löve

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 30, 2016 4:22 am
by zorg
paul54000 wrote:
zorg wrote:
paul54000 wrote:i read this on reddit, but i don't undertand :
https://www.reddit.com/r/gamedev/commen ... e/cpyw8en/
Basically, someone would need to write a Löve runtime for it, if one wanted to use it in Löve.
A good programmer of this forum can do it? It's very difficult ?
Because overlap2d is a good software, so it would be nice that it is compatible with löve
Probably not that difficult, i mean, Tiled had two wrappers written for it (and löve); though i'm not going to be the one to do it for overlap2D. :P

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 30, 2016 2:58 pm
by paul54000
here is the official answer of the creator of overlap2d
Hi,

Overlap2D only exports your visual data as a JSON file, it does not provide an engine for a specific language.
While there are open source engines/runtimes for haxe and libgdx there is no current runtime for L0VE2D (or that I know of)
So you will have to make one if you want to use it. Luckily it is not that hard, here is the link to get started: http://overlap2d.com/data-api-creating-custom-runtime/

Re: "Questions that don't deserve their own thread" thread

Posted: Wed Nov 30, 2016 4:55 pm
by Positive07
Yes, this can be done but is a really big task, far bigger than tiled, since it has light, physics, scenes, particles, even 9patch and meshed images... Writing and optimizing this to work with LÖVE wouldn't be an easy task. It is possible, but a lot of work.

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Dec 02, 2016 12:01 pm
by megalukes
What am I doing wrong? I want to scale a rectangle but I need its position to be always on center of the mouse pointer.

Code: Select all

quad = {}
quad.x = 0
quad.y = 0
quad.sx = 1
quad.sy = 1
quad.r = 0
quad.w = 256
quad.h = 128
quad.ox = quad.w/2
quad.oy = quad.h/2

function love.update(dt)
	quad.x, quad.y = love.mouse.getPosition()
end

function love.draw()
	love.graphics.translate(-quad.ox, -quad.oy)
	love.graphics.scale(quad.sx, quad.sy)
	love.graphics.rectangle("fill", quad.x, quad.y, quad.w, quad.h)
end

function love.wheelmoved( x, y )
	quad.sx = quad.sx + 0.01*y
	quad.sy = quad.sy + 0.01*y
	quad.ox = (quad.w*quad.sx)/2
	quad.oy = (quad.h*quad.sy)/2
end

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Dec 02, 2016 1:48 pm
by Beelz
Apply your offset when drawing:

Code: Select all

love.graphics.rectangle("fill", quad.x-quad.ox, quad.y-quad.oy, quad.w, quad.h)

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Dec 02, 2016 1:57 pm
by megalukes
Beelz wrote:Apply your offset when drawing:

Code: Select all

love.graphics.rectangle("fill", quad.x-quad.ox, quad.y-quad.oy, quad.w, quad.h)
It's behaving weirdly though. I'm trying to find a solution for that here.

Re: "Questions that don't deserve their own thread" thread

Posted: Fri Dec 02, 2016 6:38 pm
by Positive07
That is because you are using the offset AND the translation. He mean to remove you love.graphics.translate line and replacing the rectangle drawing with that:

Code: Select all

quad = {}
quad.x = 0
quad.y = 0
quad.sx = 1
quad.sy = 1
quad.r = 0
quad.w = 256
quad.h = 128
quad.ox = quad.w/2
quad.oy = quad.h/2

function love.update(dt)
   quad.x, quad.y = love.mouse.getPosition()
end

function love.draw()
   love.graphics.scale(quad.sx, quad.sy)
   love.graphics.rectangle("fill", quad.x-quad.ox, quad.y-quad.oy, quad.w, quad.h)
end

function love.wheelmoved( x, y )
   quad.sx = quad.sx + 0.01*y
   quad.sy = quad.sy + 0.01*y
   quad.ox = (quad.w*quad.sx)/2
   quad.oy = (quad.h*quad.sy)/2
end
But that won't work either, that is because once you scale, all your dimensions are scaled, including mouse coordinates.

In order to fix this you have two options:

Scaling your mouse coordinates back to their original size by dividing them by quad.sx and quad.sy

Code: Select all

quad = {}
quad.x = 0
quad.y = 0
quad.sx = 1
quad.sy = 1
quad.r = 0
quad.w = 256
quad.h = 128
quad.ox = quad.w/2
quad.oy = quad.h/2

function love.update(dt)
   quad.x, quad.y = love.mouse.getPosition()
end

function love.draw()
   love.graphics.scale(quad.sx, quad.sy)
   love.graphics.rectangle("fill", (quad.x/quad.sx)-quad.ox, (quad.y/quad.sy)-quad.oy, quad.w, quad.h)
end

function love.wheelmoved( x, y )
   quad.sx = quad.sx + 0.01*y
   quad.sy = quad.sy + 0.01*y
   quad.ox = (quad.w*quad.sx)/2
   quad.oy = (quad.h*quad.sy)/2
end
Or translating to mouse coordinates first, scaling and then drawing the rectangle with it's offset

Code: Select all

quad = {}
quad.x = 0
quad.y = 0
quad.sx = 1
quad.sy = 1
quad.r = 0
quad.w = 256
quad.h = 128
quad.ox = quad.w/2
quad.oy = quad.h/2

function love.update(dt)
   quad.x, quad.y = love.mouse.getPosition()
end

function love.draw()
   love.graphics.translate(quad.x,quad.y)
   love.graphics.scale(quad.sx, quad.sy)
   love.graphics.rectangle("fill", -quad.ox, -quad.oy, quad.w, quad.h)
end

function love.wheelmoved( x, y )
   quad.sx = quad.sx + 0.01*y
   quad.sy = quad.sy + 0.01*y
   quad.ox = (quad.w*quad.sx)/2
   quad.oy = (quad.h*quad.sy)/2
end
This one is really similar to what you had and is really simpler