var pause = false; var drawing = true; var doing = false; var x1, y1; function setup() { createCanvas(1920, 850); background(51); frameRate(144); walls = []; var checkbox; var drawingbox; player = new Player(createVector(400, 450)); preview = new Wall(100,100,200,200); level = new Map(); checkbox = createCheckbox('pause', false); drawingbox = createCheckbox('drawing', true); checkbox.changed(pauseCheck); drawingbox.changed(drawCheck); sightSlider = createSlider(1, 100, 100); fovSlider = createSlider(1, 360, 90); velocitySlider = createSlider(1, 10, 3); rotationSpeedSlider = createSlider(1, 10, 1); } function draw() { clear(); background(51); if (!pause) { if (!drawing) { background(51); level.show(); player.update(); player.show(); } else { if (doing === true) { preview = new Wall(x1, y1,mouseX, mouseY); preview.show(); } } } for (let w of walls) { w.show(); } } function mouseClicked() { if (drawing && mouseY <= 850) { if (doing === false) { doing = true; x1 = mouseX; y1 = mouseY; } else { walls.push(new Wall(x1, y1, mouseX, mouseY)); doing = false; } } } function pauseCheck() { if (this.checked()) { //console.log('Checking!'); pause = true; } else { //console.log('Unchecking!'); pause = false; } } function drawCheck() { if (this.checked()) { //console.log('Checking!'); drawing = true; } else { //console.log('Unchecking!'); drawing = false; } } class Map { constructor() {}; show() { for (let w of walls) { w.show(); } } }