I added a random level generator to the game. It generates 12 blocks between 120 and 480 on the x axis and between 60 and 330 on the y axis. The code is as below...
for (var i = 0; i < 12; i++)
{
var x = Math.floor((Math.random()*10)+3) *40;
var y = Math.floor((Math.random()*9)+2) *30;
rects.push(rect(x, y, 20, 20));
}
The first 8 levels are randomly generated then the last 2 are pre generated.
No comments:
Post a Comment