ndouglas / azymus

An experimental roguelike, written in Rust.
The Unlicense
6 stars 0 forks source link

Tile Map as Resource? #8

Closed ndouglas closed 5 years ago

ndouglas commented 5 years ago

There are some expensive operations that I need to perform -- initializing the Field of View map (see #6) for each mob in the dungeon. Perhaps several field of view maps for things like detect magic, infravision, etc. I don't want to just naïvely loop through the storage for each one of these. Also, I'm seeing nontrivial CPU usage when holding down movement keys, and I think it's at least in part because I'm looping through every wall in the map for every move. So I'm thinking about having a 2-D array for this that gets generated along with the map and inserted into the world as a resource.

This isn't the ECS way, as I understand it, but I'd expect it to head off some performance issues.

ndouglas commented 5 years ago

I did this and replaced the is-there-an-occupant-at-x,y check that was looping through the relevant storages and CPU usage went from ~30% to ~14% while holding a movement key and running down a long corridor. That's a substantial improvement, but I'm nevertheless horrified to see such high CPU usage this early in the game, so to speak. This might be due to factors out of my control or might be because I'm an idiot. It's just hard to tell 🤔