Improve comments

This commit is contained in:
Rampoina 2023-01-03 22:17:28 +01:00
parent 7665f7a1d7
commit 82a6de5fa2
1 changed files with 6 additions and 5 deletions

View File

@ -1,7 +1,8 @@
#!/usr/bin/env BQN #!/usr/bin/env BQN
# 2048 game
# The game is controlled with the vim movement keys: # The game is controlled with the vim movement keys:
# h: left, j: down, k: up, l: right # h: left, j: down, k: up, l: right, q: quit
# it needs a VT-100 compatible terminal # needs a VT-100 compatible terminal
Merge{𝕩 0/ m<`=«𝕩 4(¬»m)/𝕩×1+m} # Merge a single row to the right Merge{𝕩 0/ m<`=«𝕩 4(¬»m)/𝕩×1+m} # Merge a single row to the right
StepMerge˘ # Merges each row of the board StepMerge˘ # Merges each row of the board
@ -16,7 +17,7 @@ Win←´·˝2048⊸= # Winning condition, 2048!
boardSpawn 440 boardSpawn 440
e@+27 e@+27
•term.RawMode 1 •term.RawMode 1
Quit{•Out e"[?12l"e"[?25h" •Exit 𝕩} Quit{•Out e"[?12l"e"[?25h" •Exit 𝕩} # Restores the terminal and exits
•Out e"[?25l"e"[2J"e"[H" # Cursor to origin, hide it and clear screen •Out e"[?25l"e"[2J"e"[H" # Cursor to origin, hide it and clear screen
{𝕤 {𝕤
•Out e"[H"e"[2J" # Cursor to origin •Out e"[H"e"[2J" # Cursor to origin
@ -24,7 +25,7 @@ Quit←{•Out e∾"[?12l"∾e∾"[?25h" ⋄ •Exit 𝕩}
•Show board •Show board
key•term.CharB @ # Read key key•term.CharB @ # Read key
key"hjklq"? key"hjklq"? # Valid key?
{𝕤•Out e"[?12l"e"[?25h" Quit 0}(key='q')@ # Quit key? {𝕤•Out e"[?12l"e"[?25h" Quit 0}(key='q')@ # Quit key?
move(key="hjkl")/LeftDownUpRight # Get movement function from the key move(key="hjkl")/LeftDownUpRight # Get movement function from the key
{𝕤boardSpawnMove 𝕩}(Move) board # Generate the next board if the move is valid {𝕤boardSpawnMove 𝕩}(Move) board # Generate the next board if the move is valid
@ -33,4 +34,4 @@ Quit←{•Out e∾"[?12l"∾e∾"[?25h" ⋄ •Exit 𝕩}
{𝕤•Out "You win!" Quit 0}Win board {𝕤•Out "You win!" Quit 0}Win board
{𝕤•Out "You lose!" Quit 1}Lose board {𝕤•Out "You lose!" Quit 1}Lose board
; @ ; @
}•_While_{𝕤¬Lose board}@ }•_While_{𝕤1}@