Imagine Conway's game of life. mhhhm, good, now imagine that whenever something hits the border, everything on screen would be rescale by 0.5(as in zoom out), and it would continue running. But how would you do this?
You could ofcourse have an array, but then how would you go about implenting not only the switch to a different array, but also the dynamic recreation of one, since i imagine creating a 250x250 2d array on the run is kinda heavy.
Or you could do it arrayless, and just depend on reading the color of previous objects/pixels, but is this possible?
So all in all: what's the best way to manipulate a grid of above 100x100 tiles, if you wanna update it regularly, like, alot...
Flexibility in project
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Flexibility in project
If I catch what you want to do correctly, you'll want to implement a camera. You can do this using love.graphics.translate, love.graphics.rotate, and for what you want to do, love.graphics.scale. But you'll also need to manage a transformation stack using love.graphics.push and love.graphics.pop. The basic formula is this:
Fortunately this has already been done. For example kikito has implemented a camera in his framework called PÄSSION, and I've also made one (based off his) in my framework Grace; although to use these you'll have to use the whole framework. vrld has implemented a (I believe) framework independent camera in his library HUMP.
Hope that helps.
Code: Select all
love.graphics.push() -- push the current transformation
love.graphics.rotate(-math.rad(degrees))
love.graphics.scale(1.0 / scaleX, 1.0 / scaleY)
love.graphics.translate(-posX, -posY)
-- do all drawing here
love.graphics.pop() -- return screen to normal state of transformation
Hope that helps.
Re: Flexibility in project
Thanks for the quick response those functions are just what i need, but clearly require some testing to get to know how to make them function correctly.
Eitherway, i'll get back to making the scaling work correctly once i get a bit more done on the actual content.
Eitherway, i'll get back to making the scaling work correctly once i get a bit more done on the actual content.
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Flexibility in project
No worries . The wiki is your friend, it's got a lot of information in it.
By the way those functions perform very well (even when calling the whole sequence every frame - which is what you'll have to do).
By the way those functions perform very well (even when calling the whole sequence every frame - which is what you'll have to do).
Re: Flexibility in project
I hope so Came to Love2D for the sole reason that Flash+AS3 got too inefficient and limited. Before even stepping it up to 1080p HD resolution!
Eitherway, i tested yestaday and just the love.exe demo screen seemed to utilize the GPU for drawing, so it can't be worse
Eitherway, i tested yestaday and just the love.exe demo screen seemed to utilize the GPU for drawing, so it can't be worse
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Flexibility in project
Really? My first programming environment was Flash with AS3. Yeah, Flash sure does have it's limitations.
As far as I know, Love uses OpenGL for hardware acceleration, I'm sure that would give it a boost.
As far as I know, Love uses OpenGL for hardware acceleration, I'm sure that would give it a boost.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Flexibility in project
Lua can make a 250x250 array in a hundredth of a second - it may be a scripting language, but it's /fast/.Echo51 wrote:You could ofcourse have an array, but then how would you go about implenting not only the switch to a different array, but also the dynamic recreation of one, since i imagine creating a 250x250 2d array on the run is kinda heavy
But why make a new array each time? Why not just add new rows and columns to the existing array as you need them?
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Flexibility in project
Creation of a 250x250 array is very fast and running through it every frame is pretty fast too. Thing is it's better to update large arrays a chunk at a time. Like in SimCity, in order to update the entire city, it would update it a chunk at a time from the top left to bottom right. Depends on what you want to do.
- Anisij1981
- Prole
- Posts: 1
- Joined: Mon Feb 07, 2011 4:09 pm
- Location: Russia
- Contact:
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Flexibility in project
Yes. It is a nice answer.. I guess?Anisij1981 wrote:Какой симпатичный ответ
Who is online
Users browsing this forum: Bing [Bot] and 3 guests