Mastermind: Difference between revisions
Content added Content deleted
Line 234: | Line 234: | ||
[https://easylang.online/apps/mastermind.html Run it] |
[https://easylang.online/apps/mastermind.html Run it] |
||
<lang>col[] = [ |
<lang>col[] = [ 902 990 171 229 960 808 ] |
||
len code[] 4 |
len code[] 4 |
||
len guess[] 4 |
len guess[] 4 |
||
Line 244: | Line 244: | ||
for j range 2 |
for j range 2 |
||
for c range 2 |
for c range 2 |
||
move c * 3 + 76.5 r * 11.5 + 10. |
move c * 3.5 + 76.5 r * 11.5 + 10.4 + j * 3.5 |
||
if black > 0 |
if black > 0 |
||
color 000 |
color 000 |
||
circle 1. |
circle 1.4 |
||
black -= 1 |
black -= 1 |
||
elif white > 0 |
elif white > 0 |
||
color 999 |
color 999 |
||
circle 1. |
circle 1.4 |
||
white -= 1 |
white -= 1 |
||
else |
else |
||
color |
color 310 |
||
circle 0.7 |
circle 0.7 |
||
. |
. |
||
Line 261: | Line 261: | ||
. |
. |
||
func show_code . . |
func show_code . . |
||
color |
color 531 |
||
move 27 0 |
move 27 0 |
||
rect 46 8 |
rect 46 8 |
||
Line 278: | Line 278: | ||
. |
. |
||
func next_row . . |
func next_row . . |
||
⚫ | |||
⚫ | |||
color 420 |
color 420 |
||
linewidth 11 |
|||
⚫ | |||
move |
move 22 row * 11.5 + 12 |
||
line 65 row * 11.5 + 12 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
move 75.7 row * 11.5 + 9.8 |
|||
color 753 |
|||
text "OK" |
text "OK" |
||
. |
. |
||
func rate . . |
func rate . . |
||
move 78 row * 11.5 + 12 |
move 78.5 row * 11.5 + 12 |
||
color |
color 531 |
||
circle |
circle 5.2 |
||
c[] = code[] |
c[] = code[] |
||
g[] = guess[] |
g[] = guess[] |
||
Line 309: | Line 313: | ||
. |
. |
||
call draw_rate row black white |
call draw_rate row black white |
||
color 531 |
|||
linewidth 12 |
|||
move 22 row * 11.5 + 12 |
|||
line 65 row * 11.5 + 12 |
|||
call draw_guess |
|||
row -= 1 |
row -= 1 |
||
if black = 4 |
if black = 4 |
||
Line 315: | Line 324: | ||
if row = -1 |
if row = -1 |
||
call show_code |
call show_code |
||
timer 1 |
|||
else |
else |
||
call next_row |
call next_row |
||
. |
. |
||
. |
|||
on timer |
|||
row = -2 |
|||
. |
. |
||
func new . . |
func new . . |
||
Line 324: | Line 337: | ||
code[i] = random 6 |
code[i] = random 6 |
||
. |
. |
||
color |
color 531 |
||
move 15 10 |
move 15 10 |
||
rect 70 80 |
rect 70 80 |
||
Line 333: | Line 346: | ||
line 90 5 |
line 90 5 |
||
line 10 5 |
line 10 5 |
||
color |
color 310 |
||
linewidth 7 |
linewidth 7 |
||
move 33 3.5 |
move 33 3.5 |
||
Line 341: | Line 354: | ||
textsize 4.5 |
textsize 4.5 |
||
text "Mastermind" |
text "Mastermind" |
||
color |
color 310 |
||
linewidth 0.5 |
linewidth 0.5 |
||
move 15 10 |
move 15 10 |
||
Line 362: | Line 375: | ||
. |
. |
||
func do_move . . |
func do_move . . |
||
c = |
c = floor ((mouse_x - 20) / 12) |
||
guess[c] = (guess[c] + 1) mod 6 |
guess[c] = (guess[c] + 1) mod 6 |
||
call draw_guess |
call draw_guess |
||
. |
. |
||
on mouse_down |
on mouse_down |
||
if row = - |
if row = -2 |
||
call new |
call new |
||
elif mouse_y > row * 11.5 + 7 and mouse_y < row * 11.5 + 17 |
elif mouse_y > row * 11.5 + 7 and mouse_y < row * 11.5 + 17 |