thrust_sine.py

"""Grass in the wind, really.
   by stephan)
"""
from slut import *

class Atlantis(World):
    def onSetup(self):
        self.name = "Sine"
        self.width = 200
        self.height = 150
        self.showCoordinates = True
        Polygon(self, 'poly1').enableMouseEvents()
        Polygon(self, 'poly2').enableMouseEvents()
        Polygon(self, 'poly3').enableMouseEvents()
        self.sprites['poly1'].moveBy(1.0, 0.0, 0.0)
        self.sprites['poly3'].moveBy(-1.0, 0.0, 0.0)
        self.sprites['poly1'].rotBy(0.0, 80.0, -15.0)
        self.sprites['poly2'].rotBy(0.0, 89.0, -15.0)
        self.sprites['poly3'].rotBy(0.0, 100.0, -15.0)
        self.sprites['poly1'].rotBy(SineThrust(0.0, 0.0, 20.0))
        self.sprites['poly2'].rotBy(SineThrust(0.0, 0.0, 20.0))
        self.sprites['poly3'].rotBy(SineThrust(0.0, 0.0, 20.0))
        self.sprites['poly1'].enableMouseEvents()

        #make a mpeg movie
        from slut.context import AnimatedGifMaker
        self.addContext(AnimatedGifMaker(0, 200))

class Polygon(Sprite):
    def onDraw(self):
        glBegin(GL_POLYGON)
        glVertex3f(0.0, 0.0, 0.0)
        glVertex3f(1.0, 0.0, 0.0)
        glVertex3f(1.0, 1.0, 0.0)
        glVertex3f(-0.5, 1.5, 0.0)
        glVertex3f(0.0, 0.0, 0.0)
        glEnd()


class SineThrust(Thrust):
    """This is redundant."""
    def thrustfunc(self, change):
        return (math.sin(self.time))*(change/glo.fps)


atlantis = Atlantis()
atlantis.run()
Initiated by Stephan Hechenberger
Thanks to CADRE's 103