Skip to content

Standards and Conventions

Chad Estioco edited this page Mar 17, 2018 · 7 revisions

For compliance of the rest of the codebase.

Geometric Points

When a method or function requires geometric point as input, take in a tuple so as to make it easily extendable for higher-dimensions.

They will always be specified as (width, height) for sizes or (row, col) for actual coordinates.

An exemption is when the class/method requiring it already makes explicit assumptions on the dimensionality of data.

Drawing Rectangles

To lessen cognitive overload from vanilla PyGame, rectangles are always described as (upper_left_x, upper_left_y, block_width, block_height). Classes which abstract rectangles should provide a way to express/convert the abstractions into this form.

Variable/parameter naming

window refers to a Pygame surface, specifically one returned by pygame.display.set_mode.

screen refers to an instance of components.core.GameScreen.

Returning iterables

If the order of the items does not matter return a set. Otherwise, return a tuple or a list. If modifications are not expected, prefer tuples over lists, especially if it is just a compilation of constant literals; this provides a speed advantage.