Example #1
0
 def draw_object_layer(self, layer):
     if layer.name == 'Collision Layer' or \
         layer.name == 'Trigger Layer':
         if game_framework.debug:
             pico2d_extension.set_color(127, 127, 127)
             for object in layer.objects:
                 pico2d_extension.draw_rectangle(*self.to_object_rect(object))
     else:
         pico2d_extension.set_color(255, 255, 0)
         for object in layer.objects:
             if object.visible:
                 gid = object.gid
                 tileset = self.to_tileset(gid)
                 if tileset is not None:
                     rect = self.to_tileset_object_rect(object)
                     tileset.image.clip_draw_to_origin(*self.to_rect(gid), x=rect[0], y=rect[1], w=object.width, h=object.height)
                     if game_framework.debug:
                         pico2d_extension.draw_rectangle(*rect)
Example #2
0
def get_intersect_rect(o1_left,o1_bottom,o1_right,o1_top,o2_left,o2_bottom,o2_right,o2_top):
    
    left, right, bottom, top = 0, 0, 0, 0

    if rect_in_rect(o1_left,o1_bottom,o1_right,o1_top,o2_left,o2_bottom,o2_right,o2_top):
        if (o1_left < o2_right and o1_right > o2_left):
            left    = (o1_left > o2_left) and o1_left or o2_left
            right   = (o1_right < o2_right) and o1_right or o2_right

        if (o1_top > o2_bottom and o1_bottom < o2_top):
            bottom  = (o1_bottom > o2_bottom) and o1_bottom or o2_bottom
            top     = (o1_top < o2_top) and o1_top or o2_top

        if game_framework.debug:
            pico2d_extension.set_color(255, 0, 0)
            pico2d_extension.draw_rectangle(left,bottom,right,top)
            pico2d.update_canvas()

    return left, bottom, right, top
Example #3
0
 def draw_rect(self, r, g, b):
     pico2d_extension.set_color(r, g, b)
     pico2d_extension.draw_rectangle(*self.to_rect())