Author Topic: Ottosparks' Mod Topic  (Read 5803 times)

New cloud generator code, makes it much more realistic if done correctly.

Code: [Select]
function cloudGenerator(%magnitude, %x, %y, %loop, %chance)
{
$CG = new scriptObject(CloudGenerator);
$CG.prepare(%magnitude, %x, %y);
for(%i = 0; %i < %loop; %i++)
$CG.expandClouds(%chance);
for(%yPrep = 0; %yPrep < $CG.yMax; %yPrep++)
{
for(%xPrep = 0; %xPrep < $CG.xMax; %xPrep++)
{
if($CG.tewdee[%xPrep, %yPrep] == 1)
{
plantBrick(1);
plantBrick(0);
}
superShiftBrickRight(1);
superShiftBrickRight(0);
}
for(%xPrep = 0; %xPrep < %x; %xPrep++)
{
superShiftBrickLeft(1);
superShiftBrickLeft(0);
}
superShiftBrickAway(1);
superShiftBrickAway(0);
}
$CG.delete();
}

function cloudGenerator::prepare(%this, %magnitude, %x, %y)
{
%this.xMax = %x;
%this.yMax = %y;
for(%yM = 0; %yM < %y; %yM++)
{
for(%xM = 0; %xM < %x; %xM++)
{
%random = getRandom(0, %magnitude);
if((%random > 5 && %random < 15) || (%random > 20 && %random <= 30) || (%random >= 50 && %random <= 65))
%this.tewdee[%xM, %yM] = 1;
}
}
}

function cloudGenerator::expandClouds(%this, %chance)
{
for(%y = 0; %y < %this.yMax; %y++)
{
for(%x = 0; %x < %this.xMax; %x++)
{
if(%this.tewdee[%x, %y] == 1)
{
%random = getRandom(0, 100);
%u = %this.tewdee[%x, %y+1];
%d = %this.tewdee[%x, %y-1];
%l = %this.tewdee[%x-1, %y];
%r = %this.tewdee[%x+1, %y];
if(%u == 0 && %random <= %chance)
{
%this.tewdee[%x, %y+1] = 1;
continue;
}
if(%d == 0 && %random <= %chance)
{
%this.tewdee[%x, %y-1] = 1;
continue;
}
if(%l == 0 && %random <= %chance)
{
%this.tewdee[%x-1, %y] = 1;
continue;
}
if(%r == 0 && %random <= %chance)
{
%this.tewdee[%x+1, %y] = 1;
continue;
}
}
}
}
}

i want to see the puzzle mod


redoing TRP completely without stupid


brainstorming a new landscape generator since my new one just generates the same thing every time with slightly different expansion