Skip to content

Instantly share code, notes, and snippets.

@osa1
Created December 7, 2012 18:26
Show Gist options
  • Save osa1/4235267 to your computer and use it in GitHub Desktop.
Save osa1/4235267 to your computer and use it in GitHub Desktop.
random distribution
randoms = 20
width = 800
height = 500
function love.load()
love.graphics.setMode(width, height, false, false, 0)
randomCounts = {}
for i=0,randoms do randomCounts[i] = 0 end
end
function love.draw()
local idx = math.random(randoms)-1
randomCounts[idx] = randomCounts[idx] + 1
local w = width / randoms
for i=0,20 do
love.graphics.rectangle("line", i*w, height-randomCounts[i], w-1, randomCounts[i])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment