So I'm making a web game using HTML5 / Javascript.
I have an Enemy class and would like to know the best way to implement a path system.
I currently have something, but it doesn't seem too efficient for me (Compared to programming I've done in C++).
function Enemy(){
this.currentPath = [];
this.currentPath.push({x: 5, y: 9});
this.currentPath.push({x: 5, y: 1});
// e.t.c ...
this.currentPath.push({x: ..., y: ...});
this.move = function(){
if(atNextNode){
//Not actual code, but relevant
this.currentPath.shift();
}
};
}
For every enemy I create, I push a whole load of new data into each class.
Compared to C++ where I could just have a pointer to a Path class and then increment where in the path it is, saving memory.
I know computing power is very fast but I want to know if there are better ways to implement this sort of thing in JavaScript or I should just not worry about minuscule optimisations like this.