ENTRY | DOWNLOAD | MANUAL | ONGOING | |
tween.py"""Two polygons are moved and rotated as the scene starts up. All of these tweens are implemented using sine tweens. The movement/rotation starts slowly, peaks when half way through and slows down again. The rotation takes two seconds (fourth parameter to the tween constructor) and the movements one second to complete. Both polygons also listen to LMB (left mouse button) clicks. They move by 1.0 to the left and, when the shift key is pressed, to the right. Left movement uses a sine tween and right movement a linear tween. by stephan) """ from slut import * class Atlantis(World): def onSetup(self): self.name = "Tweens" self.width = 400 self.height = 300 self.showCoordinates = True p1 = Polygon(self, 'poly1') p2 = Polygon(self, 'poly2') p1.enableMouseEvents() p2.enableMouseEvents() p1.moveBy(SineTween(1.0, 0.0, 0.0, 1.0)) p2.moveBy(SineTween(-1.5, 0.0, -1.5, 1.0)) p2.rotBy(SineTween(90.0, 0.0, 20.0, 2.0)) p1.enableMouseEvents() 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() def onMouseButtonDown(self, event): if glo.ia.SHIFT: self.moveBy(Tween(1.0, 0.0, 0.0, 1.0)) else: self.moveBy(SineTween(-1.0, 0.0, 0.0, 1.0)) atlantis = Atlantis() atlantis.run() |
|
Initiated by Stephan Hechenberger Thanks to CADRE's 103 |