Thread: Tile Based game map

  1. #1

    Question Tile Based game map

    I was once again reading the Tile Maze tutorial on gametutorials.com. Though I have read it a few times I still dont understand how this line detects the collision with the WALL tiles:
    Code:
     	
    // Check if we collided with a wall (Used the 2D to 1D index conversion)
    if(g_BoardArray[player1->Index.x + player1->Index.y * BOARD_WIDTH] == WALL)
    the code was slightly changed (just the x and y point names)

    I understand how it gets the top left corner point but I don't understand how that tests for collision with the rest of the user controlled sprite.

    If anyone could explai this to me I would be very greatful, Thanks.

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I haven't read the tutorial, but I'm gonna assume that the player is always within one square, never spanning two:
    Code:
    The player is in (2, 0)
    ..P..
    .....
    .....
    .....
    
    
    Then the player moves down and to the right:
    
    The player is in (3, 1)
    .....
    ...P.
    .....
    .....
    
    The player never is partway between these two squares.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Hey thanks, a quick response with diagrams, those are the best kind.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 01-29-2008, 04:40 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  3. Creating Shell based game..Few questions
    By Saintdog in forum Game Programming
    Replies: 1
    Last Post: 12-01-2004, 08:14 PM
  4. 2d non tile based
    By DavidP in forum Game Programming
    Replies: 4
    Last Post: 02-01-2002, 12:51 PM
  5. tile based gaming
    By Unregistered in forum Game Programming
    Replies: 3
    Last Post: 10-27-2001, 12:17 PM