02-06-2024, 02:13 PM
playing with the idea of a "10-line" program I cane up with a "5-lines" engine that builds a game map of a cave and handles W,A,S,D navigation. I posted this to a facebook group and another person was able to fir in treasure placement and grabbing. What can you fit in there?
Code: (Select All)
Screen _NewImage(80, 45, 0): _FullScreen: _ControlChr Off: _PrintString (1, 1), String$(3280, 219): dx = 40: dy = 20: Randomize Timer: s = Int(200 + Rnd * (100 * (1 + Rnd * 4))): For d = 1 To s: m$ = m$ + Chr$(49 + Int(Rnd * 4)): Next d: px = 40: py = 20: stand = 0
Do: dx = 40: dy = 20: Color 7: _PrintString (1, 1), String$(3280, 219): For c = 1 To Len(m$): _PrintString (dx, dy), ".": Select Case Mid$(m$, c, 1): Case "1": dy = dy - 1: Case "2": dx = dx + 1: Case "3": dy = dy + 1: Case "4": dx = dx - 1: End Select: Select Case dy: Case 40, 1: dy = 20: dx = 40: End Select: Select Case dx: Case 80, 1: dy = 20: dx = 40: End Select: Next c: Color 15: _PrintString (px, py), Chr$(2)
Do: _Limit 40: kk$ = InKey$: Loop Until kk$ <> "": kk$ = UCase$(kk$)
pxm = 0: pym = 0: Select Case kk$: Case "W": pym = -1: Case "S": pym = 1: Case "D": pxm = 1: Case "A": pxm = -1: End Select: Select Case Screen(pym + py, pxm + px, 0): Case 219: pxm = 0: pym = 0: End Select: px = px + pxm: py = py + pym
Loop Until kk$ = Chr$(27)