summaryrefslogtreecommitdiffhomepage
path: root/derelict.js
diff options
context:
space:
mode:
Diffstat (limited to 'derelict.js')
-rw-r--r--derelict.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/derelict.js b/derelict.js
index 4be97ef..0e629b9 100644
--- a/derelict.js
+++ b/derelict.js
@@ -10,23 +10,29 @@ const GRID_EXTENT = 100 * SCALE
class Timeline {
start
finish
- current = 0
+ current
simple_list = []
register(wreck) {
- // TODO: Consider expiration right away
- if (this.start === undefined || wreck.timestamp < this.start)
- this.start = wreck.timestamp
- if (this.finish === undefined || wreck.timestamp > this.finish)
- this.finish = wreck.timestamp
+ if (this.start === undefined || wreck.timestamp - EXPIRY < this.start) {
+ this.start = wreck.timestamp - EXPIRY
+ if (this.current === undefined || this.current == this.start)
+ this.current = this.start
+ }
+ if (this.finish === undefined || wreck.timestamp + EXPIRY > this.finish)
+ this.finish = wreck.timestamp + EXPIRY
// TODO: Implement more reliable and optimized data structure for timeline.
this.simple_list.push(wreck)
}
- setTo(time) {} // TODO: Implement
- moveForward(time) {} // TODO: Implement
- moveBackward(time) {} // TODO: Implement
+ update() {
+ this.simple_list.forEach(wreck => wreck.toggleKilled(this.current))
+ }
+
+ setTo(time) {
+ this.current = time
+ }
}
class Grid {