Hi, I took this code from the demo game. abs(spike.x - ball.x).
It makes a spike fall when the player passes it. What's the abs part? And how does it work?
Thanks for the help.
That's the absolute value. So whatever is the result of the subtraction is, positive or negative, it will return the positive of the result.
so abs(10-12) = 2
abs(12-10) = 2
Develop games in your browser. Powerful, performant & highly capable.
I see, thank you very much for explaining that. Appreciate it. It can be quite overwhelming sometimes. So much to learn.
abs is just one example of a classical arithmetic operation. They are all very handy to use when you understand know them. commonly used in all situations when you are handle numbers, like excel, programming or just math :)
Here is a good explanation of different math funtions (example is for java), but I believe they all exist in Construct as well:
way2java.com/java-lang/class-math
some examples
Thank you so much for this buddy. Seems really useful. There is so much to learn, it can be quite overwhelming, but a bit a time i guess is a good way.
Cheers for that, I will have a play about with expressions now :-)