MCPcopy Create free account
hub / github.com/braziljs/eloquente-javascript / updateParcels

Method updateParcels

code/animatevillage.js:70–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68 }
69
70 updateParcels() {
71 while (this.parcels.length) this.parcels.pop().remove()
72 let heights = {}
73 for (let {place, address} of this.worldState.parcels) {
74 let height = heights[place] || (heights[place] = 0)
75 heights[place] += 14
76 let node = document.createElement("div")
77 let offset = placeKeys.indexOf(address) * 16
78 node.style.cssText = `position: absolute; height: 16px; width: 16px; background-image: url(${this.imgPath}parcel2x.png); background-position: 0 -${offset}px`;
79 if (place == this.worldState.place) {
80 node.style.left = "25px"
81 node.style.bottom = (20 + height) + "px"
82 this.robotElt.appendChild(node)
83 } else {
84 let pos = places[place]
85 node.style.left = (pos.x - 5) + "px"
86 node.style.top = (pos.y - 10 - height) + "px"
87 this.node.appendChild(node)
88 }
89 this.parcels.push(node)
90 }
91 }
92
93 tick() {
94 let {direction, memory} = this.robot(this.worldState, this.robotState)

Callers 1

constructorMethod · 0.95

Calls 1

popMethod · 0.80

Tested by

no test coverage detected