Subj : Re: Javascript for scripting a computer game To : netscape.public.mozilla.jseng From : smileyhamster Date : Fri Nov 19 2004 08:59 am Igor Bukanov wrote in message news:<419CF8C3.7030205@fastmail.fm>... > S wrote: > > ... > > What is the best way to implement this? > > What is the definition of "best"? Best in memory usage/speed/programming > simplicity/maintenance easiness? Just in general. For all I know, there could be Context.pauseExecution() and Content.resumeExecution() methods that are fast and memory effecient. Using continuations means that my code has to be interpreted so my might get speed issues later. > It is not supported directly but if you use continuations and moveUp is > JS function, then you can program it like: That's pretty much exactly what I'm doing at the moment. Thanks for the code. Again though, I'm worried that having to use interpreted code might become a problem. > > Also, each script can be assigned to multiple entities. For example, > > the player entity could create a entity each turn and attach a bullet > > script to it (to shoot at things). How can I do this using the least > > resources in a fast way? My prototype runs very slowly when I create > > new entities on the board but is fast when nothing is being created. > > Each time a new bullet entity is made, it runs code like this: > > See http://www.mozilla.org/rhino/scopes.html and pay attention to the > shared scope section. I'm not at my home computer right now so I can't try anything out. So I could have one "bullet object scope" and give that to each bullet so they could all reuse the same scope I just compiled? Doesn't this mean they'll share variables between each other and could possibly interfere which each other? I don't want each, for example, bullet objects to share data directly from the same scope if this is what this does. I read the page but I'm having trouble understand exactly what shared scope implies. Thanks for your help. .