Boomerang Pathfinding

Hey all my new game features a boomerang and I have figured two ways to calculate the path for the boomerang (without the return arc, I’ll work on that later).

First of all draw a line of “range” length from the centre of the hero sprite, divide that into 20 - “speed” nodes (i.e. higher speeds leads to less nodes leads to it moving along its path faster) and store the nodes in an array to be sequentially ran through by each call of updateSprite()

Second create a for loop that increments and X and Y position each iteration and stores the results as nodes in an array.

My question is, which is less memory/processor intensive?

Neither should really damage your memory too much…go with the one that’d be easier to program.

I thought as much, I’m new to java and wondered more for my own knowledge, do you think creating the line would use more memory, just out of interest?

A line is just 2 points, so 8 - 16 bytes depending on what variable types you use. How many hundred million boomerangs do you need? If you only need like 200 000 you should be fine with lines. :wink:

I think OCD is the key word here, but thanks :slight_smile: