Hey Processing Forum,
I am working on a simple code that is supposed to look at where a user clicked and return a True or False for a function. Later on I want to use an IF statement to determine if my function has returned True or False and act accordingly.
astroid_spawn = True
rndXpos = 100
rndYpos = 100
grow = 30
strScore = "0"
score = 0
def inside_astroid(x, y, ast_x, ast_y, ast_size):
# ast_size - Diameter of the asteroid
x = mouseX
y = mouseY
fill(255, 0, 0)
ellipse(ast_x, ast_y, ast_size, ast_size)
if ((x > (ast_x - (ast_size/2))) and (x < (ast_x + (ast_size/2))))and((y > (ast_y - (ast_size/2)))and(y < (ast_y + (ast_size/2)))):
return True
else:
return False
def setup():
size (400, 400)
background(0, 0, 0)
return
def draw():
global rndXpos, rndYpos, grow, strScore, astroid_spawn
inside_astroid(mouseX, mouseY, 300, 300, grow)
def mouseClicked():
global rndXpos, rndYpos, grow, strScore, score
if inside_astroid(mouseX, mouseY, rndXpos, rndYpos, grow) == True:
print("This is Working")
else:
return
The Problem I am having, is that in mouseClicked the
if inside_astroid(mouseX, mouseY, rndXpos, rndYpos, grow) == True:
not only returns true, but it also draws an ellipse on the canvas. (Something I don’t want)
All I want is to check if the function has returned true. Is there a way to check if a function has returned true or did I setup def inside_astroid(x, y, ast_x, ast_y, ast_size): incorrectly?