problem with if statements
in
Programming Questions
•
11 months ago
Hi guys,
i got a problem. i need a game sort of qual to snake. and i have my triangle and moving. but i use that in the draw.
so i need the balls to be in the void draw too. but if i give them a random they keep moving. if i declare it globally outside the voids. it starts with one position and thats good. but i want to go over the ball with the triangle and then it needs to dissappear and appear somewhere random on the screen. and let that dissappear again if I go over it with the triangle.
it also needs to fit in little squares of 40. so the triangle fits perfectly over the balls.
I already tried something but that didnt work out.
hope you guys can help me out.
here is my try:
- int ballPos = round(random(0,amountOfSquares-1)) * SquareSize
- boolean grab = false;
- if(positionXTriangle == ballPos && positionYTriangle == ballPos && grab == false){
- grab = true;
- }
- if(grab == false){
- ellipse(ballPos,ballPos,40,40);
- }
- if(grab == true){
- ellipse(random(0,width),random(0,height),40,40);
- grab = false;
- }
1