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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Locked
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

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

Post 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.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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.
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.
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

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

Post 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
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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
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.
paul54000
Prole
Posts: 22
Joined: Mon Nov 28, 2016 12:19 am

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

Post 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/
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

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

Post 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.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

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

Post 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
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

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

Post 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)

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

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

Post 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.
Attachments
main.love
(435 Bytes) Downloaded 97 times
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

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

Post 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
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Locked

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Semrush [Bot], slime and 1 guest