Skip to content

Instantly share code, notes, and snippets.

@line-o
Created May 22, 2022 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save line-o/7cb0ec335316b4531807133527345c88 to your computer and use it in GitHub Desktop.
Save line-o/7cb0ec335316b4531807133527345c88 to your computer and use it in GitHub Desktop.
GPN20 display hack
let tx = document.getElementById("text-input")
let h = 2
let state = Array(24).fill([h, '_'])
let c = ['/', '_', '\\']
let interval
function step () {
let direction = Math.floor(Math.random() * 2.9999) - 1
let d = Math.min(3, Math.max(0, h+direction))
state.shift()
let uuu = c[d-h +1]
state.push([h, uuu])
h = d
tx.value = render(state)
updateDisplay()
}
function render(state) {
let asdf = Array(4).fill(null)
let buuu = asdf.map(_ => Array(24).fill(' '))
for (let index in state) {
let arr = state[index]
let realh = arr[0]+(arr[1] == '\\')
buuu[realh][index] = arr[1]
realh +=1
for (;realh<4;realh++) {
buuu[realh][index] = '8'
}
}
return buuu.map(a => a.join('')).join('\n')
}
int = setInterval(step, 250)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment