Let's say I have a hypothetical program or game with class Car and I want to create a new car object any time players e.g click mouse. In folowing example we create newCarNrI
; I want be able to create : newCarNr1, newCarNr2, newCarNr3, newCarNr4, newCarNr5
on every click.
import pygame
class Car:
def __init__(self,name):
self.name = name
def main():
#pygame initialisation and logic and stuff ...
#game Loop
while True:
click = pygame.mouse.get_pressed()
if click[0] == 1:
# Create new Car object when click
newCarNrI = Car(aCarName)
if __name__ = '__mian__':
main()
Is it possible? How to do it?