Snake: Difference between revisions
Content deleted Content added
→{{header|Java}}: added Java |
m →{{header|Sidef}}: ignore opposite directions |
||
Line 321: | Line 321: | ||
given (key) { |
given (key) { |
||
when ("\e[A") { dir = UP } |
when ("\e[A") { if (dir != DOWN ) { dir = UP } } |
||
when ("\e[B") { dir = DOWN } |
when ("\e[B") { if (dir != UP ) { dir = DOWN } } |
||
when ("\e[C") { dir = RIGHT } |
when ("\e[C") { if (dir != LEFT ) { dir = RIGHT } } |
||
when ("\e[D") { dir = LEFT } |
when ("\e[D") { if (dir != RIGHT) { dir = LEFT } } |
||
} |
} |
||
} |
} |