diff --git a/art/CyberCity-MelonMars/index.js b/art/CyberCity-MelonMars/index.js new file mode 100644 index 000000000..87e6cb226 --- /dev/null +++ b/art/CyberCity-MelonMars/index.js @@ -0,0 +1,332 @@ +/* +@title: CyberCity +@author: MelonMars +@snapshot: snapshot1.png +*/ + +const blockWidth = 50; //Width of a block +const blockHeight = 70; //Height of a block +const nBlocks = 5; // Number of blocks on each row and height +const streetSize = 20; //Thickness of the street +const screenHeight = nBlocks * (blockHeight + streetSize); +const screenWidth = nBlocks * (blockWidth + streetSize); +const carHeight = 1; //Height of each car +const carLength = 10; //Length of each car +const nCars = 0 //Number of cars, similar to number of blocks +const stripeFac = 10; //Stripe factor for crosswalks +const extraGap = 0; //Extra gap between stripes of crosswalk +const crossWalkSize = 5; //Length of crosswalk +const laneDashes = 20; //Amount of dashes per lane +const laneSpacing = 5; //Amount of space between dashes +const nLanes = 3; //Amount of lanes +const skyScraperChance = 0.3 +const skyScraperJumps = 5 // How many tiers you want in your tiered skyscraper +const skyScraperReductionFactor = 0.4; +const colorCars = false +const colorBuildings = false +const colorBackground = true +const sidewalkWidth = 5; //Also increases the width of the skyscrapers +const stuff = 2; //Amount of random stuff to put on each block +const lChance = 0.5; //Chance that the random thing on the block will be an L shaped polygon or not +const maxStuffLength = 10; //Max stuff length (MUST BE LESS THAN THE SIZE OF THE BLOCK) +const minStuffLength = 5; //Minimum stuff length (>0) +setDocDimensions(screenWidth, screenHeight); + +function getRandElem(arr) { + const randI = Math.floor(bt.randInRange(0,1) * arr.length); + return arr[randI].slice(); +} + +function makeBlock(startPos, bw, bh) { + const blk = new bt.Turtle() + blk.up() + blk.goTo(startPos) + blk.down() + blk.forward(bw) + blk.left(90) + blk.forward(bh) + blk.left(90) + blk.forward(bw) + blk.left(90) + blk.forward(bh) + + return (blk.lines()) +} + +function makeCar(startPos, carL, carH) { + const car = new bt.Turtle() + car.up() + car.goTo(startPos) + car.down() + car.forward(carL) + car.left(90) + car.forward(carH) + car.left(90) + car.forward(carL) + car.left(90) + car.forward(carH) + return (car.lines()) + +} + +function drawLanes(bw, bh, streetSize, i, spaceI) { + if (spaceI != nLanes) { + console.log(spaceI, nLanes); + const lw = new bt.Turtle(); + const spacing = streetSize / nLanes; + lw.up(); + i+=1; + lw.goTo([(bw*i)+(i*streetSize)-(spaceI*spacing), 0]); + lw.left(90); + lw.down(); + for (let i=0; i alloPts[0] === pt[0] && alloPts[1] === pt[1])) { + return false; + } + } + return true; +} + +const ptsOutBlk = [] +const ptsInBlk = [] +for (let x = 0; x < screenWidth; x++) { + for (let y = 0; y < screenHeight; y++) { + if (insideBlock(x, y)) { + ptsInBlk.push( + [x, y] + ) + } else { + ptsOutBlk.push( + [x, y] + ) + } + } +} + +const cycleWidth = blockWidth + streetSize +const cycleHeight = blockHeight + streetSize +const blkXs = [] +const blkYs = [] +for (let x = 0; x < screenWidth; x++) { + if (x % cycleWidth < blockWidth) { + blkXs.push(x) + } +} +for (let y = 0; y < screenHeight; y++) { + if (y % cycleHeight < blockHeight) { + blkYs.push(y) + } +} + +const range = streetSize / 2 +const vertCarPts = [] +const horCarPts = [] +for (let pt of ptsOutBlk) { + let [x, y] = pt + if (blkYs.includes(y)) { + vertCarPts.push([x, y]) + } else { + horCarPts.push([x, y]) + } +} + +const cars = [] +for (let horCar = 0; horCar < nBlocks; horCar++) { + for (let i = 0; i < nCars; i++) { + cars.push(makeCar(getRandElem(horCarPts), carLength, carHeight)) + } +} + +for (let vertCar = 0; vertCar < nBlocks; vertCar++) { + for (let i = 0; i < nCars; i++) { + cars.push(makeCar(getRandElem(vertCarPts), carHeight, carLength)) + } +} + +const Cols = ["green", "red", "black", "blue", "orange", "navy", "pink", "purple"] + +const border = new bt.Turtle() +border.goTo([0,0]) +border.forward(screenWidth) +border.left(90) +border.forward(screenHeight) +border.left(90) +border.forward(screenWidth) +border.left(90) +border.forward(screenHeight) +if (colorBackground) { + drawLines(border.lines(), { "fill": getRandElem(Cols) }) +} else { + drawLines(border.lines()) +} + + +for (const crosswalk of crosswalks) { + drawLines(crosswalk, {"stroke": "white"}); +} + +if (colorBuildings) { + for (const block of blocks) { + drawLines(block, { "fill": getRandElem(Cols) , "width": sidewalkWidth}) + } +} else { + for (const block of blocks) { + drawLines(block, {"width": sidewalkWidth}) + } +} + +if (colorCars) { + for (const car of cars) { + drawLines(car, { "fill": getRandElem(Cols) }) + } + }else { + for (const car of cars) { + drawLines(car) + } +} + +for (const lane of lanes) { + drawLines(lane, {"fill": "white"}); +} + +for (const poly of polys) { + drawLines(poly); +} diff --git a/art/CyberCity-MelonMars/snapshots/snapshot1.png b/art/CyberCity-MelonMars/snapshots/snapshot1.png new file mode 100644 index 000000000..550e3bf82 Binary files /dev/null and b/art/CyberCity-MelonMars/snapshots/snapshot1.png differ diff --git a/art/CyberCity-MelonMars/snapshots/snapshot2.png b/art/CyberCity-MelonMars/snapshots/snapshot2.png new file mode 100644 index 000000000..95676c29c Binary files /dev/null and b/art/CyberCity-MelonMars/snapshots/snapshot2.png differ diff --git a/art/CyberCity-MelonMars/snapshots/snapshot3.png b/art/CyberCity-MelonMars/snapshots/snapshot3.png new file mode 100644 index 000000000..eab38606d Binary files /dev/null and b/art/CyberCity-MelonMars/snapshots/snapshot3.png differ