Editing sprites in video 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
ultrasemen
Prole
Posts: 5
Joined: Sun Aug 12, 2012 9:40 am

Editing sprites in video memory

Post 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... :(
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Editing sprites in video memory

Post 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.
Help us help you: attach a .love.
User avatar
tv_user
Citizen
Posts: 57
Joined: Sun Aug 12, 2012 4:39 pm
Location: Portugal

Re: Editing sprites in video memory

Post 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...
Did my comment help/offended you? Use the Karma button!!
LÖVEing each day...
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 211 guests