Okey I made several changes:
As said above, you have "mltplay1" in some places and "/mltplay1" in others, I changed everything to "/mltplay1" and "/mltplay2" so that it fits better
You had this in love.update:
Code: Select all
if gamestate == '/mltplay1' or gamestate == '/mltplay2' then
take_turns()
end
Which means that in every frame you changed from player 1 to player 2, and that is not what you want, you need to wait until the user presses something to change the state, luckily you got that right and in the OX_click you had this for every tile:
Code: Select all
if mousePosX > tile.pos1X and mousePosX < tile.pos1X + 100 and mousePosY > tile.pos1Y and mousePosY < tile.pos1Y + 100 then
tile1 = true
take_turns()
end
But here is your second error, you put tile1 to true, and then in your OX_draw you did this
Code: Select all
if gamestate == "/mltplay1" then
if tile1 == true then
love.graphics.draw(O, tile.pos1X, pos1Y)
elseif tile2 == true then
love.graphics.draw(O, tile.pos2X, pos1Y)
...
end
This means that you draw just 1 tile every frame, because of elseif, you dont get to check each tile. The other error was that each tile was drawn an O if it was the turn of player 1, and each tile was drawn an X if it was the turn of player X
So I changed the OX_click to this:
Code: Select all
if mousePosX > tile.pos1X and mousePosX < tile.pos1X + 100 and mousePosY > tile.pos1Y and mousePosY < tile.pos1Y + 100 then
if not tile1 then
tile1 = gamestate
take_turns()
end
end
Which now sets tile 1 to the current game state
I changed OX_draw to this:
Code: Select all
if tile1 == '/mltplay1' then
love.graphics.draw(O, tile.pos1X, tile.pos1Y)
end
if tile2 == '/mltplay1' then
love.graphics.draw(O, tile.pos2X, tile.pos1Y)
end
...
if tile1 == '/mltplay2' then
love.graphics.draw(X, tile.pos1X, tile.pos1Y)
end
if tile2 == '/mltplay2' then
love.graphics.draw(X, tile.pos2X, tile.pos1Y)
end
Here you may notice that im checking if I should draw O or X, also other thing I changed here was that, before, you had pos1Y, pos2Y and so on for the Y position, but it should have been tile.pos1Y, tile.pos2Y and so on
The other problem was that you were drawing the main_UI after OX_draw, which means that after you placed all the O's and X's you drew the tiles.png image, which doesnt have a transparent background, so that means that it was on top and you couldnt see the O's and X's at all... To change this I changed this lines in love.draw
Code: Select all
if gamestate == '/mltplay1' or gamestate == '/mltplay2' then
main_UI()
OX_draw() --OX_draw is now drawn after main_UI
end
So here we had the O's and X's, but they were drawn with a color background, and in the turn of player 1 the background was black, and in player2 turn it was red, that was because you never changed back the color. Adding love.graphics.setColor(255,255,255) as the first line in OX_draw solved this.
Right now your game was completely fine, the only problem being that the backgrounds of the X's and O's covered the tiles.png image, to solve this I replaced your assets but that is because I wanted to do an other neat trick
Now make the logic so that I can play your game!