# HP Prime for All

English  Русский
 Name Tic Tac Toe Description Simple Tic Tac Toe game. Author Mickaël Nicotera

EXPORT TIC_TAC_TOE() `BEGIN ````//By Mickaël Nicotera local touch; LOCAL X, Y, J, G, C, L1; RECT; 2▶J; G := 0; C := 1; L1 := {0, 0, 0, 0, 0, 0, 0, 0, 0}; LINE_P(70, 20, 70, 170, #007CFFh); LINE_P(120, 20, 120, 170, #007CFFh); LINE_P(20, 70, 170, 70, #007CFFh); LINE_P(20, 120, 170, 120, #007CFFh); TEXTOUT_P("TIC", 56, 195, 3, #FF0000h); TEXTOUT_P("TAC", 86, 195, 3, #007CFFh); TEXTOUT_P("TOE", 121, 195, 3, #00C20Eh); TEXTOUT_P("By Mickaël Nicotera", 205, 220, 1); WHILE ISKEYDOWN(4) <> 1 OR C < 9 do touch := mouse(); if size(touch(1)) then if touch(1, 5) == 0 then X := B→R(touch(1, 1)); Y := B→R(touch(1, 2)); if irem(C, 2) == 1 THEN if 20 < X < 70 AND 20 < Y < 70 AND L1(1) == 0 THEN LINE_P(24, 24, 66, 66, #FF0000h); LINE_P(66, 24, 24, 66, #FF0000h); L1(1) := 1; C+1▶C; END; if 70 < X < 120 AND 20 < Y < 70 AND L1(2) == 0 THEN LINE_P(74, 24, 116, 66, #FF0000h); LINE_P(116, 24, 74, 66, #FF0000h); L1(2) := 1; C+1▶C; END; if 120 < X < 170 AND 20 < Y < 70 AND L1(3) == 0 THEN LINE_P(124, 24, 166, 66, #FF0000h); LINE_P(166, 24, 124, 66, #FF0000h); L1(3) := 1; C+1▶C; END; if 20 < X < 70 AND 70 < Y < 120 AND L1(4) == 0 THEN LINE_P(24, 74, 66, 116, #FF0000h); LINE_P(66, 74, 24, 116, #FF0000h); L1(4) := 1; C+1▶C; END; if 70 < X < 120 AND 70 < Y < 120 AND L1(5) == 0 THEN LINE_P(74, 74, 116, 116, #FF0000h); LINE_P(116, 74, 74, 116, #FF0000h); L1(5) := 1; C+1▶C; END; if 120 < X < 170 AND 70 < Y < 120 AND L1(6) == 0 THEN LINE_P(124, 74, 166, 116, #FF0000h); LINE_P(166, 74, 124, 116, #FF0000h); L1(6) := 1; C+1▶C; END; if 20 < X < 70 AND 120 < Y < 170 AND L1(7) == 0 THEN LINE_P(24, 124, 66, 166, #FF0000h); LINE_P(66, 124, 24, 166, #FF0000h); L1(7) := 1; C+1▶C; END; if 70 < X < 120 AND 120 < Y < 170 AND L1(8) == 0 THEN LINE_P(74, 124, 116, 166, #FF0000h); LINE_P(116, 124, 74, 166, #FF0000h); L1(8) := 1; C+1▶C; END; if 120 < X < 170 AND 120 < Y < 170 AND L1(9) == 0 THEN LINE_P(124, 124, 166, 166, #FF0000h); LINE_P(166, 124, 124, 166, #FF0000h); L1(9) := 1; C+1▶C; END; if (L1(1) == L1(2) AND L1(2) == L1(3) AND L1(1) == 1) OR (L1(4) == L1(5) AND L1(5) == L1(6) AND L1(6) == 1) OR (L1(7) == L1(8) AND L1(8) == L1(9) AND L1(9) == 1) OR (L1(1) == L1(4) AND L1(4) == L1(7) AND L1(7) == 1) OR (L1(2) == L1(5) AND L1(5) == L1(8) AND L1(8) == 1) OR (L1(3) == L1(6) AND L1(6) == L1(9) AND L1(9) == 1) OR (L1(1) == L1(5) AND L1(5) == L1(9) AND L1(9) == 1) OR (L1(3) == L1(5) AND L1(5) == L1(7) AND L1(7) == 1) THEN TEXTOUT_P("Player 1 wins", 180, 30, 1, 1); G := 1; WAIT(3); BREAK; end; end; IF irem(C, 2) == 0 THEN if 20 < X < 70 AND 20 < Y < 70 AND L1(1) == 0 THEN ARC_P(45, 45, 20, 360, 1, #00C20Eh); L1(1) := 2; C+1▶C; END; if 70 < X < 120 AND 20 < Y < 70 AND L1(2) == 0 THEN ARC_P(95, 45, 20, 360, 1, #00C20Eh); L1(2) := 2; C+1▶C; END; if 120 < X < 170 AND 20 < Y < 70 AND L1(3) == 0 THEN ARC_P(145, 45, 20, 360, 1, #00C20Eh); L1(3) := 2; C+1▶C; END; if 20 < X < 70 AND 70 < Y < 120 AND L1(4) == 0 THEN ARC_P(45, 95, 20, 360, 1, #00C20Eh); L1(4) := 2; C+1▶C; END; if 70 < X < 120 AND 70 < Y < 120 AND L1(5) == 0 THEN ARC_P(95, 95, 20, 360, 1, #00C20Eh); L1(5) := 2; C+1▶C; END; if 120 < X < 170 AND 70 < Y < 120 AND L1(6) == 0 THEN ARC_P(145, 95, 20, 360, 1, #00C20Eh); L1(6) := 2; C+1▶C; END; if 20 < X < 70 AND 120 < Y < 170 AND L1(7) == 0 THEN ARC_P(45, 145, 20, 360, 1, #00C20Eh); L1(7) := 2; C+1▶C; END; if 70 < X < 120 AND 120 < Y < 170 AND L1(8) == 0 THEN ARC_P(95, 145, 20, 360, 1, #00C20Eh); L1(8) := 2; C+1▶C; END; if 120 < X < 170 AND 120 < Y < 170 AND L1(9) == 0 THEN ARC_P(145, 145, 20, 360, 1, #00C20Eh); L1(9) := 2; C+1▶C; END; if (L1(1) == L1(2) AND L1(2) == L1(3) AND L1(1) == 2) OR (L1(4) == L1(5) AND L1(5) == L1(6) AND L1(6) == 2) OR (L1(7) == L1(8) AND L1(8) == L1(9) AND L1(9) == 2) OR (L1(1) == L1(4) AND L1(4) == L1(7) AND L1(7) == 2) OR (L1(2) == L1(5) AND L1(5) == L1(8) AND L1(8) == 2) OR (L1(3) == L1(6) AND L1(6) == L1(9) AND L1(9) == 2) OR (L1(1) == L1(5) AND L1(5) == L1(9) AND L1(9) == 2) OR (L1(3) == L1(5) AND L1(5) == L1(7) AND L1(7) == 2) THEN TEXTOUT_P("Player 2 wins", 180, 30, 1, 1); G := 1; WAIT(3); BREAK; end; END; END; END; END; IF G == 0 THEN TEXTOUT_P("Draw", 180, 30, 1, 1); WAIT(3); END; ```END;