```js elements.gasoline_engine = { color: "#6d5f5d", behavior: behaviors.WALL, state: "solid",

elements.gasoline_engine = {
  color: "#6d5f5d",
  behavior: behaviors.WALL,
  state: "solid",
  density: 1000,
  category: "testing",
  properties: {
    shocksToDo: 0
  },
  tick: function(pixel){
    if (pixel.shocksToDo <= 40){
    for (var i = 0; i < adjacentCoords.length; i++){
      var coord = adjacentCoords[i]
      var x = pixel.x + coord[0]
      var y = pixel.y + coord[1]
      if (!isEmpty(x, y, true)){
        var otherPixel = pixelMap[x][y]
        if (otherPixel.element == "gasoline"){
          deletePixel(x, y)
          if(!pixel.shocksToDo){pixel.shocksToDo = 0}
          pixel.shocksToDo += 10
        }
        else if (otherPixel.element == "gasoline_engine"){
          var otherPixel = pixelMap[x][y]
          var otherShock = otherPixel.shocksToDo || 0
          var currentShock = pixel.shocksToDo || 0
          if (otherShock == currentShock){break;}
          if (otherShock > currentShock){
            otherPixel.shocksToDo --
            pixel.shocksToDo ++
          } else {
            otherPixel.shocksToDo ++
            pixel.shocksToDo --
          }
        }
      }
    }}
    if (!pixel.charge && !pixel.chargeCD && pixel.shocksToDo){
      for (var i = 0; i < adjacentCoords.length; i++){
        var coord = adjacentCoords[i]
        var x = pixel.x + coord[0]
        var y = pixel.y + coord[1]
        if (!isEmpty(x, y, true)){
          if (elements[pixelMap[x][y]].conduct > 0){
            pixel.charge = 1
            pixel.shocksToDo --
            break;
          }
        }
      }
    }
  }
}
Was this page helpful?