xxxxxxxxxx
81
var loft;
let cat;
function kill_loft(){
loftexists=false;
}
var loftexists=true;
function loftpreload(){
cat=loadSound("sounds/cat.wav");
}
function loftsetup(){
loft=createElement("div","<img onclick='kill_loft()' id='loft' src='https://hotdaniel83.nekoweb.org/images/cat.jpeg' width='31' height='31'>");
cat.play();
}
var loftx=0;
var lofty=0;
var llx=0;
var lx=0;
var lly=0;
var ly=0;
var sfxrefresh=0;
var pitch=0;
function loftnoises(){
llx=lx;
lly=ly;
lx=loftx;
ly=lofty;
pitch=(((llx-lx)+(lly-ly))/2)/3;
if(pitch<0){
pitch=pitch*-1;
}
}
function chat(pitch){
if(pitch!=0){
cat.stop();
//console.log(pitch);
cat.play(0,pitch,0.5);
}
}
function loftm(){
sfxrefresh--;
if(sfxrefresh<0){
if(pitch!=0){
sfxrefresh=25/pitch;
if(sfxrefresh>45){
sfxrefresh=20;
}
}else{
sfxrefresh=20;
}
chat(pitch);
}
}
function loftframe(){
if(loftexists){
loftx+=(((mouseX+scrollX)-15.5)-loftx)/4;
lofty+=(((mouseY+scrollY)-15.5)-lofty)/4;
loftnoises();
loftm();
}
if(!loftexists){
if(loftx-32){
loftx--;
}
}
loft.position(loftx,lofty);
}
function preload(){
loftpreload();
}
function setup() {
loftsetup();
}
function draw() {
loftframe();
}