MAIN
MAIN.py — text/python-source, 8 KB (9132 bytes)
Dateiinhalt
from Engine import * from Objects import * from Raumschiff import * from Umgebung import * from math import * from random import random #scene.stereo ="redcyan" import Image name = "moon" width = 1024 height = 512 im = Image.open(name+".tga") materials.saveTGA(name,im) mondtextur = materials.texture(data=im, mapping="spherical") engine = Engine(25) scene.autoscale=0 r=Raumschiff(vector((100,100,100)),vector((1.1,1.1,-3.1)),3,1 ) engine.addObject(r) b=box(material=materials.earth) s = sphere(pos = (0, 0, 0, ), radius = 1000, color = (0, 0, 1), material = mondtextur) scene.lights=[distant_light(direction=(0.22, 0.44, 0.88), color=color.gray(0.4))] # nur schwaches 'Weltraumlicht' sonne = Planet(pos=(0,0,0),radius=75, color = (1,1,0), material=materials.emissive) sonnenlicht = local_light(pos=(0,0,0), color=color.white) color1 = (1,0.7,0.3) asteroid1 = Planet(pos = (-500, -400, -450), axis =2*pi*random(),radius = 25, \ color = (1.0, 0, 0), umkreiszeit=50, zentrum=sonne, abstand_zentrum=sqrt(500**2+400**2+450**2)) asteroid2 = Planet(pos = (400, -540, -650), axis =2*pi*random(),radius = 55, \ color = color1, material=mondtextur, umkreiszeit=100, zentrum=sonne, abstand_zentrum=sqrt(400**2+540**2+650**2)) asteroid4 = Planet(pos = (-730, -500, 550), axis =2*pi*random(),radius = 42, \ color = color1, material=mondtextur, umkreiszeit=150, zentrum=sonne, abstand_zentrum=sqrt(730**2+500**2+550**2)) asteroid5 = Planet(pos = (-650, 450, -550), axis = 2*pi*random(),radius = 30, \ color = color1, material=mondtextur, umkreiszeit=90, zentrum=sonne, abstand_zentrum=sqrt(650**2+450**2+550**2)) asteroid6 = Planet(pos = (600, -500, 450), axis =2*pi*random(),radius = 40, \ color = color1, material=mondtextur, umkreiszeit=70, zentrum=sonne, abstand_zentrum=sqrt(600**2+500**2+450**2)) asteroid7 = Planet(pos = (600, 770, -650), axis =2*pi*random(),radius = 35, \ color = color1, material=mondtextur, umkreiszeit=60, zentrum=sonne, abstand_zentrum=sqrt(600**2+770**2+650**2)) asteroid8 = Planet(pos = (-450, 450, 500), axis =2*pi*random(),radius = 46, \ color = color1, material=mondtextur,umkreiszeit=66, zentrum=sonne, abstand_zentrum=sqrt(450**2+450**2+500**2)) asteroid9 = Planet(pos = (450, 500, 350), axis =2*pi*random(),radius = 15, \ color = color1, material=mondtextur, umkreiszeit=80, zentrum=sonne, abstand_zentrum=sqrt(450**2+500**2+350**2)) asteroid10 = Planet(pos = (-650,-680, -654), axis =2*pi*random(),radius = 10,\ color = color1, material=mondtextur,umkreiszeit=100, zentrum=sonne, abstand_zentrum=sqrt(650**2+680**2+654**2)) asteroid11 = Planet(pos = (-290, -200, 200), axis =2*pi*random(),radius = 16, \ color = color1, material=mondtextur, umkreiszeit=110, zentrum=sonne, abstand_zentrum=sqrt(290**2+200**2+200**2)) asteroid12 = Planet(pos = (-420, 300, -500), axis =2*pi*random(),radius = 17, \ color = color1, material=mondtextur, umkreiszeit=120, zentrum=sonne, abstand_zentrum=sqrt(420**2+300**2+500**2)) asteroid13 = Planet(pos = (400, -500, -540),axis =2*pi*random(),radius = 20, \ color = color1, material=mondtextur, umkreiszeit=50, zentrum=sonne, abstand_zentrum=sqrt(400**2+500**2+540**2)) asteroid14 = Planet(pos = (-450, 590, 600), axis =2*pi*random(),radius = 25, \ color = color1, material=mondtextur, umkreiszeit=40, zentrum=sonne, abstand_zentrum=sqrt(450**2+590**2+600**2)) asteroid15 = Planet(pos = (650,660, -500), axis =2*pi*random(),radius = 26, \ color = color1, material=mondtextur, umkreiszeit=30, zentrum=sonne, abstand_zentrum=sqrt(650**2+660**2+500**2)) asteroid16 = Planet(pos = (400, -650, 680), axis =2*pi*random(),radius = 10, \ color = color1, material=mondtextur, umkreiszeit=70, zentrum=sonne, abstand_zentrum=sqrt(400**2+650**2+680**2)) asteroid17 = Planet(pos = (500, 453, 660), axis =2*pi*random(),radius = 45, \ color = color1, material=mondtextur, umkreiszeit=90, zentrum=sonne, abstand_zentrum=sqrt(500**2+453**2+660**2)) asteroid18 = Planet(pos = (-650, -600, 540), axis =2*pi*random(),radius = 24, \ color = color1, material=mondtextur,umkreiszeit=80, zentrum=sonne, abstand_zentrum=sqrt(650**2+600**2+540**2)) asteroid19 = Planet(pos = (580, -400, -650),axis =2*pi*random(),radius = 40, \ color = color1, material=mondtextur,umkreiszeit=70, zentrum=sonne, abstand_zentrum=sqrt(580**2+400**2+650**2)) asteroid20 = Planet(pos = (-450, 500, -350), axis =2*pi*random(),radius = 30, \ color = color1, material=mondtextur,umkreiszeit=60, zentrum=sonne, abstand_zentrum=sqrt(450**2+500**2+350**2)) asteroid21 = Planet(pos = (-250, -450, 250), axis =2*pi*random(),radius = 34, \ color = color1, material=mondtextur,umkreiszeit=60, zentrum=sonne, abstand_zentrum=sqrt(250**2+450**2+250**2)) asteroid22 = Planet(pos = (450, -350, 350),axis =2*pi*random(),radius = 29, \ color = color1, material=mondtextur,umkreiszeit=60, zentrum=sonne, abstand_zentrum=sqrt(450**2+350**2+350**2)) asteroid23 = Planet(pos = (-120, 160,250), axis =2*pi*random(),radius = 50, \ color = color1, material=mondtextur,umkreiszeit=60, zentrum=sonne, abstand_zentrum=sqrt(120**2+160**2+250**2)) asteroid24 = Planet(pos = (500, 400, -450), axis =2*pi*random(),radius = 45, \ color = color1, material=mondtextur,umkreiszeit=80, zentrum=sonne, abstand_zentrum=sqrt(500**2+400**2+450**2)) asteroid25= Planet(pos = (180, 190, 210), axis =2*pi*random(),radius = 40, \ color = color1, material=mondtextur,umkreiszeit=120, zentrum=sonne, abstand_zentrum=sqrt(180**2+190**2+210**2)) asteroid26 = Planet(pos = (-230, -170, -250), axis =2*pi*random(),radius = 66, \ color = color1, material=mondtextur,umkreiszeit=40, zentrum=sonne, abstand_zentrum=sqrt(230**2+170**2+250**2)) asteroid27 = Planet(pos = (-500, 460, -450), axis =2*pi*random(),radius = 34, \ color = color1, material=mondtextur,umkreiszeit=180, zentrum=sonne, abstand_zentrum=sqrt(500**2+460**2+450**2)) asteroid28 = Planet(pos = (-380, -360, 280), axis =2*pi*random(),radius = 46, \ color = color1, material=mondtextur,umkreiszeit=190, zentrum=sonne, abstand_zentrum=sqrt(380**2+360**2+280**2)) asteroid29 = Planet(pos = (380, -510, -450), axis =2*pi*random(),radius = 22, \ color = color1, material=mondtextur,umkreiszeit=170, zentrum=sonne, abstand_zentrum=sqrt(380**2+510**2+450**2)) asteroid30 = Planet(pos = (690, -560, 490), axis =2*pi*random(),radius = 22, \ color = color1, material=mondtextur,umkreiszeit=160, zentrum=sonne, abstand_zentrum=sqrt(690**2+560**2+490**2)) asteroid31 = Planet(pos = (-550, 450, 450), axis =2*pi*random(),radius = 26, \ color = color1, material=mondtextur,umkreiszeit=140, zentrum=sonne, abstand_zentrum=sqrt(550**2+450**2+450**2)) asteroid32 = Planet(pos = (400, 200, -300), axis =2*pi*random(),radius = 20, \ color = color1, material=mondtextur,umkreiszeit=200, zentrum=sonne, abstand_zentrum=sqrt(400**2+200**2+300**2)) asteroid33 = Planet(pos = (350, 400, 350), axis =2*pi*random(),radius = 15, \ color = color1, material=mondtextur,umkreiszeit=150, zentrum=sonne, abstand_zentrum=sqrt(350**2+400**2+350**2)) engine.addObject(sonne) engine.addObject(asteroid1) engine.addObject(asteroid2) engine.addObject(asteroid4) engine.addObject(asteroid5) engine.addObject(asteroid6) engine.addObject(asteroid7) engine.addObject(asteroid8) engine.addObject(asteroid9) engine.addObject(asteroid10) engine.addObject(asteroid11) engine.addObject(asteroid12) engine.addObject(asteroid13) engine.addObject(asteroid14) engine.addObject(asteroid15) engine.addObject(asteroid16) engine.addObject(asteroid17) engine.addObject(asteroid18) engine.addObject(asteroid19) engine.addObject(asteroid20) engine.addObject(asteroid21) engine.addObject(asteroid22) engine.addObject(asteroid23) engine.addObject(asteroid24) engine.addObject(asteroid25) engine.addObject(asteroid26) engine.addObject(asteroid27) engine.addObject(asteroid28) engine.addObject(asteroid29) engine.addObject(asteroid30) engine.addObject(asteroid31) engine.addObject(asteroid32) engine.addObject(asteroid33) engine.start() scene.ambient = 0.5 scene.userzoom = 0 scene.userspin = 0 a = sphere(pos=(100,200,100),radius= 15, color = (0,0,1)) counter = 0 label = label(heigth = 50, pos=(0,0,0),text="Punkte") while 1: if 18 > abs(r.position - a.pos): a.pos =(random()*500, random()*500, random()*500) counter += 1 label.text = "Punkte: " + str(counter) sleep(0.5) scene.fullscreen=1