clock.go 886 B

1234567891011121314151617181920212223242526
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Package clock provides a clock and time functions for a sprite engine.
  5. package clock
  6. // A Time represents an instant in sprite time.
  7. //
  8. // The application using the sprite engine is responsible for
  9. // determining sprite time.
  10. //
  11. // Typically time 0 is when the app is initialized and time is
  12. // quantized at the intended frame rate. For example, an app may
  13. // record wall time when it is initialized
  14. //
  15. // var start = time.Now()
  16. //
  17. // and then compute the current instant in time for 60 FPS:
  18. //
  19. // now := clock.Time(time.Since(start) * 60 / time.Second)
  20. //
  21. // An application can pause or reset sprite time, but it must be aware
  22. // of any stateful sprite.Arranger instances that expect time to
  23. // continue.
  24. type Time int32