Python Forum
The graphic/simulator is not loading in OOP version
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The graphic/simulator is not loading in OOP version
#1
I transformed my existing code to an OOP version. Now I have the problem that the plantes of my solar system are not loaded anymore. Nothing is loaded. Just a white screen. But I also dont get any errors showing whats wrong. It should be exactly the same just in OOP. So its first the parameters for the program to calculate with. And then the different Planets coming. In the normal Version I shortened it, it just continues till Pluto.

Normal Code:

#array liste von Planeten
    planets = []

    #Sonne
    sun = sphere(pos = vec(0,0,0), radius = s_rad1,texture = "http://i.imgur.com/yoEzbtg.jpg", make_trail = True ) 
    sun.mass = 2e30   
    sun.velocity = vec(0,0,0)

    #Merkur
    mercury = sphere(pos = vec(ae/3,0,0), radius = s_rad1/2, color=color.red, make_trail = True ) 
    mercury.mass = 3.25e23
    mercury.velocity = vec(0,0,-47000)

    #Venus
    venus = sphere(pos = vec(ae/1.6,0,0), radius = s_rad1/1.8, color=color.cyan, make_trail = True ) 
    venus.mass = 4.9e24
    venus.velocity = vec(0,0,-35000)

    #Erde
    earth = sphere (pos = vec(ae, 0, 0), radius = e_rad, texture = "http://i.imgur.com/rhFu01b.jpg", make_trail = True)
    earth.mass = 5.9e24    
    earth.velocity = vec(0,0,-25000)#bewegt sich mit 30000 ms



    #Mars
    mars = sphere (pos = vec(ae*1.52, 0, 0), radius = s_rad1/1.8, make_trail = True, color = color.red)
    mars.mass = 6.4e23    
    mars.velocity = vec(0,0,-24000)#bewegt sich mit 30000 ms

...

planets.extend((mercury,venus,earth,mars,jupiter,saturn,uranus,neptun,pluto))
OOP VERSION:


#array liste von Planeten
planets = []


class Sphere(object):
    def __init__(self, pos, radius, make_trail):
        self.pos = pos
        self.radius = radius
        self.make_trail = make_trail


class Planet(Sphere):
    def __init__(self, pos, radius, make_trail, mass, velocity):
        super().__init__(pos, radius, make_trail)
        self.mass = mass
        self.velocity = velocity


sun = Planet(pos=vec(0,0,0),radius=s_rad1, make_trail=True, mass=2e30, velocity=vec(0,0,0))
mercury = Planet(pos=vec(ae/3,0,0), radius=s_rad1/2, make_trail=True, mass=3.25e23, velocity=vec(0,0,-47000))
venus = Planet(pos=vec(ae/1.6,0,0), radius=s_rad1/1.8, make_trail=True, mass=4.9e24, velocity=vec(0,0,-35000))
earth = Planet(pos=vec(ae,0,0), radius=e_rad, mass=5.9e24, make_trail=True, velocity=vec(0,0,-25000))
mars =  Planet(pos=vec(ae*1.52,0,0), radius=s_rad1/1.8, make_trail=True, mass=6.4e23, velocity=vec(0,0,-24000))
jupiter = Planet(pos=vec(ae*5.18,0,0), radius=s_rad1/1.2, make_trail=True, mass=10e27, velocity=vec(0,0,-9678))
saturn = Planet(pos=vec(ae*9.5,0,0), radius=s_rad1/1.4, make_trail=True, mass=5.7e26, velocity=vec(0,0,-7678))
uranus = Planet(pos=vec(ae*19.13,0,0), radius=s_rad1/1.7, make_trail=True, mass=8.7e25, velocity=vec(0,0,-6772))
neptun = Planet(pos=vec(ae*30,0,0), radius=s_rad1/1.7, make_trail=True, mass=1.02e26, velocity=vec(0,0,-5344))
pluto = Planet(pos=vec(ae*39.37,0,0), radius=s_rad1/2.4, make_trail=True, mass=1.3e22, velocity=vec(0,0,-4740))

planets.extend((mercury,venus,earth,mars,jupiter,saturn,uranus,neptun,pluto))
Reply


Messages In This Thread
The graphic/simulator is not loading in OOP version - by Caturix99 - Sep-05-2018, 06:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Graphic line plot with matplotlib, text file in pytho khadija 2 1,340 Aug-15-2022, 12:00 PM
Last Post: khadija
  elevator simulator...whats the wrong at this code? tasos710 5 5,858 Jun-11-2019, 01:38 AM
Last Post: micseydel
  Embedding Python into a simulator siggi 0 2,170 Apr-24-2019, 07:42 PM
Last Post: siggi
  Can I upload a new version without previously deleting ancient version sylas 6 4,183 Nov-08-2017, 03:26 PM
Last Post: Larz60+
  Graphic of total different connection opened by one ip (per seconds) by time FoxModem56k 0 3,175 May-25-2017, 03:27 PM
Last Post: FoxModem56k

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020