Rotate / scale / move entire screen?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
timmaxw
Prole
Posts: 2
Joined: Mon Feb 02, 2009 1:30 am

Rotate / scale / move entire screen?

Post by timmaxw »

It looks to me like LOVE does not have functions to rotate, move or scale the window as a whole. These would be useful features. Moving the viewport is useful for creating scrolling games. Rotating and scaling are not as important, but are useful for some games and for special effects. All three should be easy to do because LOVE is based on OpenGL.

If nobody else wants to implement these, I'll consider doing it myself eventually.
francois
Prole
Posts: 6
Joined: Sun Feb 01, 2009 3:56 am
Location: Sherbrooke, Québec, Canada
Contact:

Re: Rotate / scale / move entire screen?

Post by francois »

Look at the "CAMERA: scrolling and scaling" thread on the projects & demos page at http://love2d.org/forum/viewtopic.php?f=5&t=419

Hope that helps!
François Beausoleil
http://blog.teksol.info/
osuf oboys
Party member
Posts: 215
Joined: Sun Jan 18, 2009 8:03 pm

Re: Rotate / scale / move entire screen?

Post by osuf oboys »

timmaxw wrote:It looks to me like LOVE does not have functions to rotate, move or scale the window as a whole. These would be useful features. Moving the viewport is useful for creating scrolling games. Rotating and scaling are not as important, but are useful for some games and for special effects. All three should be easy to do because LOVE is based on OpenGL.

If nobody else wants to implement these, I'll consider doing it myself eventually.
CAMERA achieves these effects merely by overloading all of the love.graphics routines with functions that applies the transformation before calling the original functions. Lua is quick so this does not hurt performance but it could be made even faster by extending the LÖVE source. You are welcome to discuss with rude about doing so. There's also a number of features that would be easy on the hardlöve side not currently provided by CAMERA.

If you feel that anything is missing or should be done differently in CAMERA, then you are most welcome to comment or accommodate the necessary changes. If you want, you can even take the code, change it, and call it your own module. I'd much rather see that you contribute to the library and the community (not I) decide what should be in there.

I have moved CAMERA to a wiki page for this reason: http://love2d.org/wiki/index.php?title=CAMERA .
If I haven't written anything else, you may assume that my work is released under the LPC License - the LÖVE Community. See http://love2d.org/wiki/index.php?title=LPC_License.
User avatar
zapwow
Prole
Posts: 48
Joined: Fri Oct 24, 2008 11:37 pm

Re: Rotate / scale / move entire screen?

Post by zapwow »

timmaxw,
You might benefit from having "screenToWorld" and "worldToScreen" functions for converting coordinates. That way you can transform all your positions to screen space before rendering. This is what I'm presently using, but I don't need the screen to rotate. If you can figure out how to do these transformations, then adding rotation shouldn't be too difficult. I've attached some example code and a demo of what it accomplishes.

Code: Select all

function screenToWorld(p)
	x = (p:getX() - screenWidth/2)/scale.val + screenPos:getX()
	y = (p:getY() - screenHeight/2)/scale.val + screenPos:getY()
	return Point(x, y)
end

function worldToScreen(p)
	x = scale.val*(p:getX() - screenPos:getX())+screenWidth/2
	y = scale.val*(p:getY() - screenPos:getY())+screenHeight/2
	return Point(x, y)
end
Attachments
testNav3.love
(324.13 KiB) Downloaded 306 times
Post Reply

Who is online

Users browsing this forum: No registered users and 61 guests