2048: Difference between revisions
m
→{{header|FutureBasic}}: Remove FutureBasic 'Output' label
m (→{{header|FutureBasic}}: Remove FutureBasic 'Output' label) |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 11:
:* All tiles move as far as possible in that direction, some move more than others.
:* Two adjacent tiles (in that direction only) with matching numbers combine into one bearing the sum of those numbers.
:* A move is valid when at least one tile can be moved,
:* A new tile is spawned at the end of each turn at a randomly chosen empty square (if there is one).
:* Most of the time,
:* To win,
:* The player loses if no valid moves are possible.
Line 22:
;Requirements:
* "Non-greedy" movement.
<big><big> [2][2][2][2] </big></big>
Line 34:
<big><big> .........[8] </big></big>
* "Move direction priority".
<big><big> ...[2][2][2] </big></big>
Line 48:
* Check for valid moves.
* Check for a
* Check for a lose condition.
<br><br>
Line 8,169:
void local fn drawBoard
int x, y,r = 1, add
cls
for y = 320 to 20 step -100
for x = 20 to 320 step 100
Line 8,247 ⟶ 8,248:
next
fn drawBoard▼
if moved == 0 then exit fn
Line 8,257 ⟶ 8,259:
if rnd(10) - 1 then bd[b]++ else bd[b] = 2
zs--
timerbegin 0.25
▲ fn drawBoard
fn drawBoard
timerend
if zs then exit fn
Line 8,296 ⟶ 8,300:
handleevents
</syntaxhighlight>
▲[[File:2048 Game Window.png]]
=={{header|Go}}==
Line 16,699 ⟶ 16,702:
{{libheader|Wren-fmt}}
{{libheader|Wren-str}}
<syntaxhighlight lang="
import "random" for Random
import "./ioutil" for Input
import "./fmt" for Fmt
import "./str" for Str
var MoveDirection = Enum.create("MoveDirection", ["up", "down", "left", "right"])
|