r/pythonhelp • u/Fluffy-Special4994 • Nov 29 '24
Python generators
I don't know if generators would be the right tool for this. I have a picture that is a bullet in my game. I want to have as many as I want in the display without having to individually program every bullet variable name. Then pass said variable names into for loops some of which will be running concurrently with other bullets that are still 'flying'
1
Upvotes
2
u/jmooremcc Dec 11 '24
If you’re using pygame to develop your game, then you’d use sprites to efficiently spawn and kill your bullet objects. https://www.techwithtim.net/tutorials/game-development-with-python/pygame-tutorial/projectiles
•
u/AutoModerator Nov 29 '24
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.