On Tue, Jan 29, 2013 at 4:43 PM, Francois Dion <francois.d...@gmail.com>wrote:
> On Fri, Jan 18, 2013 at 7:21 PM, Jurgis Pralgauskis > <jurgis.pralgaus...@gmail.com> wrote: > > http://www.skulpt.org/ or http://www.brython.info/ ? > > They are made on javascript - so if you don't need to save stuff > > serverside - might be good enough. > > > Regarding the original question, about putting text adventures on the > web, it's a funny thing, because that's what I've had on my mind since > I heard about Brython. Initially it didn't even have print(), and to > me that was a basic requirement. so I created a webprint for brython ( > http://raspberry-python.blogspot.com/2012/12/brython-browser-python.html > ), but then Pierre (the author) added print(). The next piece of the > puzzle was the raw_input() (or in this case input() since Brython is > Python 3.x ). Pierre, Andre (Roberge, fellow edu-sig member) and I > went through various discussions on how this could work. In the end, I > had to go back to my original thought of having input() bringing up a > web browser prompt (javascript prompt) so the call would be blocking, > to flow just like a Python script. > > To test this, I grabbed a simple python text adventure from a blog ( > http://livingcode.org/entries/2008-02-22_simple-text-adventure/ ) and > plugged it in the web page, with minimum change, namely to convert it > to Python 3.x syntax. The purpose of getting code I didn't write to > test the idea, was that I knew how to code around the limitations of a > web browser (event driven vs the linear approach of a typical Python > script), so if my code ran ok, it wouldn't prove the suitability of > the solution. So the code from the blog ran, but it's not 100% what > one would expect. You can check it out for yourselves here (it's my > Brython playground, on free hosting so it's not particularly fast to > answer): > > http://brython.heliohost.org/demos/simpleadventure.html Having just tried it, I noticed a problem with it that I had not anticipated when thinking of using prompt for input. the information written in the textarea (?) needs to be scrolled up; however, the prompt prevents a user from doing so. . > > > A more proper way of doing this does require eliminating the while > True: loop and replacing it with a function, and moving the input to > the end of the function: > > http://brython.heliohost.org/demos/simpleadventure1.html > > This works much better. The way I would describe, without looking at the code, would be like a state machine. The "world" is stored as an object; when the user enters a command, a single function call is issue [ "update(user_input)"] and some feedback is given. Impressive. André > Still, it is close to a solution. > > Francois > > -- > www.pyptug.org - raspberry-python.blogspot.com - @f_dion > _______________________________________________ > Edu-sig mailing list > Edu-sig@python.org > http://mail.python.org/mailman/listinfo/edu-sig >
_______________________________________________ Edu-sig mailing list Edu-sig@python.org http://mail.python.org/mailman/listinfo/edu-sig