Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Detecting collision
#1
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.
Reply
#2
You can store the map in an array and check the guys position to the array data.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#3
the last column does not appear because u didnt read it. it is a 7x6 map u read 6x6
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)