Object dynamics should not depend on their respective visual representation. Hence, when creating the object, pass the visualization (called image, being a pygame.Surface object) to the object constructor (see "Dependency Injection Design Pattern").
Changes
make image constructor arguments of the object classes
read dimensions via image.get_rect() to avoid redundant size information
tests on Rocket to verify that it keeps parent functionality (could be harmed by bad __init__ calls)
Description
Object dynamics should not depend on their respective visual representation. Hence, when creating the object, pass the visualization (called
image
, being apygame.Surface
object) to the object constructor (see "Dependency Injection Design Pattern").Changes
image
constructor arguments of the object classesimage.get_rect()
to avoid redundant size informationRocket
to verify that it keeps parent functionality (could be harmed by bad__init__
calls)How to Test
main.py