xxxxxxxxxx
45
// define global array of Muybridge's 1878 Horse in Motion images
let imgArray = ["horse01.png", "horse02.png", "horse03.png", "horse04.png", "horse05.png", "horse06.png", "horse07.png", "horse08.png", "horse09.png", "horse10.png", "horse11.png", ]
// define global empty array
let hArr = []
// define global variables
let sky;
let angle=0
function preload() {
// preload images into empty array
for(i=0;i<imgArray.length;i++){
hArr[i]=loadImage(imgArray[i])
}
sky = loadImage("SkyClouds.jpg")
}
function setup() {
createCanvas(600,300)
// mimic frame rate of film
frameRate(24)
}
function draw() {
// background image
image(sky,0,0)
translate(0-40,height/2-15)
offy = 0
// for each horse in motion image
for(m=0; m<hArr.length; m++){
y = sin(angle+offy)*100
// if counter within valid counter range
if(m>=0 && m<=hArr.length-1){
//make bouncy horses :D
image(hArr[round(m)],m*55,y,hArr[0].width/2,hArr[0].height/2);
}
offy+=0.1
}
angle +=0.04
}