| importwebbrowser |
| fromvpythonimport* |
| fromcollectionsimportnamedtuple |
| importtkinterastk |
| |
| #webbrowser.open_new("https://images-assets.nasa.gov/image/PIA15416/PIA15416~medium.jpg") |
| |
| print('Hello and welcome to NASA Planet Builder lab! You are about to create your brand new planet!') |
| yesno=input('Are you ready? {yes or no}').lower() |
| |
| ifyesno=='yes': |
| print('Perfect! We are very excited to have you in our team!') |
| else: |
| whileyesno!='yes'.lower(): |
| yesno=input('Are you sure? Maybe you want to reconsider your answer {yes or no}') |
| |
| name=input("So, what's your name?") |
| print('Hello',name,', nice to meet you!') |
| |
| print() |
| |
| planetname=input("First of all, we want you to decide your planet's name... What will it be?") |
| print('Ok, seems that',planetname,"isn't taken yet!") |
| print("Now we have to decide where your planet is going to be placed, so we suggest you to choose a galaxy you could consider your ''home''.") |
| |
| print() |
| |
| print('Right now, we can offer you these: Milky Way, Andromeda, Pegasus, Whirlpool and Tadpole') |
| planetlocation=input('Which one are you choosing?').lower() |
| |
| if (planetlocation=='milky way'orplanetlocation=='andromeda'orplanetlocation=='pegasus'or |
| planetlocation=='whirlpool'orplanetlocation=='tadpole'): |
| ifplanetlocation=='milky way': |
| planetlocation='Milky Way' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('https: // images - assets.nasa.gov / image / PIA10748 / PIA10748~medium.jpg') |
| print('The Milky Way looks awesome!') |
| ifplanetlocation=='andromeda': |
| planetlocation='Andromeda' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new("https://images-assets.nasa.gov/image/PIA15416/PIA15416~medium.jpg") |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='pegasus': |
| planetlocation='Pegasus' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('http://cs.astronomy.com/cfs-file.ashx/__key/telligent-evolution-components-attachments/13-58-00-00-00-49-23-40/UGC-12613-_2D00_-LRGB.jpg') |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='whirlpool': |
| planetlocation='Whirlpool' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('https://images-assets.nasa.gov/image/PIA04230/PIA04230~thumb.jpg') |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='tadpole': |
| planetlocation='Tadpole' |
| print(planetlocation,"is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('https://images-assets.nasa.gov/image/hubble-reveals-stellar-fireworks-in-skyrocket-galaxy_27946907106_o/hubble-reveals-stellar-fireworks-in-skyrocket-galaxy_27946907106_o~thumb.jpg') |
| print('A picture of your new home has just opened!') |
| else: |
| planetlocation=input('Sorry, your option is not in the list, could you choose again? {select an item from the list again}') |
| |
| print() |
| |
| yn=input("Great location, right? {yes or no}") |
| ifyn=='yes': |
| print('Perfect!') |
| else: |
| whileyn!='yes'.lower(): |
| planetlocation=input('Choose another option!') |
| if (planetlocation=='milky way'orplanetlocation=='andromeda'orplanetlocation=='pegasus'or |
| planetlocation=='whirlpool'orplanetlocation=='tadpole'): |
| ifplanetlocation=='milky way': |
| planetlocation='Milky Way' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('https: // images - assets.nasa.gov / image / PIA10748 / PIA10748~medium.jpg') |
| print('The Milky Way looks awesome!') |
| ifplanetlocation=='andromeda': |
| planetlocation='Andromeda' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new("https://images-assets.nasa.gov/image/PIA15416/PIA15416~medium.jpg") |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='pegasus': |
| planetlocation='Pegasus' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new( |
| 'http://cs.astronomy.com/cfs-file.ashx/__key/telligent-evolution-components-attachments/13-58-00-00-00-49-23-40/UGC-12613-_2D00_-LRGB.jpg') |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='whirlpool': |
| planetlocation='Whirlpool' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new('https://images-assets.nasa.gov/image/PIA04230/PIA04230~thumb.jpg') |
| print('A picture of your new home has just opened!') |
| ifplanetlocation=='tadpole': |
| planetlocation='Tadpole' |
| print(planetlocation, "is perfect! We are sure you're going to love it!") |
| webbrowser.open_new( |
| 'https://images-assets.nasa.gov/image/hubble-reveals-stellar-fireworks-in-skyrocket-galaxy_27946907106_o/hubble-reveals-stellar-fireworks-in-skyrocket-galaxy_27946907106_o~thumb.jpg') |
| print('A picture of your new home has just opened!') |
| else: |
| planetlocation=input( |
| 'Sorry, your option is not in the list, could you choose again? {select an item from the list again}') |
| yn=input('Do you like this one? {yes or no}') |
| |
| print() |
| |
| ifplanetlocation=='Milky Way': |
| print("We are already in the Milky Way, so you're not going too far!") |
| print('Since you are staying in our galaxy, we will add',planetname,'to our Solar System') |
| ifplanetlocation=='Andromeda': |
| print('Did you know Andromeda is 2.537 millions of Light Years away? The journey will get exciting!') |
| print('Since',planetname,'is in Andromeda, it will be orbiting Upsilon Andromedae') |
| ifplanetlocation=='Pegasus': |
| print('Did you know Pegasus is 3.001 millions of Light Years away? The journey will get exciting!') |
| print('Since', planetname, 'is in Pegasus, it will be orbiting 51 Pegasi') |
| ifplanetlocation=='Whirlpool': |
| print('Did you know Whirlpool is 30 millions of Light Years away? The journey will get exciting!') |
| print('Since', planetname, 'is in Whirlpool, it will be orbiting Asterion') |
| ifplanetlocation=='Tadpole': |
| print('Did you know Tadpole is 420 millions of Light Years away? The journey will get exciting!') |
| print('Since', planetname, 'is in Tadpole, it will be orbiting Giausar') |
| |
| print() |
| |
| print('Perfect! Are you ready to contiue?') |
| yesno2=input('Are you ready? {yes or no}').lower() |
| |
| ifyesno2=='yes': |
| print('Ok!') |
| else: |
| whileyesno2!='yes'.lower(): |
| yesno2=input('Sure? {yes or no}') |
| |
| print() |
| |
| print("Ok, so now that we have the perfect location, let's start building",planetname,'!') |
| |
| print() |
| |
| rawplanet=sphere(radius=5) |
| planetscene=canvas(title='Planet',width=800, height=500) |
| |
| |
| |
| print("Wow, that planet looks so sad! It's time to give it some colour!") |
| |
| print("You can decide between these colours, the colour you choose will determine what your planet is made of: " |
| "Oranje, salmon, beige, green, dark blue, light blue") |
| |
| planetcolour=input('Which one do you prefer?').lower() |
| |
| print() |
| |
| if (planetcolour=='orange'orplanetcolour=='salmon'orplanetcolour=='beige'or |
| planetcolour=='green'orplanetcolour=='dark blue'orplanetcolour=='light blue'): |
| ifplanetcolour=='orange': |
| |
| orangeplanet=sphere(radius=5,shininess=0,color=vector(255, 1, 0), texture="https://st.depositphotos.com/2331871/3374/i/950/depositphotos_33746135-stock-photo-cement-background-with-a-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='salmon': |
| |
| salmonplanet=sphere(radius=5,shininess=0,texture="https://st2.depositphotos.com/1012885/10581/i/450/depositphotos_105813258-stock-photo-large-grunge-textures-and-backgrounds.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='beige': |
| |
| beigeplanet=sphere(radius=5,shininess=0,texture="https://static4.depositphotos.com/1014905/305/i/450/depositphotos_3057810-stock-photo-grunge-and-beige-background-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='green': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://static8.depositphotos.com/1008191/989/i/450/depositphotos_9898616-stock-photo-green-background-with-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='dark blue': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://st2.depositphotos.com/2495215/5942/i/450/depositphotos_59427461-stock-photo-dark-blue-stone-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| |
| ifplanetcolour=='light blue': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://st4.depositphotos.com/13193824/20986/i/450/depositphotos_209866464-stock-photo-close-view-dark-rough-wall.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| yesno3=input("Do you like the colour of your planet? {yes or no}").lower() |
| whileyesno3=='no': |
| planetcolour=input("Choose a new colour!") |
| ifplanetcolour=='orange': |
| |
| orangeplanet=sphere(radius=5,shininess=0,color=vector(255, 1, 0), texture="https://st.depositphotos.com/2331871/3374/i/950/depositphotos_33746135-stock-photo-cement-background-with-a-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='salmon': |
| |
| salmonplanet=sphere(radius=5,shininess=0,texture="https://st2.depositphotos.com/1012885/10581/i/450/depositphotos_105813258-stock-photo-large-grunge-textures-and-backgrounds.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='beige': |
| |
| beigeplanet=sphere(radius=5,shininess=0,texture="https://static4.depositphotos.com/1014905/305/i/450/depositphotos_3057810-stock-photo-grunge-and-beige-background-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='green': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://static8.depositphotos.com/1008191/989/i/450/depositphotos_9898616-stock-photo-green-background-with-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| ifplanetcolour=='dark blue': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://st2.depositphotos.com/2495215/5942/i/450/depositphotos_59427461-stock-photo-dark-blue-stone-texture.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| |
| ifplanetcolour=='light blue': |
| greenplanet=sphere(radius=5,shininess=0, |
| texture="https://st4.depositphotos.com/13193824/20986/i/450/depositphotos_209866464-stock-photo-close-view-dark-rough-wall.jpg") |
| planetscene=canvas(title='Planet', width=800, height=500) |
| |
| yesno3=input('What about this? {yes or no}') |
| |
| print() |
| |
| print("Awesome!",planetname,"it's fantastic!") |
| |
| print("Let's take a ride and see",planetname,"!") |
| |
| ifplanetcolour=='orange': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| orangeplanet=sphere(radius=5, shininess=0, color=vector(255, 1, 0), |
| texture="https://st.depositphotos.com/2331871/3374/i/950/depositphotos_33746135-stock-photo-cement-background-with-a-texture.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| orangeplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| orangeplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| orangeplanet.rotate(angle=orangeplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=orangeplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=orangeplanet.pos) |
| |
| ifplanetcolour=='salmon': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| salmonplanet=sphere(radius=5, shininess=0, |
| texture="https://st2.depositphotos.com/1012885/10581/i/450/depositphotos_105813258-stock-photo-large-grunge-textures-and-backgrounds.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| salmonplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| salmonplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| salmonplanet.rotate(angle=salmonplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=salmonplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=salmonplanet.pos) |
| |
| ifplanetcolour=='beige': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| beigeplanet=sphere(radius=5, shininess=0, |
| texture="https://static4.depositphotos.com/1014905/305/i/450/depositphotos_3057810-stock-photo-grunge-and-beige-background-texture.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| beigeplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| beigeplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| beigeplanet.rotate(angle=beigeplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=beigeplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=beigeplanet.pos) |
| |
| ifplanetcolour=='green': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| greenplanet=sphere(radius=5, shininess=0, |
| texture="https://static8.depositphotos.com/1008191/989/i/450/depositphotos_9898616-stock-photo-green-background-with-texture.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| greenplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| greenplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| greenplanet.rotate(angle=greenplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=greenplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=greenplanet.pos) |
| |
| ifplanetcolour=='dark blue': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| greenplanet=sphere(radius=5, shininess=0, |
| texture="https://st2.depositphotos.com/2495215/5942/i/450/depositphotos_59427461-stock-photo-dark-blue-stone-texture.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| greenplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| greenplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| greenplanet.rotate(angle=greenplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=greenplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=greenplanet.pos) |
| |
| |
| ifplanetcolour=='light blue': |
| |
| scene.lights[0].visible=False |
| sun=sphere(color=vector(1, 1, 0), pos=vec(0, 0, 0), radius=1.5, shininess=0, emissive=True) |
| greenplanet=sphere(radius=5, shininess=0, |
| texture="https://st4.depositphotos.com/13193824/20986/i/450/depositphotos_209866464-stock-photo-close-view-dark-rough-wall.jpg") |
| moon=sphere(color=vector(0.5, 0.5, 0.5), pos=vec(12, 0, 0), radius=0.5, shininess=10, make_trail=True) |
| lamp=local_light(pos=vector(0, 0, 0), color=vector(1, 1, 1)) |
| |
| greenplanet.make_trail=True |
| moon.make_trail=False |
| framerate=50 |
| |
| greenplanetOmega=2*3.14159/365 |
| |
| moonAngle=0 |
| moonOmega=2*3.14159/28 |
| |
| whileTrue: |
| rate(framerate) |
| greenplanet.rotate(angle=greenplanetOmega, axis=vector(0, 1, 0), origin=vector(0, 0, 0)) |
| |
| moonAngle+=moonOmega |
| |
| moon.pos=greenplanet.pos+vector(2, 0, 0) |
| moon.rotate(angle=moonAngle, axis=vector(0, 1, 0), origin=greenplanet.pos) |
| |
| |
| |
| |
| |