I'm playing around with the Sense Hat, which I'm rather enjoying, but programming has moved on a touch since I was young.
I'm trying to get the Sense Hat to animate two space invader images and go back to the first image in the program once it has displayed the last.
In Basic the command would have been goto and the line number of the image. But Python is more up to date than Basic and doesn't recognise it.
Does anyone know the Python equivalent goto command?
Code: Select all
# Space Invaders
from sense_hat import SenseHat
import time
sense = SenseHat()
x = (255,0,0)
o = (255,255,255)
image_1 = [
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,x,x,x,x,x,x,o,
x,o,o,o,o,o,o,x,
x,o,o,o,o,o,o,x,
x,x,o,o,o,o,x,x,
]
image_2 = [
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,o,x,x,x,x,o,o,
o,x,x,x,x,x,x,o,
o,x,o,o,o,o,x,o,
o,x,o,o,o,o,x,o,
o,x,x,o,o,x,x,o,
]
sense.set_pixels(image_1)
time.sleep(1)
sense.set_pixels(image_2)
time.sleep(1)
goto 10