Cellular Automata Fluid Engine for Pygame
A downloadable game
This Cellular Automata Fluid Engine provides a highly optimized, fake fluid simulation for 2D grid-based games. Trying to simulate water by creating thousands of individual "WaterDrop" objects will absolutely destroy your frame rate. This asset solves that problem by using a 1D integer array to process fluid logic, allowing you to run water, acid, or lava simulations at 60 FPS.
This is the exact math required to get that satisfying, pixel-perfect fluid flow seen in games like Terraria or Noita, completely decoupled and ready to drop into your Pygame project.
Core Features:
- High-Performance 1D Array Logic: The engine maps a 2D grid into a 1D memory array, ensuring ultra-fast read/write speeds for thousands of cells per frame.
- Complete Fluid Ruleset: Automatically calculates gravity falling, diagonal slope-sliding, and lateral surface spreading. Water naturally pools and levels itself out.
- Reverse-Iterative Updating: The core algorithm iterates bottom-to-top, preventing the common "teleporting water" bug found in beginner CA tutorials.
- Interactive Sandbox Included: Comes with a fully executable main.py canvas. Left-click to pour water like a hose, right-click to draw concrete walls, and watch the algorithm work in real-time.
What's Inside the Package:
- fluid_engine.py (The optimized math and state management array)
- main.py (The executable interactive sandbox)
- README.md (Clear, step-by-step implementation guide)
Technical Specifications:
- Language: Python 3.x
- Library: Pygame 2.x
License: Purchasing this asset grants you a non-exclusive, royalty-free license to use, modify, and integrate this code into any commercial or non-commercial project. Reselling the raw source code is prohibited.
| Status | Released |
| Author | squidforge |
| Tags | 2D, fluid-simulation, game-asset, noita, Physics, pygame, python, source-code, terraria, water |
| Content | No generative AI was used |
Download
Click download now to get access to the following files:



Leave a comment
Log in with itch.io to leave a comment.