Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 10, 2012 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/4052616 to your computer and use it in GitHub Desktop.
Save Raynos/4052616 to your computer and use it in GitHub Desktop.
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