I took a one-month break from Gastropoda to participate in the JS13kGames challenge with a tiny game called Breaking Brad
But now it’s back to simulations! It’s taking me a while to remember where exactly I left off with Gastropoda last month, but now I think it’s time to figure out how to calculate a snail’s position within a jar. This is important because each snail will detect other objects (items, snails, etc) differently based on its senses. I have to have an actual location for both objects and snails. Right now I’m setting a position randomly when a snail is hatched in a jar, but I have to decide how I’m going to update this position as it crawls. Currently snails crawl at random on HTML5 canvas - they are already starting their crawl from their DB position, but pick direction randomly and then move back and forth across the screen using their speed attribute. So far all I have are some random notes:
- User actions while watching rendered snails (ie drag and drop, etc) have to influence thes snail’s position in the db, but only the jar’s owner can move snails around.
- Do I update the general crawl position on the client and then send that data to the server every x seconds? This wouldn’t really work because more than one user can be watching a snail at any one time, so if we take the random turn direction etc and record it, you will get all kinds of dodgy results in the db. Also I’d then need a separate solution for snail movement when the snails are not being rendered at all. Snails do things/move continuously - in this case a tree that falls in a forest does make a sound even if no one is there to hear it. I think I have to set direction or target position on the server and then have the client reflect this if a user is watching a jar, not the other way around.
- How do I make this scalable to potentially hundreds/thousands of snails?
Today I’m sick and not thinking straight, so I’m not actually going to even try implementing anything at this point. Back to hot tea for me :(