Tic-tac-toe: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: made p2js compatible, added online link) |
|||
Line 2,838: | Line 2,838: | ||
<lang>len f[] 9 |
<lang>len f[] 9 |
||
state = 0 |
state = 0 |
||
textsize 14 |
|||
set_textsize 14 |
|||
# |
# |
||
func init . . |
func init . . |
||
linewidth 2 |
|||
clear |
|||
clear_screen |
|||
color 666 |
|||
move 34 4 |
|||
line 34 80 |
|||
move 62 4 |
|||
line 62 80 |
|||
move 10 28 |
|||
line 86 28 |
|||
move 10 56 |
|||
line 86 56 |
|||
linewidth 2.5 |
|||
for i range 9 |
for i range 9 |
||
f[i] = 0 |
f[i] = 0 |
||
. |
. |
||
if state = 1 |
if state = 1 |
||
timer 0.2 |
|||
. |
. |
||
. |
. |
||
Line 2,866: | Line 2,866: | ||
y = r * 28 + 14 |
y = r * 28 + 14 |
||
if f[ind] = 4 |
if f[ind] = 4 |
||
color 900 |
|||
move x - 7 y - 7 |
|||
line x + 7 y + 7 |
|||
move x + 7 y - 7 |
|||
line x - 7 y + 7 |
|||
elif f[ind] = 1 |
elif f[ind] = 1 |
||
color 009 |
|||
move x y |
|||
circle 10 |
|||
color -2 |
|||
circle 7.5 |
|||
. |
. |
||
. |
. |
||
Line 2,939: | Line 2,939: | ||
. |
. |
||
func show_result val . . |
func show_result val . . |
||
color 555 |
|||
move 16 84 |
|||
if val < 0 |
if val < 0 |
||
# this never happens |
# this never happens |
||
text "You won" |
|||
elif val > 0 |
elif val > 0 |
||
text "You lost" |
|||
else |
else |
||
text "Tie" |
|||
. |
. |
||
state += 2 |
state += 2 |
||
Line 2,966: | Line 2,966: | ||
f[mov] = 1 |
f[mov] = 1 |
||
call draw mov |
call draw mov |
||
⚫ | |||
state = 1 |
state = 1 |
||
timer 0.5 |
|||
call show_result val |
|||
⚫ | |||
set_timer 0.5 |
|||
⚫ | |||
. |
. |
||
. |
. |
||
on timer |
on timer |
||
call |
call rate val done |
||
if done = 1 |
|||
⚫ | |||
⚫ | |||
call computer |
|||
⚫ | |||
. |
. |
||
on mouse_down |
on mouse_down |