E
E
Electro-max2022-03-06 17:03:27
JavaScript
Electro-max, 2022-03-06 17:03:27

How to attach a camera to a player in the A* algorithm?

There is a large map with impassable cells, the algorithm calculates the path and the ship sails along it, how to attach to the ship so that the camera moves after it? The drawing of the map starts from the upper left corner, tell me at least how to change the drawing from another place, then I will tie the ship, if there is a scheme, how to change the place where the map is drawn in the algorithm.
https://codepen.io/Electromax/pen/JjOgMmm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-03-07
@Aleksandr-JS-Developer

After that,
6225205c0adf5522972612.png
99% of people will fall down and will not help.
How much time do you spend maintaining/changing the map?)

Isn't it easier to make the initialization a little shorter?

const points = {
  0: [0,24,43,56,75,88], 1: [24,43,56,75,88], 2: [11,24,43,56,75,88],
  3: [11,24,43,56,75,88], 4: [11,24,43,56,75,88], 5: [11,24,43,56,75,88],
  6: [11,24,43,56,75,88], 7: [11,24,43,56,75,88], 8: [11,24,43,56,75,88],
  9: [11,24,43,56,75,88], 10: [11,24,43,56,75,88], 11: [11,24,43,56,75,88],
  12: [11,24,43,56,75,88], 13: [11,24,43,56,75,88], 14: [11,24,43,56,75,88],
  15: [11,24,43,56,75,88], 16: [11,24,43,56,75,88], 17: [11,24,43,56,75,88],
  18: [11,24,43,56,75,88], 19: [11,24,43,56,75,88], 20: [11,24,43,56,75,88],
  21: [11,24,43,56,75,88], 22: [11,24,43,56,75,88], 23: [11,24,43,56,75,88],
  24: [11,24,43,56,75,88], 25: [11,24,43,56,75,88], 26: [11,24,43,56,75,88],
  27: [11,24,43,56,75,88], 28: [11,24,43,56,75,88], 29: [11,24,43,56,75,88],
  30: [11,24,43,56,75,88], 31: [11,24,43,56,75,88], 32: [11,24,43,56,75,88],
  33: [11,24,43,56,75,88], 34: [11,24,43,56,75,88], 36: [11,24,43,56,75,88],
  37: [11,24,43,56,75,88], 38: [11,24,43,56,75,88], 39: [11,24,43,56,75,88],
  40: [11,24,43,56,75,88], 42: [11,24,43,56,75,88], 43: [11,24,43,56,75,88],
  44: [11,24,43,56,75,88], 45: [11,24,43,56,75,88], 46: [11,24,43,56,75,88],
  47: [11,24,43,56,75,88], 48: [11,24,43,56,75,88], 49: [11,24,43,56,75,88],
  50: [11,24,43,56,75,88], 51: [11,24,43,56,75,88], 52: [11,24,43,56,75,88],
  53: [11,24,43,56,75,88], 54: [11,24,43,56,75,88], 55: [11,24,43,56,75,88],
  56: [11,24,43,56,75,88], 57: [11,24,43,56,75,88], 58: [11,24,43,56,75,88],
  59: [11,24,43,56,75,88]
};

const a = Array(60)
  .fill()
  .map((_, y) => {
    const row = Array(90).fill(0);
    
    if (points[y] !== undefined) {
      points[y].forEach(p => row[p] = 1);
    }
    
    return row;
  });

On the question: When clicked, an exception is thrown that it cannot read 0 from undefined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question