To better organize my code, I tried to create a constants class:
class Constants:
def __init__(self):
Constants.SCREEN_WIDTH = 1500
Constants.SCREEN_HEIGHT = 800
Constants.WINDOW_COLOR = (100, 100, 100)
Constants.TICKRATE = 60
Constants.GAME_SPEED = .35
Constants.LINE_COLOR = (0, 0, 255)
Constants.ALINE_COLOR = (0, 0, 0)
Constants.BARRIER = 1
Constants.BOUNCE_FUZZ = 0
Constants.START_X = int(.5 * Constants.SCREEN_WIDTH)
Constants.START_Y = int(.99 * Constants.SCREEN_HEIGHT)
Constants.AIR_DRAG = .3
When I try to call one of the constants, such as on this line:
ball = Ball(Constants.START_X, Constants.START_Y)
I get this error: AttributeError: type object 'Constants' has no attribute 'START_X'
What am I doing wrong?