Ham62

Move0.bas

Jul 18th, 2020
1,264
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DIM X AS INTEGER, Y AS INTEGER
  2. DIM sKey AS STRING
  3.  
  4. X = 1: Y = 1  ' Coordinates for LOCATE start at (1, 1)
  5. DO
  6.    sKey = INKEY$ ' Read a key from the keyboard
  7.    IF sKey = CHR$(0) + CHR$(72) THEN     ' Up
  8.       Y = Y - 1
  9.    ELSEIF sKey = CHR$(0) + CHR$(80) THEN ' Down
  10.       Y = Y + 1
  11.    ELSEIF sKey = CHR$(0) + CHR$(75) THEN ' Left
  12.       X = X - 1
  13.    ELSEIF sKey = CHR$(0) + CHR$(77) THEN ' Right
  14.       X = X + 1
  15.    END IF
  16.  
  17.    CLS
  18.    LOCATE Y, X: PRINT "O"
  19.  
  20. LOOP UNTIL sKey = CHR$(27) ' exit when pressed escape
RAW Paste Data