ScriptaGames / zorbio

A 3D multiplayer WebGL game
MIT License
8 stars 1 forks source link

Consider measuring spheres with mass instead of radius #327

Open mwcz opened 7 years ago

mwcz commented 7 years ago

I've been thinking about this, and I think it might be a good idea to swallow the refactoring pill at some point and switch from radius to mass. AFTER 1.0 of course, just thinking ahead.

(since our spheres don't really have a density, mass and volume are equivalent)

Pros

  1. players can say "I reached 100 mass" and it would sound more accurate and cooler than "I reached 100 size" or "I reached 100 radius"
  2. we can remove all the scaling formulas we created for scaling growth. for example, we currently have a formula for calculating how much radius a piece of food should be worth based on the player's current radius. it so happens that our formula matches almost perfectly what would happen if we could simply do player.mass += 1. see: https://www.desmos.com/calculator/rpejruzn69
  3. removing the scaling formulas will be more important after I add growth numbers. right now, I'd have to scale them down, so we'd be seeing a bunch of "+0.0001" under the current system. if we used mass, I could display "+1" for food and it would honestly be adding +1 to your mass. :)
  4. all growth effects would be more intuitive because they'd have a basis in physical reality.
  5. when a player capture happens, we could do player.mass += player2.mass. now, we have to cut radius in half before adding it because adding two players' radii would increase their total size waaay too fast, but adding mass would naturally increase their radius at a slower rate.
  6. if we display mass in the leaderboard, it would make the numbers a lot more impressive. for example, a player with 150 radius (displayed as "1500" in leaderboard) would have 14,137,167 mass.
  7. it would slow down all growth, meaning it would take longer to reach max size, which is a good thing IMO. I think it would be great if it took a much longer time to reach max size

The summary is that we're already using "mass", but in a shoehorned fashion by piling scaling formulas on top of a radius system. If we used mass instead, we could replace all our custom complex math with one equation: volume (aka mass) of a sphere.

Cons

  1. re-adjusting some configurations, like player speed decay, drain amount, cost of speed boost, etc
  2. refactoring cost and...
  3. bugs due to refactoring

@Jared-Sprague thoughts?

Jared-Sprague commented 7 years ago

how would capture detection work?

mwcz commented 7 years ago

Ah, yeah, that would still use radius. I'm not suggesting removing radius completely, just that growth-related functions use mass instead. There's a simple equation to convert from mass (aka volume) to radius and back.