kopia lustrzana https://github.com/ertdfgcvb/play.core
Update coordinates_xy.js
rodzic
436a642cdb
commit
617c54e138
|
@ -5,11 +5,20 @@
|
|||
@desc Use of coord.x and coord.y
|
||||
*/
|
||||
|
||||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.:!?'
|
||||
const density = 'Ñ@#W$9876543210?!abc;:+=-,._ '
|
||||
|
||||
export function main(coord, context, cursor, buffer) {
|
||||
// To generate an output return a character
|
||||
// To generate an output return a single character
|
||||
// or an object with a “char” field, for example {char: 'x'}
|
||||
const i = (coord.y + coord.x + context.frame) % chars.length
|
||||
return chars[i]
|
||||
|
||||
// Shortcuts for frame and coord
|
||||
const f = context.frame
|
||||
const {x, y} = coord
|
||||
|
||||
// Invert direction for odd rows
|
||||
if (coord.y % 2 == 0) {
|
||||
return density[(y + x + f) % density.length]
|
||||
} else {
|
||||
return density[(y + context.cols - x + f) % density.length]
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue