Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

that is a Processing program... the question is asking Most useful module is con

ID: 3839257 • Letter: T

Question

that is a Processing program...

the question is asking

Most useful module is conditionals and function

Have Fizzy bounce as she hits a wall. Fizzy will always bounce back in the opposite direction she was travelling. When Fizzy reaches a wall, she will change her direction of movement and she will change the direction she is pointing as well. One quarter of the marks for this section are for changing direction of movement, another quarter for changing the direction she is pointing. Fizzy must always point the direction that she is moving if you are to get these marks. An example will be posted in the class forums.

The second half of the marks for this part are for having Fizzy respond to user input as well. When the user presses 'w', Fizzy should turn and move up, 'a' will make Fizzy turn and move left, 's' will turn fizzy to face down the screen and 'd' will make Fizzy move right. Thus Fizzy will now be able to move in four separate directions controlled by the 'w', 's', 'a', and 'd' keys.

That is the program i wrote...it just cannot bounce back by the window... idk y... can u fix it for me..

also idk how to rotate the Fizzy when it hit the wall..

int posX=450; //<>//
int posY=450; //<>//
int velX=5; //<>//
int velY=5; //<>//
int directionX;
int directionY;
int x,y,z;


void setup(){
size(810,810);
  
}
void draw(){
  
background(0);
drawPoles(0,0);
ellipse(posX+velX,posY+velY,40,40); //<>//
fizzMovement();




if((velX+posX)>width){
velX=-velX;

}else if((velX+posX)<0){
velX=-velX;

}else if((velY+posY)<0){
velY=-velY;

}else if((velY+posY*directionY)>height){
velY=-velY;

}}
void keyPressed(){
fizzMovement();
}
void fizzMovement(){
if(key=='w'){
posY-=2
;
}else if(key=='s'){
posY+=2;
}else if(key=='a'){
posX-=2;
} else if(key=='d'){
posX+=2;}}

void drawFizz(){
}
void drawPoles(int i,int u){
fill(255);
for(i=1;i<9;i++){
for(u=1;u<9;u++){

ellipse(i+i*90,u+u*90,10,10);
}}
}

Explanation / Answer

int posX=450; //<>//
int posY=450; //<>//
int velX=5; //<>//
int velY=5; //<>//
int directionX;
int directionY;
int x,y,z;


void setup(){
size(810,810);
  
}
void draw(){
  
background(0);
drawPoles(0,0);
ellipse(posX+velX,posY+velY,40,40); //<>//
fizzMovement();




if((velX+posX)>width){
velX=-velX;

}else if((velX+posX)<0){
velX=-velX;

}else if((velY+posY)<0){
velY=-velY;

}else if((velY+posY*directionY)>height){
velY=-velY;

}}
void keyPressed(){
fizzMovement();
}
void fizzMovement(){
if(key=='w'){
posY-=2
;
}else if(key=='s'){
posY+=2;
}else if(key=='a'){
posX-=2;
} else if(key=='d'){
posX+=2;}}

void drawFizz(){
}
void drawPoles(int i,int u){
fill(255);
for(i=1;i<9;i++){
for(u=1;u<9;u++){

ellipse(i+i*90,u+u*90,10,10);
}}
}