@Xela: Do you understand the image positioning in BE? All of this BE values like "archon", "battle.Camera", "offset" that I don't understand are making it totally confusing for me
I need to calculate sprite movement, that will fly from caster to target (that's simple (fighterx, fightery) to (targetx, tragety)) but then continue off screen on the same trajectory - like if its flying through the target ((targetx, tragety) to (?,?)).
My latest attempt that is working on paper doesn't place it right in game at all for whatever reason (500 is a made up value that should move the X somewhere off screen) :
offset = Transform(xanchor=self._sprite_fly.Anchor[0], yanchor=self._sprite_fly.Anchor[1])
# Try to normalize positions:
fighterx = fighter.Position.Transform.xpos - fighter._battle.CameraX
fightery = fighter.Position.Transform.ypos - fighter._battle.CameraY
targetx = target[0].Position.Transform.xpos - target[0]._battle.CameraX
tragety = target[0].Position.Transform.ypos - target[0]._battle.CameraY
# fly from caster to target
mf = Move((fighterx, fightery), (targetx, tragety), self._fly_duration)
renpy.show(tag, what=self._sprite_fly, at_list=[mf, offset, do_the_flip], layer=l, zorder=fighter.Position.Z + 0.001)
fighter._battle.Pause(self._fly_duration)
# continue flying out on the same trajectory
if self._fly_off_screen:
if fighterx > targetx:
flip_math = -1
else:
flip_math = 1
flyoffx = targetx+(500*flip_math)
flyoffy = (tragety-fightery)*((500*flip_math)/(targetx-fighterx))+tragety
mfout = Move((targetx, tragety), (flyoffx, flyoffy), self._fly_duration)
renpy.show("fly_off", what=self._sprite_fly, at_list=[mfout, offset, do_the_flip], layer=l, zorder=fighter.Position.Z + 0.001)
Seriously, let's say the positions are:
fighterx=100,
fightery=150,
targetx =500,
tragety=200,
and I increase the final X position by 500 to 1000, then obviously continuing on, the Y must get higher (262,5 according to vector program)
(targetx+(500*flip_math)),((tragety-fightery)*((500*flip_math)/(targetx-fighterx))+tragety)
= ((500+(500*1)),((200-150)*((500*1)/(500-100))+200)
= (1000),(50*(500/400)+200)
= (1000),(262,5)
It's just right! Then why the hell is my image always moving in the straight horizontal line?