xxxxxxxxxx
43
/*
Cats
by pbay
*/
let r = 50
let t = 0
let canvas;
let intro;
let coordinates;
let typeButton;
let num = 0;
function setup() {
intro = createP("Say hello to my spinning " + types[num] + " cat! Below are the " + types[num] + "'s coordinates.");
canvas = createCanvas(100, 150);
coordinates = createP("(" + Math.floor(r * cos(t)) + ", " + Math.floor(r * sin(t)) + ")");
typeButton = createButton("Change this cat!")
typeButton.mousePressed(changeType);
}
function changeType() {
if (num < types.length - 1) {
num++
} else {
num = 0
}
}
function draw() {
clear();
cat(50, 100, 100, types[num]);
canvas.position(r * cos(t) + 100, r * sin(t) + 200);
t += 0.01
coordinates.html("(" + Math.floor(r * cos(t)) + ", " + Math.floor(r * sin(t)) + ")");
intro.html("Say hello to my spinning " + types[num] + " cat! Below are the " + types[num] + " cat's coordinates.");
}