xxxxxxxxxx
103
/*
Welcome to the "Acuario"!
Please read the instruction clearly below to start playing.
1. Press the ">" button on the very top of the P5.JS interface to run.
2. Press "a" to get into fullscreen mode.
3. Press "ESC" to exit the Fullscreen mode.
4. Press "space" to generate a new setting.
5. Press "r" to pause and reactivate camera rotation.
6. You may check the video here: https://vimeo.com/1050086182/2dde067c6f
7. You could keep it running like watching through a Acuario :)
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0) (https://creativecommons.org/licenses/by-nc-nd/4.0/) that You must give appropriate credit, you may not use the material for commercial purposes. If you remix, transform, or build upon the material (including the code), you may not distribute the modified material.
I own the copyright and all rights reserved forever.
Jia-Rey(Gary) Chang
*/
let song;
let songPlay = false;
let cam;
let newWorld;
let worldX = 4000;
let worldY = 2000;
let worldZ = 2000;
let sepFactor = 5.0;
let aliFactor = 0.5;
let cohFactor = 0.5;
let bloops = [];
let foods = [];
let bloopsNum = 80;
let foodsNum = 40;
let runrun = false;
let rundegrees = 0;
function preload() {
song = loadSound("twinkleRing.mp3");
}
function setup() {
c = createCanvas(window.innerWidth, window.innerHeight, WEBGL);
cam = new Dw.EasyCam(this._renderer, {distance:4000, center:[0,0,0]});
newWorld = new World(bloopsNum, foodsNum);
song.loop();
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
cam.setViewport([0,0,windowWidth,windowHeight]);
}
function draw() {
//background(0);
background(color('#03A9F4'));
noFill();
strokeWeight(5);
stroke(255);
box(worldX + 160, worldY + 160, worldZ + 160);
box(worldX + 200, worldY + 200, worldZ + 200);
newWorld.display();
if(!runrun){
rundegrees=0.001;
}else{
rundegrees=0.0;
}
cam.rotateY(rundegrees);
}
function keyPressed() {
if (key == 'a') {
let fs = fullscreen();
fullscreen(!fs);
}
if (key == ' ') {
foods = []; // Clear foods array
bloops = []; // Clear bloops array
newWorld = new World(bloopsNum, foodsNum);
}
if (key == 'r') {
runrun = !runrun;
}
}