Question: Hi everybody, I am new to processing language programming (Processing 3), I have an example of bouncing the ball and when executing the program the

Hi everybody, I am new to processing language programming (Processing 3), I have an example of bouncing the ball and when executing the program the system gave me (sometimes) wrong directions as output: Ex. if xmove = 1and ymove =1the default direction = south_East , I want to add a statement to check x_move and y_move to print the directions correctly. Thanks

the code :

// initial position for our circle

float circle_x = 300;

float circle_y = 20;

// how much to move the circle on each frame float move_x = 2;

float move_y = -2;

void setup() {

size(400, 200);

stroke(#D60DFF);

strokeWeight(7);

}

void draw() {

background(#21EA73);

ellipse(circle_x, circle_y, 40, 40);

circle_x = circle_x + move_x;

circle_y = circle_y + move_y;

if(circle_x > width) {

circle_x = width;

move_x = -move_x;

println(" north_east");

}

if(circle_y > height) {

circle_y = height;

move_y = -move_y;

println(" south_west");

}

if(circle_x < 0) {

circle_x = 0;

move_x = -move_x;

println(" north_west");

}

if(circle_y < 0) {

circle_y = 0;

move_y = -move_y;

println(" south_east");

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!