示例#1
0
    def draw(self, debug):
        off_centre = self.camera.adjust_pnt(self.centre, self.parallax_depth)

        s_dim = draw.get_dimensions()

        calls = []
         
        if debug:
            calls = calls + self.debug_draw()

        #top left tile
        width, height = off_centre.x, off_centre.y
        origin = Pnt(self.width-off_centre.x, self.height-off_centre.y)

        call = Draw_call('texture', self.depth)
        call.set_arg('texture', self.texture)
        call.set_arg('pos', off_centre+Pnt(-width,-height)/2)
        call.set_arg('area', Rect(width, height, origin))
        calls.append(call)

        #top right tile
        width, height = s_dim.x-off_centre.x, off_centre.y
        origin = Pnt(0,self.height-off_centre.y)

        call = Draw_call('texture', self.depth)
        call.set_arg('texture', self.texture)
        call.set_arg('pos', off_centre+Pnt(width, -height)/2)
        call.set_arg('area', Rect(width, height, origin))
        calls.append(call)

        #bottom left tile
        width, height = off_centre.x, s_dim.y-off_centre.y
        origin = Pnt(self.width-off_centre.x,0)

        call = Draw_call('texture', self.depth)
        call.set_arg('texture', self.texture)
        call.set_arg('pos', off_centre+Pnt(-width, height)/2)
        call.set_arg('area', Rect(width, height, origin))
        calls.append(call)

        #bottom right tile
        width, height = s_dim.x-off_centre.x, s_dim.y-off_centre.y
        origin = Pnt(0,0)

        call = Draw_call('texture', self.depth)
        call.set_arg('texture', self.texture)
        call.set_arg('pos', off_centre+Pnt(width, height)/2)
        call.set_arg('area', Rect(width, height, origin))
        calls.append(call)

        return calls
示例#2
0
 def update(self, delta):
     off_centre = self.camera.adjust_pnt(self.centre,self.parallax_depth)
     s_dim = draw.get_dimensions()
     if off_centre.x + self.width < s_dim.x:
         self.centre.x += self.width*self.parallax_depth
         
     elif off_centre.x - self.width > 0:
         self.centre.x -= self.width*self.parallax_depth
         
     if off_centre.y + self.height < s_dim.y:
         self.centre.y += self.height*self.parallax_depth
         
     elif off_centre.y - self.height > 0:
         self.centre.y -= self.height*self.parallax_depth