I need to write a program so that a ball rises upwards and once it hits the top the ellipse is replaced by a image.
The ball needs to be no longer visible.
The message "cannot convert Pimage to float" appears I run the program.
// Convenient colors color orange = color(255, 140, 0); color white = color(255, 255, 255);
float y; // y is vertical position of ball float r; // r is radius of ball
// Image of fish PImage fish;
void setup() { size(500, 500); smooth(); frameRate(70); y = 450; // the ball starts near bottom of screen r = 25; // the ball has radius of 25 }
void draw() { // re-draw white background background(white); // draw ball noStroke(); fill(orange); ellipse(250, y, r * 2, r * 2); // substract 1 to y to make ball move upwards y -= 1; if (y - r <= 0) { //uh oh: the ball has gone off the edge of screen y = loadImage("fish.png"); // start at bottom again } }
THis is the first assignment we got this year. Can u help me out?
Now write a program that divides the screen canvas into four rectangles on the screen. The point where the four rectangles coincide should follow the mouse, therefore resizing the rectangles as the mouse is moved. When the user clicks any mouse button, each rectangle should change to a different random colour. You will need to investigate the use of the
random()
function to achieve this.