New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

glazz

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glazz

Model vision in a 2D world.

latest
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

Glazz

  • by mary rose cook
  • http://maryrosecook.com
  • maryrosecook@maryrosecook.com

Model vision in a 2D world.

Get the code

npm

To install npm, visit https://github.com/isaacs/npm

Install Glazz

$ npm install glazz

Git

$ git clone git://github.com/maryrosecook/glazz.git

Import the code

node

var SolidityMap = require('solidityMap').SolidityMap;
var Glazz = require('glazz').glazz;

Browser

<script type="text/javascript" src="glazz.js"></script>
<script type="text/javascript" src="solidityMap.js"></script>
<script type="text/javascript" src="raytracer.js"></script>
<script type="text/javascript" src="eyes.js"></script>

Documentation

See /index.html

Example

Require SolidityMap. Instantiate it, passing in the width and height of your world. This initialises every solidity map cell to 0, the empty material value.

var SolidityMap = require('src/solidityMap').SolidityMap;
var sm = new SolidityMap(10, 10);

Define an Obj constructor that includes getPosition(), getSize() and getMaterial() accessors. Use it to instantiate the actor, the object that will have eyes.

var Obj = function(posX, posY, sizeX, sizeY) {
  this.pos = { x:posX, y:posY };
  this.size = { x:sizeX, y:sizeY };

  this.getPosition = function() {
    return this.pos;
  },

  this.getSize = function() {
    return this.size;
  },

  this.getMaterial = function() {
    return 1;
  }
}

var actor = new Obj(1, 1, 1, 1);

Give the actor eyes.

var eyes = new Eyes(actor, sm);

Instantiate an object for the actor to look at. Put it in the solidity map.

var obj = new Obj(3, 3, 1, 1);
sm.updateObj(obj);

Make the actor look at the object. See that he sees.

var lookEndpoint = eyes.lookAt(obj);
console.log(lookEndpoint.obj === obj); // => true

The object moves. Update the solidity map with its new position.

obj.pos = { x:4, y:4 };
sm.clearMaterial(obj.getMaterial());
sm.updateObj(obj);

Run the tests

Install Node.js and npm: https://github.com/isaacs/npm

Install the node dependencies and run the tests with:

$ cd path/to/glazz
$ npm install
$ npm test

FAQs

Package last updated on 22 Sep 2013

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