Animation(String imagePrefix, int count) {
images = new PImage[imageCount];
for (int i = 0; i < imageCount; i++) {
String filename = imagePrefix + "_" + nf(i, 1) + ".png";
images[i] = loadImage(filename);
void display(float xpos, float ypos) {
frame = (frame+1) % imageCount;
image(images[frame], xpos, ypos);
int offsetA, offsetB, yOffset, speed;
ScrollingImage(PImage i, int y, int s) {
image(image, offsetA, yOffset);
image(image, offsetB, yOffset);
if(offsetA == -image.width) {
if(offsetB == -image.width) {
PImage player_standing, path, greens, mountains;
Animation player_running, monster;
ScrollingImage scrolling_path, scrolling_greens, scrolling_mountains;
player_running = new Animation("Running", 6);
monster = new Animation("Monster", 6);
player_standing = loadImage("Standing.png");
path = loadImage("Path.png");
greens = loadImage("Greens.png");
mountains = loadImage("Mountains.png");
scrolling_path = new ScrollingImage(path, 311, 0);
scrolling_greens = new ScrollingImage(greens, 222, 0);
scrolling_mountains = new ScrollingImage(mountains, 0, 0);
scrolling_mountains.draw();
monster.display(100, 328);
player_running.display(370,220);
scrolling_mountains.speed = 4;
scrolling_greens.speed = 8;
scrolling_path.speed = 16;
image(player_standing, 370, 220);
scrolling_mountains.speed = 0;
scrolling_greens.speed = 0;
scrolling_path.speed = 0;