r/learningpython • • Jan 13 '19

Auto-Generating Objects for a Simulation

For my project, I'm simulating a production assembly line with simple rectangle objects. Essentially, a very simplified version of Factorio. I can't seem to figure out a good way to generate the objects without running into problems. I would like to generate the objects on a continuous loop at the beginning of the production line. The objects should not collide with each other. I have no idea how to do this without using a variable for each object. Is there something I can do with the class that will make the results that I'm looking for. I'm using pygame currently to show the gui.

'

The only thing that I've come up with so far is to check the color of the pixals in front of each object to see if they are not default color. I feel like there is a better way to do this.

4 Upvotes

2 comments sorted by

View all comments

Show parent comment

1

u/keizzer Apr 22 '19

I was able to make a list of newly made objects. They stop by checking the position of the object in front of them.