[SOLVED]How to draw an image in a table?
Posted: Thu Jan 05, 2017 2:33 am
Well ... I'm very new to game development and I started this a few hours ago to be honest. I've been reading docs in Lua and Love docs to try to produce something and what I'm trying to do is a simple board and I'd like to put a chunk inside the table index. The following code is showing you ... but the image is positioning at the edge of the window.
What am I trying to do is ok or is there another easy way out of it?
What am I trying to do is ok or is there another easy way out of it?
Code: Select all
Tabuleiro = {}
vazio = nil
casax, casay = 0,0;
Piece1= {x = 0, y = 0, img = nil}
function IniciaTabuleiro()
for i = 1, 10 do
Tabuleiro[i] = {}
for j = 1, 10 do
Tabuleiro[i][j] = 0 -- Inicia o tabuleiro
end
end
end
function love.load(args)
vazio = love.graphics.newImage('vazio.png') -- Salva img na memoria
Piece1.img = love.graphics.newImage('aviao1.png')
IniciaTabuleiro()
end
function love.update(dt)
if love.keyboard.isDown('escape') then
love.event.push('quit') -- Fecha quando aperta ESC
end
Tabuleiro.x = 5
Tabuleiro.y = 5
end
function love.draw(dt)
for x = 1, 10 do
for y = 1, 10 do
Tabuleiro[x][y] = love.graphics.draw(vazio, y * 50 - 50, x * 50 - 50) -- Desenha o tabuleiro
end
end
Tabuleiro[2][3] = love.graphics.draw(Piece1.img, 450, 400)
end