web.pyΒΆ
Part of Tic Tac Toe.
1"""
2Tic Tac Toe: Play in your browser via video streaming.
3
4The server renders the game with Vulkan and streams JPEG frames to the
5browser over WebSocket.
6
7Run:
8 uv run python examples/demos/tictactoe/web.py
9
10Then open http://localhost:8080 in any modern browser.
11"""
12
13import argparse
14
15from game import SCREEN_H, SCREEN_W, TicTacToeApp
16
17from simvx.graphics import App
18from simvx.graphics.streaming import StreamingServer
19
20
21def main():
22 parser = argparse.ArgumentParser(description="Tic Tac Toe: web streaming")
23 parser.add_argument("--port", type=int, default=8080, help="Server port")
24 parser.add_argument("--host", type=str, default="0.0.0.0", help="Server host")
25 parser.add_argument("--backend", type=str, default=None, choices=["glfw", "sdl3"], help="Windowing backend")
26 args = parser.parse_args()
27
28 server = StreamingServer(host=args.host, port=args.port)
29 app = App(width=SCREEN_W, height=SCREEN_H, title="Tic Tac Toe", backend=args.backend)
30 print(f"Starting Tic Tac Toe at http://localhost:{args.port}")
31 app.run_streaming(TicTacToeApp(), server)
32
33
34if __name__ == "__main__":
35 main()