Back to the future
In the previous article we flirted with the idea of recreating the old-school text experience.
Is that what the world needs in 2023? What about all the lovely Web technology there is available now? What if we could we make use of that instead?
Balladeer is a web-native framework. It makes it easy to host a Story so that it runs in a browser. The Web version of the knock, knock joke has less code than the text-mode example.
Less is More
Copy the following lines into a new file called main.py:
from balladeer import Dialogue from balladeer import StoryBuilder from balladeer import quick_start story = StoryBuilder( Dialogue("Here's a joke..."), Dialogue("<ADAM> Knock, knock."), Dialogue("<BETH> Who's there?"), Dialogue("<ADAM> Doctor."), Dialogue("<BETH> Doctor who?"), Dialogue("<ADAM> You just said it."), ) if __name__ == "__main__": quick_start(builder=story)
The perfect host
Go back to your terminal window.
py3/bin/python -m main
py3\Scripts\python.exe -m main
First you should see something like this:
[2023-05-17 20:21:33 +0100]  [INFO] Running on http://127.0.0.1:8080 (CTRL + C to quit)
Now open a Web browser and type localhost:8080 into the location bar.
No points for style
Without any additional styling the results are admittedly plain.
Press the Enter key to proceed through the dialogue.
We're on our way!
You will have all the features of the Web at your disposal. The power to connect to databases, hook up with social media feeds, integrate with every kind of API.
You can write parser games or point-and-click puzzles. You can host a gallery of your art, or showcase your latest musical project. You can play locally, or on a network with colleagues, or serve to the entire world.
See you next time!