$\require{cancel}$
timer
and cooldown
control the game.
super(params)
this
and the parent's variables do not exist until this returns.
super
parameters before the call to super.
y = gun_y_position for x = gun_x_poisition to aim_x_position plot(x,y) y += m
y = mx+b m = (y1 - y0) / (x1-x0) y0 = mx+b y1 = m(x+1) + b y1-y0 = m(x+1) + b - (mx + b) = mx + m + b -mx -b = m y1 = y0 + m
m = (y1-y0)/(x1-x0) m(x1-x0) = y1-y0 y1 = m(x1-x0)-y0 y = m(x-x0)-y0 If a line is perpendicular to y=mx+b, then the slope is -1/m The original line is y = slope1(x - gun.xpos) - gun.ypos slope2 = -1/slope1 The perpendicular line is y = slope2(x - target.xpos) - target.ypos Setting these two equal we get slope1(x - gun.xpos) - gun.ypos = slope2(x - target.xpos) - target.ypos slope1*x -slope2*x = slope1 * gun.xpos - slope2* target.xpos + target.ypos -target.ypos x = (that mess above)/(slope1 - slope2)