2048: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 8,137: | Line 8,137: | ||
=={{header|FutureBasic}}== |
=={{header|FutureBasic}}== |
||
<syntaxhighlight lang="futurebasic"> |
<syntaxhighlight lang="futurebasic"> |
||
begin enum 123 |
begin enum 123 |
||
_lf |
_lf |
||
Line 8,153: | Line 8,151: | ||
void local fn initialize |
void local fn initialize |
||
subclass window 1, @"2048",(0,0,438, |
subclass window 1, @"2048",(0,0,438,438) |
||
fn WindowSetBackgroundColor( 1, fn ColorBlack ) |
fn WindowSetBackgroundColor( 1, fn ColorBlack ) |
||
color(0) = fn ColorDarkGray |
color(0) = fn ColorDarkGray |
||
color(1) = fn ColorGray |
color(1) = fn ColorGray |
||
color(2) = fn ColorLightGray |
color(2) = fn ColorLightGray |
||
color(3) = fn |
color(3) = fn ColorBlue |
||
color(4) = fn |
color(4) = fn ColorBrown |
||
color(5) = fn ColorCyan |
color(5) = fn ColorCyan |
||
color(6) = fn ColorGreen |
color(6) = fn ColorGreen |
||
Line 8,171: | Line 8,169: | ||
void local fn drawBoard |
void local fn drawBoard |
||
int x, y,r = 1, add |
int x, y,r = 1, add |
||
cls |
|||
for y = 320 to 20 step -100 |
for y = 320 to 20 step -100 |
||
for x = 20 to 320 step 100 |
for x = 20 to 320 step 100 |
||
Line 8,225: | Line 8,222: | ||
short a, b, c, t, moved = 0 |
short a, b, c, t, moved = 0 |
||
⚫ | |||
for a = st to st + rd * 3 step rd |
for a = st to st + rd * 3 step rd |
||
⚫ | |||
t = a |
t = a |
||
for b = a to a + cd * 3 step cd |
for b = a to a + cd * 3 step cd |
||
Line 8,234: | Line 8,231: | ||
end if |
end if |
||
next |
next |
||
⚫ | |||
next |
|||
⚫ | |||
⚫ | |||
for a = st to st + rd * 3 step rd |
|||
for b = a to a + cd * 2 step cd |
for b = a to a + cd * 2 step cd |
||
if bd[b] > 0 && bd[b] == bd[b+cd] |
if bd[b] > 0 && bd[b] == bd[b+cd] |
||
bd[b]++ : c = b + cd |
bd[b]++ : c = b + cd |
||
// FILL IN |
// FILL IN |
||
while c <> a+cd*3 |
while c <> a+cd*3 |
||
bd[c] = bd[c+cd] : c += cd |
bd[c] = bd[c+cd] : c += cd |
||
wend |
wend |
||
bd[c] = 0 |
bd[c] = 0 |
||
// CHECK FOR WIN |
|||
if bd[b] == 11 then fn drawBoard : fn finish( yes ) : exit fn |
if bd[b] == 11 then fn drawBoard : fn finish( yes ) : exit fn |
||
zs ++ : moved ++ |
zs ++ : moved ++ |
||
Line 8,252: | Line 8,246: | ||
next |
next |
||
next |
next |
||
⚫ | |||
if moved == 0 then exit fn |
if moved == 0 then exit fn |
||
⚫ | |||
// GROW |
// GROW |
||
Line 8,263: | Line 8,257: | ||
if rnd(10) - 1 then bd[b]++ else bd[b] = 2 |
if rnd(10) - 1 then bd[b]++ else bd[b] = 2 |
||
zs-- |
zs-- |
||
⚫ | |||
timerbegin 0.25 |
|||
fn drawBoard |
|||
timerend |
|||
if zs then exit fn |
if zs then exit fn |
||