ENTRY | DOWNLOAD | MANUAL | ONGOING | |
solarsystem.py"""Animate a solar system. by stephan) """ from slut import * class Atlantis(World): def onSetup(self): self.name = "Solar" self.width = 800 self.height = 600 self.showCoordinates = True self.camera.orbitBy(30, 30, 0) Sun(self, 'sun') self.sprites['sun'].enableMouseEvents() class Sun(Sprite): def __init__(self, parent, name): Sprite.__init__(self, parent, name) Planet(self, 'earth') self.sprites['earth'].enableMouseEvents() self.sprites['earth'].moveTo(1.0, 0.0, 0.0) self.sprites['earth'].rotBy(Thrust(0.0, 100.0, 0.0)) self.sprites['earth'].orbitBy(Thrust(0.0, 10.0, 0.0)) def onDraw(self): disc(0, 0, 0, 0.2) class Planet(Sprite): def __init__(self, parent, name): Sprite.__init__(self, parent, name) Moon(self, 'earthmoon') self.sprites['earthmoon'].enableMouseEvents() self.sprites['earthmoon'].moveTo(0.3, 0.0, 0.0) self.sprites['earthmoon'].orbitBy(Thrust(0.0, -180.0, 0.0)) def onDraw(self): disc(0, 0, 0, 0.1) class Moon(Sprite): def onDraw(self): disc(0, 0, 0, 0.02) atlantis = Atlantis() atlantis.run() |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |