All pastes #935565 Raw Edit

Basic Terrain Manipulation

public text v1 · immutable
·published 2008-03-09 19:03 UTC
rendered paste body
globals
    real terrainSize = 64.0
endglobals

function raisePoint takes real x, real y returns nothing
    set x = x - ModuloReal(x, terrainSize)
    set y = y - ModuloReal(y, terrainSize)
    call TerrainDeformCrater( x, y, 64.0, -256.0, 1, true)
endfunction

function createWall takes real x1, real x2, real y1, real y2 returns nothing
  local real xInc
  local real yInc
  local real i

    if y1 > y2 then
        set yInc = y1
        set y1 = y2
        set y2 = yInc
    endif
    if (x2 - x1) > (y2 - y1) then
        set i = (x2 - x1) / terrainSize
    else
        set i = (y2 - y1) / terrainSize
    endif
    set xInc = (x2 - x1)/i
    set yInc = (y2 - y1)/i
    if x1 > x2 then
        set i = i * -1.0
    endif
    loop
        exitwhen y1 >= y2
        call raisePoint(x1, y1)
        set x1 = x1 + xInc
        set y1 = y1 + yInc
    endloop
endfunction