# Calculates the amount of pixels the unit has moved from one tick ago as a signed integer value. Negative is up, positive is down.
from copy import deepcopy
UP = False # Negative.
DOWN = True # Positive.
up = 0
down = 0
def DeltaY (direction, a, b, c):
a_i = Inverse_X(a) # Inverse a.
b_i = Inverse_X(b) # Inverse b.
c_i = Inverse_X(c) # Inverse c.
a_v = [] # Valid a.
b_v = [] # Valid b.
c_v = [] # Valid c.
a_i_t = deepcopy(a_i) # Temporary inverse a.
while a_i:
b_i_t = deepcopy(b_i)
while b_i_t:
c_i_t = deepcopy(c_i)
while c_i_t:
if b_i[0] - a_i[0] == c_i[0]:
a_v.append(a_i[0])
b_v.append(b_i[0])
c_v.append(c_i[0])
c_i_t.pop(0)
b_i_t.pop(0)
a_i.pop(0)
if len(a_v) >= 2:
if (a_v[0] > 0 and b_v[0] < a_v[0]) or (a_v[0] < 0 and b_v[0] > a_v[0]):
if(direction == UP):
return abs(a_v[0])
else:
return -1 * abs(a_v[0])
else:
if(direction == UP):
return -1 * abs(a_v[0])
else:
return abs(a_v[0])
elif len(a_v) >= 1:
return a_v[0]
else:
raise Exception
def Inverse_X (input):
if Is_Odd(input):
a = input / 2
a = a - up
return [a]
else:
a = input / 2
b = input / 2
a = down - a
b = b - up
return [a, b]
def Is_Odd (input):
if input % 2 == 1:
return True
else:
return False
up = 6
down = 19
print DeltaY(DOWN, 24, 19, 5)