Socket
Book a DemoInstallSign in
Socket

collide-3d-tilemap

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collide-3d-tilemap

3d tilemap collisions made simple-ish

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
6
-76%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

collision

FAQs

Package last updated on 20 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts