Re: [pygame] Ridiculously simple way to seperate game-object code
by Sami Hangaslammi other posts by this author
May 20 2006 4:20PM messages near this date
[pygame] Ridiculously simple way to seperate game-object code
|
Re: [pygame] Ridiculously simple way to seperate game-object code
On 5/20/06, James Hofmann <jwhinfinity@[...].com> wrote:
> http://people.ucsc.edu/~jhofmann/programmables.py
Hello,
That's a pretty interesting idea. :)
I developed it a bit further, and made a version that understands
basic if, for and while-blocks. However, it doesn't yet support else-
or try-blocks for example. The idea is that you parse a piece of code
by creating a new LineInterpreter as in
> >> src = open("test1.py").read()
> >> li = LineInterpreter(src)
To execute the source, you call the "run" method, which return a new
"RunTime" object (so that you can have several concurrent executions
of the same code without them interfering with eachother).
> >> runtime = li.run()
After this, you can run one or more lines calling runtime.iterate.
> >> runtime.iterate(5) # execute five lines of code, then return
The fancy thing is that the script execution can be e.g. in the middle
of an if-block after the iterate call, and it knows how to resume it
during the next call.
If there really is need for this sort of thing, let me know and I can
develop it further. :)
Current version at http://codereactor.net/~shang/interpret/
--
Sami Hangaslammi
Thread:
James Hofmann
Sami Hangaslammi
James Hofmann
Kamilche
Adeola Bannis
Kris Schnee
Lenard Lindstrom
|