I’m currently working on a bullet hell style projectile system and trying to figure out the best way to structure it. I want the projectiles to be able to grow in size and follow complex paths.
I’ll use position as an example to explain my naive implementation. Struct path contains two vectors (points) that define the start and end of the bullet’s path, a vector to define how long it’s been alive and how long it should live, and an ArrayList of function pointers. The functions take in the struct and return the point in the function’s curve at that time, which I combine to get the current position of the projectile.
This feels, to put it simply, dumb and wrong. I’ve thought about it more and I’m considering using a tagged union, but I’m very unsure on what methods would be best for my use case. Currently I’m running into the problem that the struct does not contain any extra information which might be of use to the functions i.e. the linear movement function doesn’t require any extra information but for the sine wave I would like to be able to define the period and amplitude.
In summary the goal is to have a series of modules that can be used in conjunction and define the path something should take from it’s starting location to it’s finishing location.
Hoping a more experienced programmer can help me not footgun myself! Please share how you would approach this problem or any data structures/patterns/etc you think would be useful.