summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-08 13:12:51 +0200
committerAki <please@ignore.pl>2021-08-08 13:12:51 +0200
commited5f9128c1da9f1888c17e9f5e9de4cd6971290e (patch)
tree444f18791c9f82077982b0a3367017050ab11f33
parent6502cb6eea353962c4299701feba1be35bf418fe (diff)
downloadderelict-prototype-ed5f9128c1da9f1888c17e9f5e9de4cd6971290e.zip
derelict-prototype-ed5f9128c1da9f1888c17e9f5e9de4cd6971290e.tar.gz
derelict-prototype-ed5f9128c1da9f1888c17e9f5e9de4cd6971290e.tar.bz2
Naively implemented Timeline
-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 {