xxxxxxxxxx
20
function setup() {
createCanvas(400, 400);
// Create two sprites
var sprite1 = new Sprite(0, 0, 100, 100);
var sprite2 = new Sprite(200, 200, 100, 100);
// Create a function to rate the sprites
function rateSprites() {
// Get the distance between the sprites
var distance = dist(sprite1.x, sprite1.y, sprite2.x, sprite2.y);
// Return a number between 0 and 1 based on the distance
return 1 - distance / 400;
}
// Draw the sprites
sprite1.draw();
sprite2.draw();
// Draw the rating between the sprites
fill(255);
text(rateSprites(), 100, 100);
}