Skip to content

Instantly share code, notes, and snippets.

@iamvery
Created September 5, 2013 21:28
Show Gist options
  • Select an option

  • Save iamvery/6456436 to your computer and use it in GitHub Desktop.

Select an option

Save iamvery/6456436 to your computer and use it in GitHub Desktop.
var GRID_WIDTH = 10
var GRID_HEIGHT = 8
function random_between(start, end){
Math.round(Math.random() * (end - start)) + start
}
function randomly_select_bead() {
random_x = random_between(0, GRID_WIDTH)
random_y = random_between(0, GRID_HEIGHT)
PS.BeadColor(random_x, random_y, PS.COLOR_BLACK)
PS.BeadFunction(random_x, random_y, bead_clicked)
}
function bead_clicked(x,y){
PS.BeadColor(random_x, random_y, PS.COLOR_WHITE)
PS.BeadFunction(x,y,null)
randomly_select_bead()
}
PS.Init = function(){
PS.GridSize(GRID_WIDTH, GRID_HEIGHT)
randomly_select_bead()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment