ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Allow Speed scheduler to accept an initial time #101

Closed tps12 closed 7 years ago

tps12 commented 7 years ago

Adds an additional optional time argument to Scheduler.Speed.add(), which defines an initial time to schedule the item. If the item is repeated then subsequent scheduling will use 1/item.getSpeed() as before.

Also exposes an item's time through a Scheduler.getTimeOf(item) method. In combination, these two changes allow clients to completely recreate the state of the speed scheduler at a given point, useful when saving and restoring a game state.

ondras commented 7 years ago

Makes sense, thanks for your contribution!