Snake: Difference between revisions

Content added Content deleted
Line 2,293: Line 2,293:


=={{header|EasyLang}}==
=={{header|EasyLang}}==
[https://easylang.dev/apps/_snake.html Run it]
[https://easylang.dev/apps/snake.html Run it]
{{Trans|Craft Basic}}
{{Trans|Craft Basic}}
<syntaxhighlight lang="easylang">
<syntaxhighlight lang="easylang">
Line 2,314: Line 2,314:
text "SNAKE"
text "SNAKE"
textsize 5
textsize 5
move 10 40
move 6 40
text "Arrow keys for controlling"
text "Keys or mouse for controlling"
move 10 30
move 6 30
text "Press space to to start"
text "Space or click to to start"
#
#
on key
on key
if keybkey = "ArrowUp" and dir <> 3
if game = 0 and keybkey = " "
dir = 1
elif keybkey = "ArrowRight" and dir <> 4
dir = 2
elif keybkey = "ArrowDown" and dir <> 1
dir = 3
elif keybkey = "ArrowLeft" and dir <> 2
dir = 4
elif keybkey = " " and game = 0
start
start
return
.
if dir mod 2 = 1
if keybkey = "ArrowRight"
dir = 2
elif keybkey = "ArrowLeft"
dir = 4
.
else
if keybkey = "ArrowUp"
dir = 1
elif keybkey = "ArrowDown"
dir = 3
.
.
.
on mouse_down
if game = 0
start
return
.
if dir mod 2 = 1
if mouse_x < sx
dir = 4
else
dir = 2
.
else
if mouse_y < sy
dir = 3
else
dir = 1
.
.
.
.
.
Line 2,335: Line 2,360:
clear
clear
color 997
color 997
move 2 96
move 2 95
text "Score: " & 10 * len sx[] - 50
text "Score: " & 10 * len sx[] - 50
color 966
color 966
Line 2,391: Line 2,416:
color 997
color 997
move 10 10
move 10 10
text "Press space for new game"
text "Space or click new game"
.
.
.
.