Racey – Score from Collision

Each time the car collides with an instance of the array of obstacles we remove that instance from the array.

At the same time we want to add one to the score variable

In order to do that we need to pass the score variable to the Coll function and return the score at the end of the function

Add the score variable to the function declaration

def coll(self, car_rect, score):

Then add one to the score variable once we remove the instance from the array

score += 1

At then end of the Coll function we want to return the score value

return score

Finally we need to modify the code where we call the Coll function so that we set the score variable to the returned value from the function and send the score variable to the function.

Change the function call to

score = dog.coll(carRect, score)