def __call__(self, sprite1, sprite2):   #__call__ not implemented in pyjs
     r = sprite1.rect
     x = (r.width*self.ratio)-r.width
     y = (r.height*self.ratio)-r.height
     r1 = rectPool.get(r.x-int(x*0.5), r.y-int(y*0.5), r.width+int(x), r.height+int(y))
     r = sprite2.rect
     x = (r.width*self.ratio)-r.width
     y = (r.height*self.ratio)-r.height
     r2 = rectPool.get(r.x-int(x*0.5), r.y-int(y*0.5), r.width+int(x), r.height+int(y))
     collide = r1.intersects(r2)
     rectPool.extend((r1,r2))
     return collide
Exemple #2
0
 def __call__(self, sprite1, sprite2):  #__call__ not implemented in pyjs
     r = sprite1.rect
     x = (r.width * self.ratio) - r.width
     y = (r.height * self.ratio) - r.height
     r1 = rectPool.get(r.x - int(x * 0.5), r.y - int(y * 0.5),
                       r.width + int(x), r.height + int(y))
     r = sprite2.rect
     x = (r.width * self.ratio) - r.width
     y = (r.height * self.ratio) - r.height
     r2 = rectPool.get(r.x - int(x * 0.5), r.y - int(y * 0.5),
                       r.width + int(x), r.height + int(y))
     collide = r1.intersects(r2)
     rectPool.extend((r1, r2))
     return collide
 def blit(self, surface, position, area=None):
     """
     Draw given surface on this surface at position.
     Optional area delimitates the region of given surface to draw.
     """
     if not area:
         rect = rectPool.get(position[0],position[1],surface.width,surface.height)
         self.impl.canvasContext.drawImage(surface.canvas, rect.x, rect.y)    #pyjs0.8 *.canvas
     else:
         rect = rectPool.get(position[0],position[1],area[2], area[3])
         self.impl.canvasContext.drawImage(surface.canvas, area[0], area[1], area[2], area[3], rect.x, rect.y, area[2], area[3])    #pyjs0.8 *.canvas
     if self._display:
         surface_rect = self._display._surface_rect
     else:
         surface_rect = self.get_rect()
     changed_rect = surface_rect.clip(rect)
     rectPool.append(rect)
     return changed_rect
Exemple #4
0
 def blit(self, surface, position, area=None):
     """
     Draw given surface on this surface at position.
     Optional area delimitates the region of given surface to draw.
     """
     if not area:
         rect = rectPool.get(position[0], position[1], surface.width,
                             surface.height)
         self.impl.canvasContext.drawImage(surface.canvas, rect.x,
                                           rect.y)  #pyjs0.8 *.canvas
     else:
         rect = rectPool.get(position[0], position[1], area[2], area[3])
         self.impl.canvasContext.drawImage(surface.canvas, area[0], area[1],
                                           area[2], area[3], rect.x, rect.y,
                                           area[2],
                                           area[3])  #pyjs0.8 *.canvas
     if self._display:
         surface_rect = self._display._surface_rect
     else:
         surface_rect = self.get_rect()
     changed_rect = surface_rect.clip(rect)
     rectPool.append(rect)
     return changed_rect