Does anybody know how Terraria keeps such good FPS? There are millions of blocks and water tiles,
countless particles torches, etc. How did they do that? Any ideas? Thanks.
This was answered in the thread already. Terraria (most likely) uses chunks and processes everything within those chunks while ignoring everything that is outside of said chunks. So the world is basically active around the player (+some extra) but everything else sort of gets frozen, doesn´t create particles/enemies etc. and thus takes basically no processing power. So yes, there are millions of tiles but it doesn´t matter. Even if you would put trillions in, only a specific amount of them is ever needed around the player.
Also one should mention that when dealing with huge amounts of things, you will get more out of it when you use C# or C++ instead of javascript, even though javascript is slowly creeping up (especially with WebAssembly)
In terms of water, I really don´t know how one could do it. I found this though
youtube.com/watch
Along with the code
drive.google.com/file/d/0Byqm4cKYC28xV0M1NTdsNVBUMjQ/view
I think there is a fair chance that you´d be able to translate this into Events or JS (or webassembly?), though it will likely be slower AND it is not optimized for chunking and such.