Пример #1
0
    def __init__(self, color=(255,255,255)):
        self.normalImg = data.textures['grassblade.png']
        self.sweptOffImg = data.textures['grassblade_swept.png']
        self.blowing = True
        self.highlighted = False
        self.sweptOffEdge = False
        self.logicalX = random.randint(20,60)
        self.logicalY = random.randint(80,260)
        self.logicalZ = random.randint(100,150)
        super(Leaf,self).__init__(self.normalImg)
        self.origColor = color
        self.xy = logicalToPerspective(self.logicalX, self.logicalY)
        self.velocityX = 0.1
        self.velocityY = 0
        self.velocityZ = 0
        self.lifetime = 30

        self.image.anchor_x = self.image.width/2
        self.image.anchor_y = 7
        self.clumpMates = []

        self.windEffects = {'duration': 0,
                            'offset': 0,
                            'flutter': 0,
                            'countdown': 0,
                           }

        #print 'created leaf at', self.logicalX, self.logicalY
        #print 'at', self.xy
        window.game_window.push_handlers(self.on_mouse_scroll)
        window.game_window.push_handlers(self.on_mouse_press)
        window.game_window.push_handlers(self.on_mouse_motion)
        events.AddListener(self)
Пример #2
0
    def update(self, timeChange):
        newY = self.logicalY
        newX = self.logicalX
        if self.windEffects['countdown'] > 0:
            # TODO: not quite perfect math here. but approximate
            intensity = 1.0 - abs(self.windEffects['duration']/2 - (self.windEffects['duration']-self.windEffects['countdown']))
            self.windEffects['countdown'] -= timeChange
            if self.windEffects['countdown'] <= 0:
                newX = self.logicalX
            newX = self.logicalX + self.windEffects['offset']*intensity +\
                     random.randint(*self.windEffects['flutter'])
        if newX != self.logicalX:
            delta = newX-self.logicalX
            if self.north:
                self.north.pullX( delta/4 )
            if self.south:
                self.south.pullX( delta/4 )
            if newX > self.logicalX:
                if self.west:
                    self.west.pullX( delta/2 )
            else:
                if self.east:
                    self.east.pullX( delta/2 )

        self.xy = logicalToPerspective(newX, newY)
        self.y += self.logicalZ*self.scale
Пример #3
0
    def __init__(self, pos):
        img = data.textures['grassblade.png']
        rabbyt.sprites.Sprite.__init__(self, img)
        self.logicalX = pos[0]
        self.logicalY = pos[1]
        self.xy = logicalToPerspective(*pos)
        self.scale = (1.0 + (300.0-pos[1])/200.0)/2
        self.logicalZ = random.randint(-2,3)

        self.north, self.east, self.south, self.west = None,None,None,None

        self.windEffects = {'duration': 0,
                            'offset': 0,
                            'flutter': 0,
                            'countdown': 0,
                           }
Пример #4
0
 def setLogicalXY(self, x, y):
     self.logicalX = x
     self.logicalY = y
     self.xy = logicalToPerspective(x,y)
Пример #5
0
 def setLogicalXY(self, x, y):
     self.logicalX = x
     self.logicalY = y
     self.xy = logicalToPerspective(x,y)
     self.scale = (1.0 + (300.0-y)/200.0)/2