xxxxxxxxxx
// Pretty Bad North (by Gabrz)
// https://github.com/Gabrz/PrettyBadNorth
// 3D Island generation using the Wave Function Collapse Algorithm
// Built after watching streams of The Coding Train (Choo Choo).
// It's not perfect, but I had a lot of fun building it.
// TODO:
// - Come up with a better weight system.
// (based on Axis? instead of just some random numbers because they work)
// - Come up with a alternative propegate function
// (curently getting a Max call stack error when DIM > 15)
// - Fiddle around with adjacencies.
// (box next to air)
// - Make new Meshes.
// (corner that is not a slope)
// - Convert box to Geometry with vertices.
// (so top and side can have separate colors)
// - Refactor the gui.
// (more structured)
// -
const WIDTH = 600;
const HEIGHT = 400;
const DIM = 13;
const SIZE = 50;
var cam;
var gui = {};
var modules = {};
var grid;
var sinWater = 0.0;
var startWave = false;
function setup() {
createCanvas(WIDTH, HEIGHT, WEBGL);
// Init Stuff
initGui();
initModules();
// Start
startOver();
}
function draw() {
angleMode(DEGREES);
background(220);
// Draw Stuff
drawLight();
drawGui();
grid.draw();
// Start the Wave
if (startWave) for (var i = 0; i <= gui.speed; i++) grid.startWave();
}
function startOver() {
// Create Grid and set Slots
grid = new Grid(gui.dim, SIZE);
grid.setupStartGrid();
startWave = true;
}
function drawLight() {
ambientLight(50);
normalMaterial();
directionalLight(240, 240, 240, 0, 0, -350);
}