float x=250;
float y=250;
float speed=3;
float gravity=0.1;
float Xspeed=0;
float Yspeed=0;
float XYspeed;
float XYangle;
boolean time = true;
void setup() {
size(500, 500);
stroke(255, 255, 255);
}
int line1;
float line1angle=asin(-height*0.4/width);
int line2;
/*void option(int a, int b) {
fill (255, 255, 255);
square(a, b, 10);
text("Time", a+15, b+10);
if (mousePressed() && mouseX >= a && mouseX <= a+10 && mouseY >= a && mouseY <=
a+10) {
fill (100, 100, 100);
square(a, b, 10);
}
}*/
void draw() {
background(0);
//option(10, 10);
line(0, height/2, width, height*0.9);
line1 = round((height*0.4/width)*(x)+height/2);
//line(0, height, width, height/2);
circle(x, y, 10);
if (time == true) {
y=y-Yspeed;
Yspeed=Yspeed-gravity;
x=x-Xspeed;
}
XYspeed = sqrt(pow(Xspeed, 2) + pow(Yspeed, 2));
XYangle = asin(Xspeed/XYspeed);
if (y > line1-10) {
Xspeed = (XYspeed*sin(line1angle + XYangle));
Yspeed = (XYspeed*cos(line1angle + XYangle));
}
if (y <= 0) {
Yspeed = -Yspeed;
y = 0;
}
if (x <= 0 || x >= width) {
Xspeed = -Xspeed;
x = constrain(x, 0, width);
}
}