Remove a rectangle when a circle overlapps it
in
Programming Questions
•
9 months ago
Hi, guys. I'm new to Processing. I use it to communicate with Arduino and receive messages from serial port.
So I want to make a simple game that responds to buttons on arduino. I know only basic syntax and possibilities of Processing so it's hard for me to do simple things.
And now i'm stuck trying to remove a rectangle when a circle collides with it.
So here is part of my code I'm having problems with
- import processing.serial.*;
- Serial port;
- int X = 250;
- int Y = 250;
- int px,py;
- int PlayerRS=X+50;
- int PlayerLS=X;
- int PlayerT=Y;
- int PlayerB=Y+50;
- void setup()
- {
- size(500,500);
- port = new Serial(this, "COM11", 9600);
- port.bufferUntil('\n');
- rectMode(CENTER);
- background(255);
- smooth();
- px=250;
- }
- void draw()
- {
- background(0);
- //You
- rect(X,Y,50,50);
- enemies();
- }
- void enemies(){
- py=py+4/2;
- ellipse(px, py, 15, 15);
- if(px>=PlayerLS || px<=PlayerRS || py>PlayerT || py<PlayerB){
- //And here I need that rectangle to be removed
- }
- }
1