Hello everyone , im making a roguelike game just for exercise myself , i come to a problem when i come to the line of sigth.
Am unable to find a equation/formula for getting the number of purple “square/node” like in this schema:
i think i can resolve this by a exponential equation (y = ab^x) but im not sure on that because i cant get the “b” right when checking it with multiple points.
Thanks for your future responds and help.
You have an arithmetic progression there.
1 → 0
2 → 0 + 2 = 2
3 → 0 + 2 + 4 = 6
4 → 0 + 2 + 4 + 6 = 12
5 → 0 + 2 + 4 + 6 + 8 = 20
yes indeed, the goal would be to have some sort of formula for it to be inside a loop.
I dont get it. Doesnt this formula fit your needs?
An arithmetic progression or arithmetic sequence (AP) is a sequence of numbers such that the difference from any succeeding term to its preceding term remains constant throughout the sequence. The constant difference is called common difference of that arithmetic progression. For instance, the sequence 5, 7, 9, 11, 13, 15, . . . is an arithmetic progression with a common difference of 2.
If the initial term of an arithmetic progression is
a
...
It should if all you need is the number of purple squares.
well the number of purple square are base on the range of the line of sight(in red)
Ryiah
August 14, 2016, 1:11am
6
If that’s the pattern this will handle it.
int purpleSquares = lengthOfSight * (lengthOfSight - 1);