3d tilemap collisions made simple-ish
Switch branches/tags
Nothing to show
Clone or download
Latest commit 4d5c0e4 Jan 20, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md update readme a lil, bump version Jan 21, 2013
index.js skip colliding axes when vector component is 0 Jan 20, 2015
package.json 1.0.0 Jan 20, 2015

README.md

collide-3d-tilemap

an api for user-defined collision-detection between aabb-3d objects and tilemaps.

var my_tilemap = [
        0, 0, 0, 1
      , 1, 0, 0, 1
      , 1, 0, 0, 1
      , 1, 1, 1, 1
    ]

var collisions = require('collide-3d-tilemap')
  , collide

var player = aabb([0, 0, 0], [16, 16, 16])
  , vec = [0, 0, 0]

// collisions(field, size of tile in pixels, [width, height])
collide = collisions(my_tilemap, 32)

my_game_event_loop(function(dt) {
  vec = get_player_input() * dt 

  collide(player, vec, function(axis, tile_data, coords, dir, diff) {
    if(tile) {
      vec[axis] = diff
      return true
    }
  })

})

License

MIT