I’ve been working on a fun little side project to customize the dale harvey’s html5 canvas pacman game http://arandomurl.com/2010/07/25/html5-pacman.html and teach myself a bit of javascript at the same time. But after a few seconds of playing the game it freezes… I believe this is from too much recursion (i.e. something needs to be closed?) but I’m under the impression that game loop needs to remain open to allow the continuous control and movement of the characters… correct?
I’m a bit of a noob in the javascript game so any help would be great.
http://bridgestreetcollective.harmonyapp.com/pacman/?password=test
Cheers
Your
clonefunction is screwed up. You call it on the document’sbodyelement somewhere, and that has circular references. You should be able to see this using a debugger. See How do you clone an Array of Objects in Javascript? and In Javascript, when performing a deep copy, how do I avoid a cycle, due to a property being "this"?.Also, you should never ever use Object.prototype.