Created
November 10, 2012 21:37
-
-
Save Raynos/4052616 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var screen = require("screen") | |
var point = require("screen/point") | |
var center = point() | |
var world = screen(center, 800, 600) | |
var gen = generator(world, { | |
tick: 1000 | |
, density: 3 | |
}) | |
/* | |
Generator emits items if the density on the current screen | |
is less then the set value. | |
i.e. if there are less then 3 points in the world near | |
the center it will emit new items to be created. | |
It does so once every tick until the density is matched | |
*/ | |
gen.on("item", function (pos) { | |
// pos.x, pos.y | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment