Results 1 to 12 of 12

Thread: [resolved] collision detection (2d array, sprite)

Threaded View

  1. #1

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    [resolved] collision detection (2d array, sprite)

    I'm writing a game but I can't get the collision detection to work quite right...

    I have a map of tiles, each tile is 20x20 pixels and I have the map stored in a 2d array iMap[20][20] so my whole map is 400x400 pixels on the screen.

    If I move my sprite 20 pixels at a time the collision detection works because then I can just go: sprite.x/20 to find out where in the array the player is and then chek to see if the next spot in the array is walkable or not.

    The problem is that I want to move my sprite 5 pixels at a time so the method mentioned above won't work. I can partually move through walls and that is not the way I want it.

    How can I get the collision detection to work even if I move 5 pixels at a time?
    Last edited by McCain; Dec 3rd, 2002 at 04:35 AM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width