OK, so im going on my 2 week in trying to learn CODEA and after some help on the fourms and youtube i come up with this…
– tic tac toe –
– Created by Evan Davis on September the 1st –
– I was just fooling around and made this, i have no idea about the “board” class, and after i made this code i started inserting random numbers trying to get it to work. Please dont put too much effort into fixing it, and thanks for any help!!
function setup()
setup:init
board={
{"TL",1,w20,h60,w40,h80,0},
{"TM",2,w40,h60,w60,h80,0},
{"TR",3,w60,h60,w80,h80,0},
{"ML",4,w20,h40,w40,h60,0},
{"MM",5,w40,h40,w60,h60,0},
{"MR",6,w60,h40,w80,h60,0},
{"BL",7,w20,h20,w40,h40,0},
{"BM",8,w40,h20,w60,h40,0},
{"BR",9,w60,h20,w80,h40,0}
}
end
function draw()
background(0, 0, 0, 255)
stroke(255, 255, 255, 255)
strokeWidth(2)
– left line –
line(w40,h20,w40,h80)
– right line –
line(w60,h20,w60,h80)
– bottom –
line(w20,h40,w80,h40)
– top –
line(w20,h60,w80,h60)
for t=1,9 do
if CurrentTouch.x>board[t][3] and CurrentTouch.x<board[t][5] then
if CurrentTouch.y>board[t][4] and CurrentTouch.y<board[t][6] then
if CurrentTouch.tapCount==1 then
board[t][7]=1
elseif CurrentTouch.tapCount==2 then
board[t][7]=1
end
end
end
end
end
-- This is where the problem is
for i=7,9 do
board[i][1]=1
text(“x”,board[i][3],board[i][4])
text(“0”,board[i][3],board[i][4])
end
I hve no idea if this is even close to making a tic tac toe game, any advice will be greatly appreciated! Thanks