Actually im not sure why the images are not updated. However your code is quite a mess
A simple indicator that your making yourself too much work is when you start naming variables with indices. Remember to stay DRY (Dont repeat yourself), much code you wrote is simply copy-pasted 10 times in a row! I simplified the functions love.load, love.draw and getCard for you and you should simplify/adapt the other functions, too, because that will make reasoning about the actual problem much easier. (Also i renamed some variables so that i actually understand what they are used for.)
You dont have to use my code as written, but i hope that it servers as an inspiration to what you are actually able to do in lua!
If you don't understand what i changed, please ask.
Code: Select all
function love.load()
love.window.setTitle("TripleTriad Ultimate")
bg = love.graphics.newImage( '/images/playmat.png' )
spots = {}
for i=1,9 do
spots[i] = Cardspot:new("fancy", 0, 0, 0, 0)
spots[i].x = 220 + (i%3)*130
spots[i].y = 120 + math.floor(i/3)*150
end
playerHand = {"bitebug","blobra","bloodsoul","caterchipillar","cockatrice"}
enemyHand = {}
for i=0,5 do
enemyHand[i] = Cards[love.math.random(1, 11)]
end
cardsOnTable = {}
for i=1,5 do
cardsOnTable[i] = getCard(playerHand[i])
cardsOnTable.x = 40
cardsOnTable.y = 100+i*60
cardsOnTable.owner = "blue"
end
for i=6,10 do
e[i] = getCard(enemyHand[i-5])
e.x = 660
e.y = 100+i*60
e.owner = "red"
end
s = {
Score:new(playerScore),
Score:new(enemyScore)
}
s[1].x, s[1].y = 80, 50
s[2].x, s[2].y = 700, 50
if gameStarted == 0 then
turn = love.math.random(1,2)
print(turn)
end
if turn == 2 then
enemyTurn()
end
end
Cards = {"bitebug", "blobra", "bloodsoul", "caterchipillar", "cockatrice", "fastitocalon-f", "funguar", "gayla", "geezard", "gesper", "redbat"}
-- to get PlayerCards do: Cards[i]
-- to get EnemyCards do: 'r' .. Cards[i]
local cardTemplates = {
bitebug = {5,1,3,3},
blobra = {5,2,3,1},
bloodsoul = {1,2,1,6},
caterchipillar = {3,4,2,4},
cockatrice = {6,2,1,2},
fastitocalon-f = {1,3,5,2},
funguar = {3,5,1,1},
gayla = {4,2,1,4},
geezard = {5,1,4,1},
gesper = {1,1,5,4},
redbat = {2,6,1,1},
}
function getCard(name, owner)
local filename = name
if owner == "red" then filename = "r" .. filename end
return Card:new(filename, cardTemplate[0], cardTemplate[1], cardTemplate[2], cardTemplate[3])
end
function love.draw()
love.graphics.draw(bg, 0, 0)
for i, o in ipairs(spots) do
love.graphics.draw(o.image, o.x, o.y)
end
for i, o in ipairs(playerHand) do
love.graphics.draw(o.image, o.x, o.y)
end
for i, o in ipairs(enemyHand) do
love.graphics.draw(o.image, o.x, o.y)
end
for i, o in ipairs(cardsOnTable) do
love.graphics.draw(o.image, o.x, o.y)
end
end