how to saving memory

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.
Post Reply
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

how to saving memory

Post by pielago »

love.graphics.setDefaultFilter(nearest,nearest) for sure this will help memory and speed and frame rate...makes small images bigger onscreen
but in my case I want to make a spritesheet with 64x64 and 128x128 and don't want to kill the memory
I want the images to look smaller on screen I played around with filter and love.draw() but none worked
and was not able to make my 64 and 128 look like a 32x32

perhaps I missed something can someone help me ?
cube.love
cube
(67.67 KiB) Downloaded 157 times
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: how to saving memory

Post by rmcode »

I'm not sure what exactly you are asking here.

Code: Select all

love.graphics.setDefaultFilter
doesn't have much to do with memory usage. It just determines which FilterMode is used while scaling your images.

It looks like something in your code is producing a lot of garbage each frame (and I supposed this is what you are trying to reduce). Generally you should try to avoid creating tables each frame. E.g.:

Code: Select all

love.graphics.setColor( unpack{ fontcolor } )
can be simply rewritten as:

Code: Select all

love.graphics.setColor( fontcolor )
I'd say if you get rid of all those unpack statements you have in your code it should already greatly improve garbage usage. That's the only big issue I saw while glancing over your code.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: how to saving memory

Post by pielago »

Oh ..thanks so much ..i don't want to over kill this ,as for the images the scale
will this work to make my 128x128 images to 32x32 and save memory as well?? or wont work?
https://love2d.org/wiki/love.graphics.scale
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: how to saving memory

Post by zorg »

Let's say that you load a 128x128 image that uses 8 bits for 4 channels (red, green, blue, alpha). The raw data will take up 128*128*4 bytes, which is 65536 bytes, which is 64 kilobytes. Not much. 64x64 is even smaller, with 64*64*4 = 16 kilobytes.

Both disk space and memory will be around those values, maybe a bit more for headers, maybe a bit less because compression.

As for speed, it literally does not matter. The slowest thing would be loading in the file from disk to memory, but you should only do that once anyway, so it is meaningless. Drawing out a 64x64 and a 128x128 image takes about the same time.

Both love.graphics.scale and the sx, sy parameter for love.graphics.draw are the same in functionality, you could use either. For your case, you want a scale factor of 32/128 for both axes, which is 0.25. It will work in that your images will have a size of 32x32 on screen. It has nothing to do with memory usage, or speed.
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.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: how to saving memory

Post by pielago »

thanks you so much for the answer.
I do see many great games with such great graphics ( computers and/or cells ) clash of clans as an example to me looks like a 2D game but the graphics are so nice ( I question my self if it is the programmer or the artist? ) for such nice result!
and that's what I want to achieve.
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: how to saving memory

Post by rmcode »

pielago wrote:thanks you so much for the answer.
I do see many great games with such great graphics ( computers and/or cells ) clash of clans as an example to me looks like a 2D game but the graphics are so nice ( I question my self if it is the programmer or the artist? ) for such nice result!
and that's what I want to achieve.

Clash of Clans is developed by a professional studio so chances are they have more than one artist ;)

I haven't played clash of clans, but it looks like 3d models rendered to 2d sprites. You basically can do the very same with LÖVE.
pielago
Party member
Posts: 142
Joined: Fri Jun 14, 2013 10:41 am

Re: how to saving memory

Post by pielago »

oh! you say its render???
now for TERRARIA its computer game...is that also render from 3D to 2D?????
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: how to saving memory

Post by rmcode »

pielago wrote:oh! you say its render???
now for TERRARIA its computer game...is that also render from 3D to 2D?????
No, sprites in Terraria are hand-drawn.
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests