Now I need to compare the x value of two items in my array. I am using a print statement to check the x coordinate and I get values from -222 to 600. When the x value should only be between a set of positive values 0-320.
Are the objects in my array working in polar coordinates? And if so, how do I convert them. I am trying to check the difference between two items in my array to determine how close they are together. See my code below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | function pAccuracy() accuracy = array[ obj ].x - array[ obj - 1 ].x return accuracy end function checkScore() if pAccuracy() == 0 and scoreFound == false then --perfectly aligned. print("Perfect") scoreFound = true elseif pAccuracy() <= 5 or pAccuracy() >= -5 and scoreFound == false then -- aligned with atleast a 5px gap either side. print("Almost Perfect.") scoreFound = true end scoreFound = false end |