bouncing_box.utilities module

The Utilities module is a set of functions that have no specific class. These functions can be used when needed and are best separate for reusability.

loadScores()

A function load in the scores from scores.txt.

Returns

An int array of the scores

Return type

list

rectRectIntersection(rect1Pos, rect1Dim, rect2Pos, rect2Dim)

A function to test for if two rectangles intersect.

Parameters
  • rect1Pos (class:pygame.math.Vector2) – The position of the first rectangle.

  • rect1Dim (class:pygame.math.Vector2) – The dimensions of the first rectangle.

  • rect2Pos (class:pygame.math.Vector2) – The position of the second rectangle.

  • rect2Dim (class:pygame.math.Vector2) – The dimensions of the second rectangle.

Returns

A True/False value for if the two rectangles intersect.

Return type

bool

saveScores(scores)

A function write the scores to scores.txt.

Parameters

scores (list) – The int array of the scores

sortScores(latestScore)

A function sorts the scores and the latest score into the correct order and removes the lowest score.

Parameters

latestScore (int) – The latest score