Cannot convert float to boolean error
in
Programming Questions
•
2 years ago
I'm trying to make a bouncing ball change colours whe it hits a wall it will bounce off, however I keep encountering an error that reports "Cannot convert float to boolean". I just can not see what the error is refering too.
- float shapesize, xPos, yPos, xSpeed, ySpeed, xDirection, yDirection, fGreen, fBlue, fRed;
- void setup()
{
size(640, 640);
frameRate(30);
smooth();
strokeWeight(5);
xPos = width/2;
yPos = height/2;
xSpeed = 5;
ySpeed = 4;
xDirection = 1;
yDirection = 1;
fRed = 255;
fBlue = 255;
fGreen = 255;
if (width >= height)
{
shapesize = height/15;
}
else
{
shapesize = width/15;
}
} - void draw ()
{
background (80, 50, 80);
xPos = xPos + (xSpeed * xDirection);
yPos = yPos + (ySpeed * yDirection);
if (xPos > (width/10)*9-shapesize || xPos < width/10)
{
xDirection = xDirection * -1;
}
if (yPos > (height/10)*9-shapesize || yPos < height/10)
{
yDirection = yDirection * -1;
}
if (xPos > width/10 + shapesize/2 & yPos > height/10 + shapesize/2 || xPos < width/9 - shapesize/2 & yPos < height /9 - shapesize/2)
{
fRed = 255;
fBlue = 255;
fGreen = 255;
}
else if (xPos = width/10 + shapesize)
{
fRed = 255;
fGreen = 0;
fBlue = 0;
}
else if (yPos = height/10 + shapesize)
{
fRed = 0;
fGreen = 0;
fBlue = 255;
}
else if (xPos = width/9 - shapesize)
{
fRed = 0;
fGreen = 255;
fBlue = 0;
}
else if ( yPos = height/9 - shapesize)
{
fRed = 255;
fGreen = 255;
fBlue = 0;
}
stroke(0, 0, 0);
fill (fRed, fGreen, fBlue);
ellipse(xPos+shapesize/2, yPos+shapesize/2, shapesize, shapesize);
stroke (255, 0, 0);
line (width/10, height/10, width/10, height/10*9);
stroke (0, 255, 0);
line (width/10*9, height/10, width/10*9, height/10*9);
stroke (0, 0, 255);
line (width/10, height/10, width/10*9, height/10);
stroke (255, 255, 0);
line (width/10, height/10*9, width/10*9, height/10*9);
}
How can i go about fixing this error?
1