adding score when clicking inside rectangle
<p>I have the following exercise to do for school:</p>

<p>Create a textfield which shows a score as follows "Score: " (You can use the text(StringValue, IntegerXposition, IntegerYposition) for the drawing of text), starting at zero.
Make it so that when the user clicks the left mouseButton a score of 10 is added to the result.</p>

<p>Create a rectangle on screen and make it so that when the user clicks inside the rectangle, a score of 20 is added to the score value.</p>

<p>I have done the first part but don't know how to add a score of 20 when clicking inside the rectangle. This is the code i have so far.</p>

<pre><code>def setup():
    global Score, xPos, yPos
    size(800,800)
    textSize(30)
    Score= 0
    xPos= 200
    yPos= 200

def draw():
    global Score, xPos, yPos
    background(51)
    rect(xPos,yPos,100,100)
    text("Score: ", 50, 50)
    text(Score, 150, 50)    


def mousePressed():
    global Score, xPos, yPos
    if (mouseButton == LEFT):
        Score= Score + 10
</code></pre>

<p>Just check the position of the mouse pointer when there is a click.</p>

<p>I don't know what library you are using, but just replace <code>mouseX</code> and <code>mouseY</code> with the actual variable names.</p>

<pre><code>def mousePressed():
    global Score, xPos, yPos
    if mouseButton == LEFT and xPos &lt; mouseX &lt; xPos+100 and yPos &lt; mouseY &lt; yPos+100:
        Score= Score + 10
</code></pre>

python python-3.x