MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / tick

Method tick

code/animatevillage.js:93–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

91 }
92
93 tick() {
94 let {direction, memory} = this.robot(this.worldState, this.robotState)
95 this.worldState = this.worldState.move(direction)
96 this.robotState = memory
97 this.turn++
98 this.updateView()
99 if (this.worldState.parcels.length == 0) {
100 this.button.remove()
101 this.text.textContent = ` Finished after ${this.turn} turns`
102 this.robotElt.firstChild.src = this.imgPath + "robot_idle2x.png"
103 } else {
104 this.schedule()
105 }
106 }
107
108 schedule() {
109 this.timeout = setTimeout(() => this.tick(), 1000 / speed)

Callers 1

scheduleMethod · 0.95

Calls 2

updateViewMethod · 0.95
scheduleMethod · 0.95

Tested by

no test coverage detected