Deleted due inconsistencies in posting code
Use the “preformatted text” (</> button) option, and it will retain the indents etc.
It wraps it in code tags.
Cheers mate. I was doing a search for what i was doing wrong. I’ll try again in a bit.
Hi all. I’ve been playing with the Cosmic and Galatic unicorns. Not an expert in Micropython etc by any means so the following is just a bit of fun. It will no doubt have duplication of stuff plus easier ways of programming (i.e. Global variables? and Wizz…bang!!! if i knew how to do the audio). Please use/amend/change/scoff/deride as you wish:-). I’m not asking for advice just thought I’d post to show the effects that can be achieved.
#Remember, remember the 5th of November (non uk Peeps will have to look that up!!!)
import time
import random
from galactic import GalacticUnicorn
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN as DISPLAY
galactic = GalacticUnicorn()
graphics = PicoGraphics(DISPLAY)
#Variables
a=0
b=-7
x0=0+a
x1=1+a
x2=2+a
x3=3+a
x4=4+a
x5=5+a
x6=6+a
x7=7+a
x8=8+a
x9=9+a
x10=10+a
x11=11+a
x12=12+a
x13=13+a
x14=14+a
x15=15+a
x16=16+a
x17=17+a
x18=18+a
x19=19+a
x20=20+a
x21=21+a
x22=22+a
x23=23+a
x24=24+a
x25=25+a
x26=26+a
x27=27+a
x28=28+a
x29=29+a
x30=30+a
x31=31+a
x32=32+a
x33=33+a
x34=34+a
x35=35+a
x36=36+a
x37=37+a
x38=38+a
x39=39+a
x40=40+a
x41=41+a
x42=42+a
x43=43+a
x44=44+a
x45=45+a
x46=46+a
x47=47+a
x48=48+a
x49=49+a
x50=50+a
x51=51+a
x52=52+a
y0=0+b
y1=1+b
y2=2+b
y3=3+b
y4=4+b
y5=5+b
y6=6+b
y7=7+b
y8=8+b
y9=9+b
y10=10+b
#delay
TS=0.0025
#Colours
night = graphics.create_pen(0,0,32)
black=graphics.create_pen(0,0,0)
grey=graphics.create_pen(50,50,50)
white=graphics.create_pen(255,255,255)
red=graphics.create_pen(255,0,0)
green=graphics.create_pen(0,255,0)
blue=graphics.create_pen(0,0,255)
yellow=graphics.create_pen(255,255,0)
brown=graphics.create_pen(150,75,0)
lbrown=graphics.create_pen(200,125,0)
graphics.set_pen(night)
graphics.clear()
#ground
graphics.set_pen(brown)
graphics.line(0,0,0,11)
def static():
#static rocket
graphics.set_pen(yellow)
graphics.pixel(x52,5)
graphics.line(x51,4,x51,7)
graphics.line(x50,3,x50,8)
graphics.set_pen(red)
graphics.pixel(x49,3)
graphics.line(x48,3,x50,5)
graphics.line(x45,3,x50,8)
graphics.line(x44,3,x49,8)
graphics.line(x41,3,x46,8)
graphics.line(x40,3,x45,8)
graphics.line(x37,3,x42,8)
graphics.line(x36,3,x41,8)
graphics.line(x33,3,x38,8)
graphics.line(x32,3,x37,8)
graphics.line(x32,6,x34,8)
graphics.pixel(x32,7)
graphics.set_pen(blue)
graphics.line(x47,3,x50,6)
graphics.line(x46,3,x50,7)
graphics.line(x43,3,x48,8)
graphics.line(x42,3,x47,8)
graphics.line(x39,3,x44,8)
graphics.line(x38,3,x43,8)
graphics.line(x35,3,x40,8)
graphics.line(x34,3,x39,8)
graphics.line(x32,4,x36,8)
graphics.line(x32,5,x35,8)
graphics.set_pen(green)
graphics.line(x31,3,x31,8)
#stick
graphics.set_pen(lbrown)
graphics.line(x1,8,x45,8)
galactic.update(graphics)
#Fuse
graphics.set_pen(blue)
graphics.pixel(x30,4)
graphics.pixel(x30,6)
graphics.pixel(x29,5)
graphics.pixel(x28,4)
graphics.pixel(x28,6)
graphics.pixel(x27,5)
#Flame
def flame():
b=-7
for j in range(8):
y0=0+b
y1=1+b
y2=2+b
y3=3+b
y4=4+b
y5=5+b
y6=6+b
y7=7+b
y8=8+b
y9=9+b
y10=10+b
f1=random.randint(100,255)
f2=random.randint(0,255)
flame=graphics.create_pen(f1,f2,0)
graphics.set_pen(flame)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
graphics.set_pen(lbrown)
graphics.pixel(x21,y4+1)
for k in range(12):
f1=random.randint(200,255)
f2=random.randint(0,255)
flame=graphics.create_pen(f1,f2,0)
graphics.set_pen(flame)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
time.sleep(0.0001)
galactic.update(graphics)
time.sleep(0.2)
graphics.set_pen(night)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
b=b+1
galactic.update(graphics)
def flame2():
b=0
y0=0+b
y1=1+b
y2=2+b
y3=3+b
y4=4+b
y5=5+b
y6=6+b
y7=7+b
y8=8+b
y9=9+b
y10=10+b
graphics.set_pen(red)
graphics.pixel(x27,5)
for k in range(250):
f1=random.randint(200,255)
f2=random.randint(0,255)
flame=graphics.create_pen(f1,f2,0)
graphics.set_pen(flame)
time.sleep(0.01)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
galactic.update(graphics)
def flame3():
b=0
for j in range(8):
y0=0+b
y1=1+b
y2=2+b
y3=3+b
y4=4+b
y5=5+b
y6=6+b
y7=7+b
y8=8+b
y9=9+b
y10=10+b
f1=random.randint(100,255)
f2=random.randint(0,255)
flame=graphics.create_pen(f1,f2,0)
graphics.set_pen(flame)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
graphics.set_pen(lbrown)
graphics.pixel(x21,y4-1)
for k in range(12):
f1=random.randint(200,255)
f2=random.randint(0,255)
flame=graphics.create_pen(f1,f2,0)
graphics.set_pen(flame)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
time.sleep(0.0001)
galactic.update(graphics)
time.sleep(0.2)
graphics.set_pen(night)
graphics.line(x25,y6,x27,y4)
graphics.line(x22,y5,x24,y3)
graphics.line(x23,y6,x26,y4)
graphics.pixel(x21,y4+1)
b=b-1
galactic.update(graphics)
def fuselit():
#Fuse
graphics.set_pen(red)
time.sleep(1)
graphics.pixel(x28,4)
graphics.pixel(x28,6)
galactic.update(graphics)
time.sleep(1)
graphics.pixel(x29,5)
galactic.update(graphics)
time.sleep(1)
graphics.pixel(x30,4)
graphics.pixel(x30,6)
galactic.update(graphics)
time.sleep(1)
#Exhaust
def exhaust():
x30=31
d=0
for n in range(10):
for m in range(20):
e1=random.randint(100,150)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.line(x30,3,x30+d,3)
e1=random.randint(100,200)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.line(x30,4,x30+d,4)
e1=random.randint(100,200)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.line(x30,5,x30+d,5)
e1=random.randint(100,200)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.line(x30,6,x30+d,6)
e1=random.randint(100,200)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.line(x30,7,x30+d,7)
galactic.update(graphics)
time.sleep(0.005)
d=d-1
#Lift off
def liftoff():
#rocket
a=0
d=0
x0=0+a
x1=1+a
x2=2+a
x3=3+a
x4=4+a
x5=5+a
x6=6+a
x7=7+a
x8=8+a
x9=9+a
x10=10+a
x11=11+a
x12=12+a
x13=13+a
x14=14+a
x15=15+a
x16=16+a
x17=17+a
x18=18+a
x19=19+a
x20=20+a
x21=21+a
x22=22+a
x23=23+a
x24=24+a
x25=25+a
x26=26+a
x27=27+a
x28=28+a
x29=29+a
x30=30+a
x31=31+a
x32=32+a
x33=33+a
x34=34+a
x35=35+a
x36=36+a
x37=37+a
x38=38+a
x39=39+a
x40=40+a
x41=41+a
x42=42+a
x43=43+a
x44=44+a
x45=45+a
x46=46+a
x47=47+a
x48=48+a
x49=49+a
x50=50+a
x51=51+a
x52=52+a
for i in range(55):
graphics.set_pen(yellow)
graphics.pixel(x52,5)
graphics.line(x51,4,x51,7)
graphics.line(x50,3,x50,8)
graphics.set_pen(red)
graphics.pixel(x49,3)
graphics.line(x48,3,x50,5)
graphics.line(x45,3,x50,8)
graphics.line(x44,3,x49,8)
graphics.line(x41,3,x46,8)
graphics.line(x40,3,x45,8)
graphics.line(x37,3,x42,8)
graphics.line(x36,3,x41,8)
graphics.line(x33,3,x38,8)
graphics.line(x32,3,x37,8)
graphics.line(x32,6,x34,8)
graphics.pixel(x32,7)
graphics.set_pen(blue)
graphics.line(x47,3,x50,6)
graphics.line(x46,3,x50,7)
graphics.line(x43,3,x48,8)
graphics.line(x42,3,x47,8)
graphics.line(x39,3,x44,8)
graphics.line(x38,3,x43,8)
graphics.line(x35,3,x40,8)
graphics.line(x34,3,x39,8)
graphics.line(x32,4,x36,8)
graphics.line(x32,5,x35,8)
graphics.set_pen(green)
graphics.line(x31,3,x31,8)
#stick
graphics.set_pen(lbrown)
graphics.line(x1,8,x45,8)
galactic.update(graphics)
time.sleep(0.01)
#rocket launch clear
graphics.set_pen(night)
graphics.pixel(x52,5)
graphics.line(x51,4,x51,7)
graphics.line(x50,3,x50,8)
graphics.pixel(x49,3)
graphics.line(x48,3,x50,5)
graphics.line(x45,3,x50,8)
graphics.line(x44,3,x49,8)
graphics.line(x41,3,x46,8)
graphics.line(x40,3,x45,8)
graphics.line(x37,3,x42,8)
graphics.line(x36,3,x41,8)
graphics.line(x33,3,x38,8)
graphics.line(x32,3,x37,8)
graphics.line(x32,6,x34,8)
graphics.pixel(x32,7)
graphics.line(x47,3,x50,6)
graphics.line(x46,3,x50,7)
graphics.line(x43,3,x48,8)
graphics.line(x42,3,x47,8)
graphics.line(x39,3,x44,8)
graphics.line(x38,3,x43,8)
graphics.line(x35,3,x40,8)
graphics.line(x34,3,x39,8)
graphics.line(x32,4,x36,8)
graphics.line(x32,5,x35,8)
graphics.line(x31,3,x31,8)
#stick
graphics.line(x1,8,x45,8)
#exhaust launch
e1=random.randint(100,150)
e2=random.randint(0,150)
exht=graphics.create_pen(e1,e2,0)
graphics.set_pen(exht)
graphics.rectangle(x1,3,29,5)
galactic.update(graphics)
time.sleep(0)
graphics.set_pen(night)
graphics.rectangle(x1,3,29,5)
d=d+1
a=a+1
x0=0+a
x1=1+a
x2=2+a
x3=3+a
x4=4+a
x5=5+a
x6=6+a
x7=7+a
x8=8+a
x9=9+a
x10=10+a
x11=11+a
x12=12+a
x13=13+a
x14=14+a
x15=15+a
x16=16+a
x17=17+a
x18=18+a
x19=19+a
x20=20+a
x21=21+a
x22=22+a
x23=23+a
x24=24+a
x25=25+a
x26=26+a
x27=27+a
x28=28+a
x29=29+a
x30=30+a
x31=31+a
x32=32+a
x33=33+a
x34=34+a
x35=35+a
x36=36+a
x37=37+a
x38=38+a
x39=39+a
x40=40+a
x41=41+a
x42=42+a
x43=43+a
x44=44+a
x45=45+a
x46=46+a
x47=47+a
x48=48+a
x49=49+a
x50=50+a
x51=51+a
x52=52+a
def burst():
x52=52
k=1
h=255
graphics.set_pen(grey)
for i in range(10):
graphics.line(x52+1,5,x52-k,5)
galactic.update(graphics)
time.sleep(0.25)
k=k+1
for r in range(12):
fgreen=graphics.create_pen(0,h,0)
graphics.set_pen(fgreen)
graphics.circle(x42,5,r)
graphics.circle(x38,4,r)
graphics.circle(x36,7,r)
galactic.update(graphics)
time.sleep(0.2)
graphics.set_pen(night)
graphics.circle(x42,5,r)
graphics.circle(x38,4,r)
graphics.circle(x36,7,r)
h=h-20
print(h)
galactic.update(graphics)
galactic.update(graphics)
static()
flame()
flame2()
flame3()
fuselit()
exhaust()
liftoff()
time.sleep(2)
burst()
I have a Galactic and Steller. I’ll try and have a look at what you posted on my Galactic over the weekend. Thanks for sharing.
I’m usually more than happy if my code “just works”, =)
I’m with you there. Once it “works” i tend to lose interest no matter how inefficient the code:-) Not aways though, just depends. Let me know what you think of the effect.
I hardly ever leave my code alone. I’m either trying to add something or tweaking the graphical display part of it. I have a tone of Pico’s on the go that just about all either have an LCD screen, or LED Matrix attached.