"""
object.py - base class for general object
Do not instantiate!
"""

import common
import pygame

class Object:

    #
    # no need to override these functions:
    #
    def __init__(self, rect, alive):
        self.rect = pygame.Rect(rect)
        self.alive = alive

    def hide(self):
        # set last_rect for dirtyrect union optimization
        self.last_rect = common.screen.blit(common.current_bg, self.rect, self.rect)

    # return rect which has to be updated
    # return as list!
    def optimizeDirtyRect(self,rect):
        if not hasattr(self,'last_rect'):
            return [rect]
        elif self.last_rect.colliderect(rect):
            return [self.last_rect.union(rect)]
        else:
            return [self.last_rect,rect]

    #
    # you may want to override these functions:
    #
    def show(self):
        r = common.screen.blit(self.images[0],self.rect)
        return self.optimizeDirtyRect(r)

    #
    # do override these functions:
    #
    def move(self):
        pass


        
    
