Qbasicnews.com

Full Version: Detecting collision
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I am kind of clueless on how to detect collision in a DATA map. Here is my code so far.

Code:
FOR y = 1 TO 6
FOR x = 1 TO 6

READ clr

IF clr = 1 THEN
  LOCATE y, x
  COLOR 15
  PRINT CHR$(219)    
END IF
IF clr = 0 THEN
  LOCATE y, x
  PRINT CHR$(32)
END IF

NEXT
NEXT

DATA 1,1,1,1,1,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,0,0,0,0,1
DATA 1,1,1,1,1,1

LET row = 2
LET col = 3

LOCATE row, col
PRINT "@"

DO

  LOCATE row, col

  FOR i = 1 to 9999
  NEXT i
  LET oldrow = row
  LET oldcol = col
  press$ = INKEY$
  SELECT CASE press$
    CASE IS = "q"
      END
    CASE IS = "w"
      row = row - 1
    CASE IS = "s"
      row = row + 1
    CASE IS = "a"
      col = col - 1
    CASE IS = "d"
      col = col + 1
  END SELECT
  T#=TIMER
  WHILE TIMER < T#+.1: WEND
  IF row <> oldrow OR col <> oldcol THEN
    LOCATE row, col
    COLOR 15
    PRINT "@"
    LOCATE oldrow, oldcol
    COLOR 0: PRINT " "
  END IF
LOOP

Also, the last column in my map does not appear. Help would be appreciated.
You can store the map in an array and check the guys position to the array data.
the last column does not appear because u didnt read it. it is a 7x6 map u read 6x6