Open gbelwariar opened 6 years ago
Some useful insights can be taken from this project - https://github.com/kenk42292/angular-pacman
Update: The difference in the approach of the above mentioned project with our project is that in latter, when an agent(pacman/any enemy) moves one step (to right/left/down/up, if possible), then the HTML elements of the leaving cell and the future cell are not changed, but instead the HTML element of the moving agent is moved in the direction of motion(by following the same approach as in https://plnkr.co/edit/ehrvsYEzDds99847tQgb?p=preview), thus manipulating only the HTML element of the moving agent and not that of the cells. This eliminates the need to re-construct the whole HTML template of the board, which takes O(width_of_board * height_of_board * avg_length_of_HTML_template_of_a_cell)
time, and achieving the same task in O(1)
time.
Currently, due to the single-threaded nature of JavaScript and heavy use of
$interval
service in the implementation, the game has become laggy, leading to a poor user experience. Another reason could be the multiple re-computations of the whole HTML for even a single movement of a particular enemy/pac-man.Also the game runs much slower in Mozilla Firefox than in Google Chrome.