Skip to content

Commit

Permalink
Ramp down with variable horizontal spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
thsparks committed Oct 16, 2023
1 parent 663ea85 commit a6298b0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,21 @@ namespace rollerCoasterBuilder {
builder.move(UP, height)
}

function rampDown(distance: number, horizSpace: number) {
for (let index = 0; index <= distance; index++) {
rollerCoasterBuilder.placeRail()
function rampDown(descentDistance: number, horizSpace: number) {
for (let currentDescent = 0; currentDescent <= descentDistance; currentDescent++) {
for (let currentHoriz = 0; currentHoriz < horizSpace; currentHoriz++) {
// Place powered at start only if needed, then every powerInterval blocks.
// Only needed on first descent level since the rest have the downhill to speed up.
let powerAtStart = currentDescent == 0 && horizSpace >= powerInterval;
if ((currentHoriz + (powerAtStart ? 0 : 1)) % powerInterval == 0) {
placePoweredRail()
}
else {
placeRail()
}
builder.move(FORWARD, 1)
}
builder.move(DOWN, 1)
builder.move(FORWARD, 1)
}

// Undo the final down movement, since we didn't actually place a block.
Expand Down

0 comments on commit a6298b0

Please sign in to comment.