Context
I’m making a Touhou-style bullet he’ll game. Bosses in this game will have a list of distinct patterns they will throw at the player, and will move on to the next pattern once the player has dealt enough damage.
I want to use inheritance to implement this, I’ll have a base Attack class which holds helper methods, alongside one empty method which will contain the actual attack logic that the subclasses will implement.
The Question
Which option should I pick for implementing this?
-
Call the attack logic function once in a new thread when the attack is to start. Thread sleep can be used for timing. The attack logic will contain its own loops and keep the thread running until the main thread stops it when the attack is defeated.
-
Call the attack function every frame, and keep track of the lifetime of the attack for timing everything.
1 allows for more intuitive timing implementation for parts of the attack, but risks some concurrency issues and bugs with pausing the game. Also call deferred needs to be used for most things, which makes bulk-processing of bullet movement tricky.
2 is annoying for getting the timing to work, but lacks the concurrency issues, will be synced to the games physics framerate, and is able to handle bulk bullet movement (handling movement inside the attack script instead of physics process in each bullet node)
I’m leaning towards 2, but I’d love to hear more opinions on this!