From 7ef2e3cd094f8010fb7402ef2790628a7e65269f Mon Sep 17 00:00:00 2001 From: Rampoina Date: Sun, 5 Mar 2023 14:42:33 +0100 Subject: [PATCH] Cleanup --- arc.bqn | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/arc.bqn b/arc.bqn index d01d5eb..ee09419 100755 --- a/arc.bqn +++ b/arc.bqn @@ -4,11 +4,11 @@ # # Arc # The level is a 2d matrix of lists (tiles) -# Each list contains the objects of the game represented as ints +# Each list contains the objects of the game represented as numbers ⟨ansi⟩←•Import "ansi.bqn" moves←⟨0‿0⟩ # list of moves, each move is a direction, we start without moving -chars←" λ$⊕⭍#/\-|+<>^v" # legal characters +chars←" λ$⊕⭍#/\-|+<>^v" # legal characters: ⟨floor,player,box,machine,pmachine,wall,lmirror,rmirror,hbeam,vbeam,xbeam,llaser,rlaser,ulaser,dlaser⟩←↕≠chars beams←hbeam‿vbeam‿xbeam mirrors←lmirror‿rmirror @@ -19,8 +19,8 @@ empties←floor∾beams # floor and laser beams colors←(≠chars)⥊○(⌊1+10⋆⁼1⌈⊢)⊢)¯1+≠moves)∧key='u')@ - •Out e∾"8" # Restore cursor position - {𝕤⋄•Out clear∾ansi.yellow∾"⭍"∾ansi.defaultB∾" Power the machines (⊕) by moving the mirrors ("∾ansi.cyan∾"\/"∾ansi.defaultB∾")"∾(@+10)∾"Controls: (hjkl or wasd) to move, u to undo, r to reset level, q to quit"}⍟(⊑key∊"wasdhjkluqr")@ - {𝕤⋄•Out "Invalid key: (hjkl or wasd) to move, u to undo, r to reset level"}⍟(¬⊑key∊"wasdhjkluqr")@ - •Out¨ (currentLevel⊑levels) Draw moves •Out "Moves: "∾•Repr ¯1+≠moves - {𝕤 + Win (currentLevel⊑levels) Step´⌽moves ? •Out "Good job!, press any key to continue to the next level" - •term.CharB @ - •Out e∾"[H"∾e∾"[0J" + key←•term.CharB @ + clear↩e∾"[2J" currentLevel↩currentLevel+1⋄moves↩⟨0‿0⟩ - }⍟(Win (currentLevel⊑levels) Step´⌽moves)@ + {𝕤⋄•Out e∾"[?12l"∾e∾"[?25h"⋄•Exit 0}⍟(key='q')@ + ; + key←•term.CharB @ + {𝕤⋄Next ⊑("hjklaswd"=key)/∾˜⟨0‿¯1,1‿0,¯1‿0,0‿1⟩}⍟(⊑key∊"hjklaswd")@ + {𝕤⋄Undo @}⍟(key='u')@ + {𝕤⋄•Out e∾"[?12l"∾e∾"[?25h"⋄•Exit 0}⍟(key='q')@ + {𝕤⋄clear↩e∾"[2J"⋄moves↩⟨0‿0⟩}⍟(key='r')@ + {𝕤⋄clear↩e∾"[2J"}⍟(((1⊸+>○(⌊1+10⋆⁼1⌈⊢)⊢)¯1+≠moves)∧key='u')@ }•_While_{𝕤⋄currentLevel<≠levels}@ •Out "Well played, you win!" •Out e∾"[?12l"∾e∾"[?25h"