def __init__(self, position, size, *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     srf = self.generateEmptySprite(size, alpha=0)
     if cblocals.DEBUG:
         srf.set_alpha(150)
     self.image = srf
Beispiel #2
0
 def __init__(self, position, size, *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self.x, self.y = position
     self.rect.midbottom = position
     self._image = None
     self._timeCollected = 0
     self._nextLightChange = randomTime()
     self._phase = 1
Beispiel #3
0
 def __init__(self, position, size, exit_to, start_position, firstNavPoint, topleft, *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self.image = self.generateEmptySprite(size, alpha=0, fillWith=(240,240,240))
     self._focus = False
     # Exit data
     self.to_level = exit_to
     self.start_position = start_position
     self.firstNavPoint = firstNavPoint
     self.nextTopleft = topleft
Beispiel #4
0
 def __init__(self, position, size, *containers):
     """The position used is the lighting strike point of the ground (midbottom)"""
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self.x, self.y = position
     self.rect.midbottom = position
     self._image = None
     self._timeCollected = 0
     self._nextLightChange = randomTime()
     self._phase = 1
Beispiel #5
0
 def __init__(self, character, bkcolor=(255, 255, 255, 0), textcolor=(0, 0, 0, 0)):
     GameSprite.__init__(self)
     self._character = character
     self.bkcolor = bkcolor
     self.textcolor = textcolor
     self._text = ""
     self._text_queue = []
     self._time_left = 0
     self._last_charX = self._last_charY = None
     self._image = None
Beispiel #6
0
 def __init__(self, level, text=None, type=LEVEL_TEXT_TYPE_NORMAL):
     GameSprite.__init__(self, level['level_text'])
     self._text = []
     self._type = type
     self.level = level
     self._image = None
     self.rect = self._getRect()
     self.position = self.rect.midbottom
     if text:
         self.addText(text)
     self.colophon = False
Beispiel #7
0
 def __init__(self, position, size, fireOnCollistionWith=(), *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self.position = position
     srf = self.generateEmptySprite(size, alpha=0)
     if cblocals.DEBUG:
         srf.set_alpha(100)
         srf.fill( (255,255,255) )
     self.image = srf
     # Other important trigger's members
     self.disableTriggerAfterFire = True
     self.fireOnCollistionWith = fireOnCollistionWith
Beispiel #8
0
    def __init__(self, name, img, containers,
                 realSize=cblocals.TILE_IMAGE_SIZE, speed=150.,
                 attackTime=0.5, afterAttackRestTime=0.2, weaponInAndOut=False, sightRange=200,):
        
        GameSprite.__init__(self, *containers)
        Stealth.__init__(self)
        Warrior.__init__(self, attackTime, afterAttackRestTime)

        self._x = self._y = 0
        self.rect = pygame.Rect( (self.x, self.y), (cblocals.TILE_IMAGE_SIZE) )

        self.name = name
        self.characterType = "Guy"
        self.experienceLevel = 1
        
        self._brain = None
        self._presentationBrain = PresentationStateMachine(self)
        
        self._load_images(img, weaponInAndOut)
        self.lastUsedImage = 'head_south_1'

        self._stepTime = 0
        self._mustChangeImage = False
        self.direction = self._lastUsedDirection = cblocals.DIRECTION_S
        self._isMoving = False
        self.maxSpeed = self._speed = speed
        self.sightRange = sightRange
        self.rest_time_needed = .3
        
        self.side = 'Cheese Boys'
        self._enemyTarget = None
        
        self.navPoint = NavPoint(self)
        self.heading =  None
        
        # From where a succesfull attack is coming
        self.damageHeading = None
        
        self.size = realSize
        self._heatRectData = (5, 5, 10, 15)

        self.hitPoints = self.hitPointsLeft = 20
        
        self._baseAC = 1
        self._th0 = None

        self._speech = SpeechCloud(self)
        
        # *** Pathfinding ***
        self.pathfinder = None        # This is inited only after the call onto addToGameLevel

        self.afterInit()
Beispiel #9
0
 def __init__(self, position, type, orientation, *containers):
     """Init the crate. You need specify the type of the crate, that will change the used image, and also the
     orientation (image can be rotated).
     @type: a integer number to be appended to the createXX.png filename.
     @orientation: an integer from 0 to 3, that rotate the image 90*value degree counterclockwise.
     """
     GameSprite.__init__(self, *containers)
     image = utils.load_image("crate%s.png" % type, directory="miscellaneous")
     if orientation:
         image = pygame.transform.rotate(image, 90*orientation)
     self.image = image
     self.position = position
     self.rect = pygame.Rect(position, image.get_size())
     self.rect.midbottom = position
Beispiel #10
0
 def __init__(self, position, length, orientation, *containers):
     """Init the gate. Just give the length on the gate and the orientation.
     0 for horizontal, 1 for vertical.
     
     To open the gate set the open_condition tuple attribute. The tuple contains an object (commonly a GameSprite)
     and an attribute name, that need to be tested on this object.
     The open_condition attribute must be evaluated to True, or must be a callable that return True.
     In any one of this case, the gate will open on collision with the hero.
     
     You can also use the open_condition_reverse_flag to negate the condition needed to open the gate (not True but False).
     """
     GameSprite.__init__(self, *containers)
     self.length = self.total_length = length
     self.width = int(length/20)
     self.orientation = orientation
     self.position = position
     self._initGate()
     self.opened = False
     self.isOpen = False
     self._focus = False
     self.open_condition = ()
     # Negate condition for opening
     self.open_condition_reverse_flag = False
Beispiel #11
0
 def __init__(self, position, size, *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self.image = utils.load_image("codigoro-sign.png", "miscellaneous")
Beispiel #12
0
 def __init__(self, position, size, *containers):
     GameSprite.__init__(self, *containers)
     self.x, self.y = position
     self.rect = pygame.Rect(position, size)
     self.image = utils.load_image("dark-large-stain.png", "miscellaneous")
Beispiel #13
0
 def __init__(self, position, size, *containers):
     GameSprite.__init__(self, *containers)
     self.rect = pygame.Rect(position, size)
     self._image = None
     self._wave_phase = cbrandom.choice([0,1,2,3])
     self._timeCollected = self._nextRandomWaveTime()