jakob
jakob.py — text/python-source, 3 KB (3551 bytes)
Dateiinhalt
# astroid
# Einbinden des 3D-Moduls
from visual import *
from math import *
from random import *
import time
# Szene-Einstellungen
scene.userzoom = True # User darf zoomen?
scene.userspin = True # User darf rotieren?
scene.forward = (0,0,-1) # Kameraposition
scene.autoscale = False # Autoskalierung aktiv?
scene.range = 12 # Kameraabstand von scene.center
scene.center = (0,0,0) # Kamerablickpunkt: norm. (0,0,0)
scene.up = (0,1,0) # Rotationsachse Kamera: norm. (0,1,0)
scene.background = color.black # Hintergrundfarbe
scene.fov = 1 # Kamerawinkeloeffnung: norm. 1
scene.fullscreen = true # Vollbild? norm. False
scene.title = "Koordinaten" # Fenstertitel
scene.width = 200 # Fensterbreite: norm. 200
scene.height = 200 # Fensterhoehe: norm 200
scene.x = 50 # x-Koordinate d. Fensters: norm. 0
scene.y = 25 # y-Koordinate d. Fensters: norm. 0
# Koordinatenachsen in Form von Pfeilen
#xAchse = arrow(axis=(10,0,0), shaftwidth=0.05, color=color.red)
#yAchse = arrow(axis=(0,10,0), shaftwidth=0.05, color=(0,0,1))
#zAchse = arrow(axis=(0,0,10), shaftwidth=0.05, color=color.green)
# Beschriftungen
#xLabel = label(pos=(10,0,0), text="x-Achse")
#yLabel = label(pos=(0,10,0), text="y-Achse")
#zLabel = label(pos=(0,0,10), text="z-Achse")
#frame()=gruppe
#class Name: def __init__(varaiblen):
#loeschen von objekten mit: 1. objekt.visible= False
# 2. del Objektname
#
class Asteroid (frame):
def __init__ (self,n=0,g=1,x=0,y=0,z=-50):
frame.__init__(self,pos=(x,y,z))
self.objekt1=sphere(frame=self,color=(0.5,0.5,0.5),radius=(g/1.4))
self.objekt2=box(frame=self,color=(0.5,0.5,0.5),length=g, height=g, width=g)
self.objekt3=box(frame=self,color=(0.5,0.5,0.5),length=g, height=g, width=g)
self.objekt3.rotate(angle=pi/4, axis=(1,0,0), origin=(0,0,0))
self.objekt3.rotate(angle=pi/4, axis=(0,1,0), origin=(0,0,0))
self.entfernung=g+0.2
zeit=0
liste =[]
listenlaenge=0
f=frame()
i=0
d=0
e=box(length=20, height=20, width=0,z=-10,color=color.orange)
while true:
print "lalala"
time.sleep(0.02)
zeit=zeit+0.02
#Asteroid erzeugen
if zeit > 1:
a=Asteroid(x=(random()-0.5)*8,y=(random()-0.5)*7,z=-50)
liste.append(a)
listenlaenge=(listenlaenge+1)
zeit=0
print "AsteroidAsteroidAsteroidAsteroidAsteroidAsteroidAsteroid"
###
#die komplette liste nach vorne verschieben
i=0
while i < listenlaenge:
i=i+1
liste[i-1].pos=(liste[i-1].x,liste[i-1].y,(liste[i-1].z+1))
print "es wird bewegt"
print i-1
###
#Asteroiden, die nicht mehr gesehen werden, loeschen
if listenlaenge>1:
print liste[0].z
if liste[0].z>0:
print "a"
liste[0].visible =False
d=0
print listenlaenge
print liste[1].z
while d<(listenlaenge-1):
print d
liste[d]=liste[d+1]
d=d+1
print "h"
print liste[0].z
#liste[listenlaenge-1].visible=False
#del liste[listenlaenge-1]
listenlaenge=(listenlaenge-1)
else:
if listenlaenge==1:
if liste[0].z>0:
print "b"
liste[0].visible =False
del liste[0]
listenlaenge=listenlaenge-1
###