The less consuming way to draw an image out of lists of 0 and 1 ?
Posted: Fri Apr 17, 2020 7:24 pm
Hi there ! Hope everybody is fine during those weird times.
So, I created a simple algorithm that creates a list of 0 and 1 with that kind of outputs (it's a silly example supposed to be a cross) :
listCreated = {
{0,0,1,1,0,0}
{0,0,1,1,0,0}
{1,1,1,1,1,1}
{0,0,1,1,0,0}
{0,0,1,1,0,0}
}
So, in that example, I have a function that reads the list and if there's a 0 it draws nothing, and if there's a 1 it draws a rectangle using love.graphics.rectangle(). But the thing is, if I want to draw a hell lot of those kind of lists, it is a lot of work for my poor computer. Since I'm planning to create a game where all the graphics are made of those kinds of lists (with sometimes more than just 0 and 1, for example with informations about the color, etc), and since I'm planning to create those "lists/graphics" procedurally on the go (I don't want to make real images out of them for that project anyway), I need to know the best/less-consuming technique out there.
Here is where I need your help : what is the best way to use those kind of lists and draw them ? I guess it is not love.graphics.rectangle(). For example, is using an image like a PNG (a simple pixel for example) instead of a rectangle() more or less consuming for the computer ? Maybe there is another way to do those kinds of things (bitmaps ? maybe a module ?) ?
Even though I don't need it for my current project, I would also love to know if you have tips or good links about actually creating an image file out of those lists of 0 and 1 (but it's a side question), like a bitmap or a PNG even, I don't know.
Sorry if my question is silly, I'm obviously not an expert in Lua programming
PS : excuse my (bad) English, I'm French.
So, I created a simple algorithm that creates a list of 0 and 1 with that kind of outputs (it's a silly example supposed to be a cross) :
listCreated = {
{0,0,1,1,0,0}
{0,0,1,1,0,0}
{1,1,1,1,1,1}
{0,0,1,1,0,0}
{0,0,1,1,0,0}
}
So, in that example, I have a function that reads the list and if there's a 0 it draws nothing, and if there's a 1 it draws a rectangle using love.graphics.rectangle(). But the thing is, if I want to draw a hell lot of those kind of lists, it is a lot of work for my poor computer. Since I'm planning to create a game where all the graphics are made of those kinds of lists (with sometimes more than just 0 and 1, for example with informations about the color, etc), and since I'm planning to create those "lists/graphics" procedurally on the go (I don't want to make real images out of them for that project anyway), I need to know the best/less-consuming technique out there.
Here is where I need your help : what is the best way to use those kind of lists and draw them ? I guess it is not love.graphics.rectangle(). For example, is using an image like a PNG (a simple pixel for example) instead of a rectangle() more or less consuming for the computer ? Maybe there is another way to do those kinds of things (bitmaps ? maybe a module ?) ?
Even though I don't need it for my current project, I would also love to know if you have tips or good links about actually creating an image file out of those lists of 0 and 1 (but it's a side question), like a bitmap or a PNG even, I don't know.
Sorry if my question is silly, I'm obviously not an expert in Lua programming
PS : excuse my (bad) English, I'm French.