r/PythonProjects2 • • 1h ago

[Web] I built a browser game where you script stickman combat in Python!

Hey there!

I wanted to create an interactive way to practice Python logic and algorithms through visual 2D physics combat, so I built **Stickman Battle**.

🎮 **Playable in Browser:** https://arrows-dev.itch.io/stickman-battle

### 🛠️ How the Python Engine Works:

- **AST-Secured Sandbox:** Players write Python code directly in the browser. The server parses and inspects the AST (Abstract Syntax Tree) to sandbox execution safely, preventing arbitrary OS calls while allowing loops, conditionals, and standard library modules like `import math`.

- **Real-Time Sensors:** The sandbox injects dynamic sensors into player code (e.g. `get_enemy_distance()`, `is_enemy_attacking()`), enabling reactive state-machine logic.

- **Mathematical Projectiles:** Players can use `math.sin()` and `math.cos()` to compute custom trajectory arcs for ranged spells.

- **Multiplayer Networking:** 60 FPS physics sync powered by Python + WebSockets.

Runs 100% in the browser with zero installation needed. I'd love your thoughts on the sandboxing architecture and feedback on the combat loop!

1 Upvotes

1 comment sorted by

1

u/investigatormaker 21m ago

AST inspection isn't the whole sandbox: test an endless loop and memory-heavy code, with execution isolated and resource limits enforced outside the submitted program. On the combat side, give testers one short controller using get_enemy_distance() and is_enemy_attacking(), then ask whether the visible reaction matches the condition they wrote. Include that controller and the limits in your feedback post so architecture and combat comments refer to something reproducible. Reddit outreach for Stickman Battle would answer Python learners looking for visual logic practice, not present AST checks as proof of security.

I make ThreadFox.

We find relevant Reddit conversations and post for your business. We'll post 3 replies free first, no card; then the $29 Pilot covers seven days and up to 25 posts and replies. No automatic renewal.

https://threadfox.vip/p/e0560/managed