Tiles, arrays and quads
Posted: Wed May 13, 2020 12:41 pm
I'm trying to read an image as an array.
The image is 600*200px
I need an array in two dimensions. x and y
All tiles are 100px both x and y.
- - - - - - - -
| | | | | | |
- - - - - - - -
| | | | | | |
- - - - - - - -
As a test i would like to write it to the screen.
Here is what i got.
The image is 600*200px
I need an array in two dimensions. x and y
All tiles are 100px both x and y.
- - - - - - - -
| | | | | | |
- - - - - - - -
| | | | | | |
- - - - - - - -
As a test i would like to write it to the screen.
Here is what i got.
Code: Select all
img = love.graphics.newImage("test.png")
for x =0, 5 do
for y =0, 1 do
tile[x,y]=love.graphics.newQuad(x*100,y*100,(x*100)+100, (y*100)+100, img:getDimensions())
end
end
function love.draw()
for x =0, 5 do
for y =0, 1 do
love.graphics.draw(img, tile(x,y), x*100, y*100)
end
end
end