xxxxxxxxxx
//HAVE NOT TESTED W SOUND (!!)
// the image sequence
let animationFrames = [];
let frameToShow = 0; // index drawn element to show
//!!let soundFiles = [];
//!!let soundToPlay = 0; // index of sound
let initialFrameRate = 1; // starting frame rate
let currentFrameRate = initialFrameRate; // current frame rate
function preload() {
// load all the images
animationFrames[0] = loadImage("1.png");
animationFrames[1] = loadImage("2.png");
animationFrames[2] = loadImage("3.png");
animationFrames[3] = loadImage("4.png");
animationFrames[4] = loadImage("5.png");
animationFrames[5] = loadImage("6.png");
animationFrames[6] = loadImage("7.png");
animationFrames[7] = loadImage("8.png");
//load the sounds!!
//soundFiles[0] = loadSound("___.wav");
}
function setup() {
createCanvas(2550, 2100);
frameRate(currentFrameRate); // Set initial frame rate
}
function draw() {
background(160);
//console updates
print(currentFrameRate);
print(frameToShow);
//!!print(soundToShow);
print(" ");
// Draw the current frame of the animation
image(animationFrames[frameToShow], 0, 0);
//!!soundFiles[soundToPlay].play();
// Update the frame index based on the frame rate
if (frameCount % 1 === 0) {
// Move to the next frame in the array
frameToShow = (frameToShow + 1) % animationFrames.length;
//!!soundToPlay = (soundToPlay + 1) % soundFiles.length;
}
// Speed up the animation over time (gradually increase the frame rate)
currentFrameRate += 0.05; // Gradually increase frame rate to speed up the animation
frameRate(currentFrameRate); // Update the frame rate
}
function mousePressed(){
if (mouseButton === LEFT) {
console.log("Left mouse clicked!");
currentFrameRate = max(currentFrameRate - 0.1, 1); // Decrease speed (but not below 1 FPS)
} else if (mouseButton === RIGHT) {
console.log("Right mouse clicked!");
currentFrameRate = 0; // Freeze
}
else if (mouseButton === CENTER) {
console.log("Center mouse clicked!");
currentFrameRate = initialFrameRate;
}
}