Page 1 of 1

Editing sprites in video memory

Posted: Sun Aug 12, 2012 6:12 pm
by ultrasemen
Hello.
Is there any way to edit sprites I loaded? For example, if I loaded car from .png with newimage and then suddenly want to remove top half of it, or make it covered with green paint somewhere, or, I dunno, anything that can't be done with just dividing one whole car sprite to different car parts sprites. Just change color and opacity of x;y pixel in loaded image from lua. Is it possible?
If no, are there other ways to make something like, emm, voxel 2d physics? Is there something I missed in love modules? Because I want to make just normal game, with sprites, but sometimes behaving like 2d-minecraft.
If no, are you going to add functionality like this to LÖVE?
If no, can I or my friends add it? Would you like it?
If no, then... then... :(

Re: Editing sprites in video memory

Posted: Sun Aug 12, 2012 7:47 pm
by Robin
Welcome.

As for your first question, see ImageData:setPixel. Note that you need to create an ImageData from your file, edit it and then make an image, with love.graphics.newImage (the last variant). Note that changing every pixel individually can be quite slow, you might want to explore different options.

Re: Editing sprites in video memory

Posted: Sun Aug 12, 2012 7:54 pm
by tv_user
I'd say it would be more efficient to have several sprites with all the different colors/stains you would need and then simply switch between them as needed. Alternatively, you could keep the main car sprite and overlay it with some stains/scatches/etc, using another image loaded separately. Pixel by pixel editing is a framerate nightmare...