Skip to content

Instantly share code, notes, and snippets.

@crispytaffy
Created October 21, 2018 08:31
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 crispytaffy/c0fe15ed2bf39d75838fa824e542db14 to your computer and use it in GitHub Desktop.
Save crispytaffy/c0fe15ed2bf39d75838fa824e542db14 to your computer and use it in GitHub Desktop.
This is a code for the art works of ASTROID DREAMERS
let item: neopixel.Strip = null
let planet = 0
let index = 0
// OnGesture settings
input.onGesture(Gesture.Shake, () => {
planet += 1
// Mercury (No.1)
if (planet == 1) {
for (let index = 0; index <= 0; index++) {
item.setBrigthness(30)
item.range(index, 4).showColor(neopixel.rgb(88, 87, 88))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(148, 158, 148))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(102, 102, 102))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(206, 204, 206))
item.show()
item.clear()
basic.pause(100)
}
}
// Venus (No.2)
if (planet == 2) {
for (let index = 0; index <= 0; index++) {
item.setBrigthness(100)
item.range(index, 4).showColor(neopixel.rgb(224, 201, 163))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(99, 34, 2))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(237, 181, 82))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(117, 154, 193))
item.show()
item.clear()
basic.pause(100)
}
}
// Earth (No.3)
if (planet == 3) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(112, 144, 177))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(88, 104, 165))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(165, 141, 109))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(90, 92, 58))
item.show()
item.clear()
basic.pause(100)
}
}
// Mars (No.4)
if (planet == 4) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(89, 56, 50))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(194, 95, 52))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(170, 86, 52))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(243, 192, 133))
item.show()
item.clear()
basic.pause(100)
}
}
// Jupiter (No.5)
if (planet == 5) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(114, 160, 189))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(200, 169, 142))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(202, 175, 135))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(209, 194, 169))
item.show()
item.clear()
basic.pause(100)
}
}
// Saturn (No.6)
if (planet == 6) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(189, 169, 136))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(217, 195, 162))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(211, 187, 151))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(162, 145, 108))
item.show()
item.clear()
basic.pause(100)
}
}
// Uranus (No.7)
if (planet == 7) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(111, 132, 140))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(122, 141, 152))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(133, 157, 168))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(116, 138, 147))
item.show()
item.clear()
basic.pause(100)
}
}
// Neptune (No.8)
if (planet == 8) {
for (let index = 0; index <= 0; index++) {
item.range(index, 4).showColor(neopixel.rgb(93, 108, 140))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(45, 56, 138))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(100, 166, 251))
item.shift(4)
item.range(index, 4).showColor(neopixel.rgb(60, 91, 224))
item.show()
item.clear()
basic.pause(100)
}
}
// Back to Start
if (planet == 9) {
planet = planet - 9
item.show()
item.clear()
}
})
// Reset
input.onGesture(Gesture.ScreenDown, () => {
if (planet != 0) {
planet = 0
item.show()
item.clear()
}
})
input.onButtonPressed(Button.A, () => {
if (planet != 0) {
planet = 0
item.show()
item.clear()
basic.showIcon(IconNames.Yes)
basic.clearScreen()
}
})
index = 0
item = neopixel.create(DigitalPin.P0, 16, NeoPixelMode.RGB)
item.show()
basic.showIcon(IconNames.Yes)
basic.clearScreen()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment