(Many flashing colors - seizure warning). Use interface. Click circular refresh button if music does not play
A fork of Through Sound&Space(Many flashing colors - seizure warning) by Joe DeNavas (DD89)
xxxxxxxxxx
//HUGE thanks to discord user Bazul for helping me workout rocket alignment issues and to discord user
//Metamere for his advice on how to increase efficency and memory problems!
//song from https://pixabay.com/music/future-bass-showreel-99195/
//song3.mp3 from https://pixabay.com/music/beats-electronic-rock-king-around-here-15045/
//info on rocket ship
//license:https://creativecommons.org/licenses/by/4.0/
//credit to: Rafa Andrade
//link:https://sketchfab.com/3d-models/rocket-36ac04d6203545b1baf56c4cbf89349b
//changes made:thruster added
//song from https://pixabay.com/music/future-bass-showreel-99195/
//info on plane
//from https://sketchfab.com/3d-models/plane-bf45745e7c2b4abc8d013bfca29d52df
//license:https://creativecommons.org/licenses/by/4.0/
//changes made:thruster added
//info on ufo
//https://sketchfab.com/3d-models/ufospaceship-77a99a30b7eb42a3b7017dd97e5885b1
//license:https://creativecommons.org/licenses/by/4.0/
//changes made:thruster added
// code with "//Source: Shiffman" is taken from:
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Code from: https://youtu.be/NCCHQwNAN6Y
p5.disableFriendlyErrors = true;
soundfixer=false
let counter3=0
let sound1going=false
let a=0
let counter2=0
let countme=0
let goback=false
let counter=0
var diam =1
var song;//Source: Shiffman
var button;//Source: Shiffman
var amp;//Source: Shiffman
function preload()
{
soundFormats('mp3', "wav");
song = loadSound('song1.mp3'); //load song
song2 = loadSound('song3.mp3'); //load song
}
function setup()
{
OPC.slider('vehicle', 0,0,2);
OPC.slider('Song', 0,0,1);
OPC.slider('Cam_Distance', 500,0,1350);
OPC.slider('Cam_Speed', 10,0,80);
OPC.slider('Space_Objs', 2000,0,5000);
OPC.slider('Objs_Length', .8,0,10);
OPC.slider('Mode', 2,0,2);
OPC.toggle('Vehicle_React', false);
OPC.toggle('I_SAID_WARP_SPEED', false);
OPC.toggle('screenshot', false);
createCanvas(windowWidth, windowWidth*.75, WEBGL)
rocket = loadModel('rocket2.obj', true); //loads obj file of rocket
ufo = loadModel('ufo.obj', true); //loads obj file of ufo
plan = loadModel('plane.obj', true); //loads obj file of plane
song.loop()
song2.loop()
amp = new p5.Amplitude();//Source: Shiffman
}
function draw()
{
// OPC toggle made to work like a momentary switch (similar to a button)
if (screenshot){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
screenshot = false; // shut off toggle so the action is non-latching
}
if(Song==0 &sound1going==false)
{
song.play()
song2.stop()
sound1going=true
}
else if(Song==1 & sound1going==true)
{
song.stop()
song2.play()
sound1going=false
}
if(soundfixer==false) //without this song/song1.mp3 echos or plays twice at start of program
{
song.stop()
sound1going=false
soundfixer=true
}
if(diam<=25) frameRate(25/4)
else frameRate(diam/4)
counter3++
if (countme>Cam_Distance) goback=true //this code is used for camera movement
if (countme<-Cam_Distance) goback=false
if(goback==true) countme=countme-Cam_Speed
if(goback==false) countme=countme+Cam_Speed //end camera movement code
if(round(Mode)==0) background(random(255),random(255),random(255))
else if(round(Mode)==1) background(random(255))
else if(round(Mode)==2) background(random(20))
if(I_SAID_WARP_SPEED==true)
{
let choice=round(random(1))
Vehicle_React=choice
let choice2=round(random(1))
Mode=round(random(2))
Objs_Length=round(random(10))
Space_Objs=round(random(3000))
Cam_Speed=round(random(80))
Cam_Distance=round(random(1350))
if(counter3%5==0)
{
push() //rocket
translate(random(-100,100), random(-300,40),random(-100,100));
rotateZ(1);
rotateX(3);
rotateY(5+a);
if(Vehicle_React==true) scale(1.5*(diam/55))
else scale(3)
stroke(random(100))
if(vehicle==1)
{
model(ufo)
}
else if(vehicle==2)
{
rotateZ(76/10)
model(plan)
rotateZ(866/10)
// translate((-74/10),-85-14,5)
}
else model(rocket)
stroke(0)
translate(0,-85-404,-6); //thrusts
if(round(Mode)==0) fill("yellow")
else if(round(Mode)==1) fill(random(100))
else if(round(Mode)==2) fill(random(150,255))
box(random(15),diam+random(1000),random(16))
translate(0,5-14,-1);
if(round(Mode)==0) fill("red")
else if(round(Mode)==1) fill(random(30))
else if(round(Mode)==2) fill(random(150,255))
box(random(15),diam+random(-5,1000),random(20))
translate(0,5-14,+2);
if(round(Mode)==0) fill("yellow")
else if(round(Mode)==1) fill(random(100))
else if(round(Mode)==2) fill(random(150,255))
box(random(15),diam+random(1000),random(16))
translate(0,5-14,-5);
if(round(Mode)==0) fill("red")
else if(round(Mode)==1) fill(random(30))
else if(round(Mode)==2) fill(random(150,255))
box(random(15),diam+random(1000),random(20))
pop()
}
}
a=a+.03 //rotation speed
for(i=0;i<Space_Objs;i++)
{
x=random(-20,10)
y=random(-4,6)
z=random(-15,15)
push()
strokeWeight(1)
rotateZ(1);
rotateX(3);
translate(random(-100,100)-750+x*200, random(-100,100)+ (y*200), 150+z*50)
if(round(Mode)==0) fill(random(255),random(255),random(255))
else if(round(Mode)==1) fill(random(255))
else if(round(Mode)==2) fill(random(150,255))
box(3,diam*Objs_Length,3)
pop();
}
push()
strokeWeight(1)
rotateZ(1);
rotateX(3);
translate(50, -100,-800);
if(counter3%5000)
{
if(round(Mode)==0) fill(random(255),random(255),random(255))
else if(round(Mode)==1) fill(random(255))
else if(round(Mode)==2) fill(random(20))
}
box(random(40000),random(40000),1)
pop();
push() //rocket
translate(50, -100,50);
rotateZ(1);
rotateX(3);
rotateY(5+a);
if(Vehicle_React==true) scale(1.5*(diam/55))
else scale(3)
if(vehicle==1)
{
scale(.5)
model(ufo)
}
else if(vehicle==2)
{
rotateZ(76/10)
model(plan)
rotateZ(866/10)
translate((-74/10),-85-14,5)
}
else model(rocket)
if(I_SAID_WARP_SPEED==true) translate(0,-85-404,-6);
else translate(0,-85-14,-6); //thrusts
if(round(Mode)==0) fill("yellow")
else if(round(Mode)==1) fill(random(100))
else if(round(Mode)==2) fill(random(150,255))
box(random(15),diam+random(35),random(16))
translate(0,5-14,-1);
if(round(Mode)==0) fill("red")
else if(round(Mode)==1) fill(random(30))
else if(round(Mode)==2) fill(random(150,255))
if(I_SAID_WARP_SPEED==true) box(random(15),diam+random(-5,1000),random(20))
else box(random(15),diam+random(-5,30),random(20))
translate(0,5-14,+2);
if(round(Mode)==0) fill("yellow")
else if(round(Mode)==1) fill(random(100))
else if(round(Mode)==2) fill(random(150,255))
if(I_SAID_WARP_SPEED==true) box(random(15),diam+random(1000),random(16))
else box(random(15),diam+random(10),random(16))
translate(0,5-14,-5);
if(round(Mode)==0) fill("red")
else if(round(Mode)==1) fill(random(30))
else if(round(Mode)==2) fill(random(150,255))
if(I_SAID_WARP_SPEED==true) box(random(15),diam+random(1000),random(20))
else box(random(15),diam+random(30),random(20))
if(I_SAID_WARP_SPEED==true)
{
translate(0,300,-5);
stroke(random(255))
cone(100,random(300))
translate(0,-200,-5);
if(round(Mode)==0) fill("yellow")
else if(round(Mode)==1) fill(random(100))
else if(round(Mode)==2) fill(random(150,255))
cone(random(500),random(300))
}
pop()
counter2=counter2-5
camera(50+countme, -100,-500,50, -100,50, 0, 1, 0)
var vol = amp.getLevel();//Source: Shiffman
diam = map(vol, 0, 0.3, 10, 200);//Source: Shiffman makes "diam" / songs volume range from a value 10 to 200 every frame
}