GithubHelp home page GithubHelp logo

sharnw / voxel-dummy-player Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 9 KB

Dummy player object based on voxel-player. Can look at objects, move, and jump on command.

License: Other

JavaScript 100.00%
voxeljs voxel-engine

voxel-dummy-player's Introduction

voxel-dummy-player

Based on substack's voxel-player module (https://github.com/substack/voxel-player).

Create a dummy player object which can be manipulated by API methods.

example

var createGame = require('voxel-hello-world');
var game = createGame();

var createDummy = require('./')(game);
var dummy1 = createDummy('skin1.png');
dummy1.yaw.position.set(0,2,-2);

var createPlayer = require('voxel-player')(game);
var player = createPlayer('skin1.png');
player.position.set(0,2,0);
player.possess();

dummy1.faceTowards(player);

window.addEventListener('keydown', function (ev) {
    if (ev.keyCode === 'R'.charCodeAt(0)) {
        player.toggle();
    }
    if (ev.keyCode === 'F'.charCodeAt(0)) {
        dummy1.faceTowards(player);
    }
    if (ev.keyCode === 'J'.charCodeAt(0)) {
        dummy1.jump(0.3);
    }
});

methods

var voxelDummy = require('voxel-dummy-player')

var createDummy = voxelDummy(game)

Return a function createDummy from a voxel-engine game instance.

var dummy = createDummy(img)

Return a new dummy from a image file src string img.

dummy.position.set(x, y, z)

Set the dummy position.

dummy.subjectTo(forceVector)

Subject the dummy to a force of gravity or some such. The default value is a THREE.Vector3 with { x: 0, y: -0.00009, z: 0 }.

dummy.move(x, y, z) or dummy.move(vec)

Move a relative amount with (x, y, z) or a THREE.Vector3 vec.

dummy.moveTo(x, y, z) or dummy.move(pos)

Move to an absolute position with (x, y, z) or a THREE.Vector3 pos.

dummy.rotate(x, y, z) or dummy.rotate(vec)

Rotate body a relative amount with (x, y, z) or a THREE.Vector3 vec.

dummy.rotateTo(x, y, z) or dummy.rotateTo(pos)

Rotate body to an absolute position with (x, y, z) or a THREE.Vector3 pos.

dummy.faceTowards(obj)

Rotate dummy to face towards object position.

dummy.rotateHead(x, y, z) or dummy.rotate(vec)

Rotate head a relative amount with (x, y, z) or a THREE.Vector3 vec.

dummy.rotateHeadTo(x, y, z) or dummy.rotateTo(pos)

Rotate head to an absolute position with (x, y, z) or a THREE.Vector3 pos.

dummy.lookAt(obj)

Rotate dummy head to look at object position.

dummy.jump(y)

Make dummy jump by height of y.

license

MIT

install

With npm do:

npm install voxel-dummy-player

BUGS

If created after player it auto-possesses the dummy. Not sure why, but feel free to help out :)

voxel-dummy-player's People

Contributors

sharnw avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

potatolain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.