E
E
Electro-max2022-03-17 20:20:25
JavaScript
Electro-max, 2022-03-17 20:20:25

How to make a smooth movement on the map in JS after calculating the A * algorithm?

The link below implements the algorithm for finding the shortest path for the ship, when the ship reaches the finish line, the map shifts to position the ship in the center of the screen. Is it possible to implement smooth offset shift?
Any ideas are welcome, I tried to impose a second layer on top of the algorithm calculation with smooth rendering, but the ship after the finish jumps to the center even if the map is smoothly moved on top, so nothing sensible came out.
https://codepen.io/Electromax/pen/JjOgMmm
https://codepen.io/Electromax/pen/JjOgMmm

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shamanov, 2022-03-18
@SilenceOfWinter

you need to move the map when moving the ship - you calculate the difference between points A and B, divide by the number of steps. But your approach is not viable - read about background color maps.

T
twobomb, 2022-03-18
@twobomb

Here you have everything sharpened precisely for jerky movement.
Of course how it's all implemented, especially the launchDelWay method is unique....

PS Moved all the movement to the update method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question