Hi everyone,
I've just started fiddling with images in Processing, and I've run into a bit of a problem.
I'd like to have an image bouncing on the screen, with another image as the background. Here's the code so far:
Code:PImage img; //Variable for image file
//x location
float x=150;
//y location
float y=0;
float speed=0;
float gravity=.1;
void setup(){
size(400,400);
smooth();
//Image is from a screenshot of the game Polar Jump
img= loadImage("jumpbear copy.jpg"); }
void draw(){
background(255);
image(img,x,y);
//Add speed to location
y=y+speed;
//Add gravity to speed
speed=speed+gravity;
//If bear reaches bottom, reverse speed
if(y>height-80){
speed=speed*-.95;
}
}
When I tried to add another image--clouds--as the background, I got a lot of errors. The background image shows just fine if it's by itself, like this:
Code:PImage clouds=loadImage("clouds copy.jpg");
size(clouds.width, clouds.height);
background(clouds);
but I get a lot of errors when I try to add the background code to the bouncing bear code, no matter how I place or split up the background code. I'm sure I'm missing something simple, but being new to images, it's hard to tell what it is. Advice would be greatly appreciated.