Esempio n. 1
0
 def moveLeft(self, brdObject):
     """Move the person left."""
     if collisionChecker(brdObject, self, self.x, self.y - 1) == 0:
         editMatrix(brdObject, self, self.x, self.y - 1)
         self.place(self.x, self.y - 1)
     else:
         return 1
Esempio n. 2
0
 def moveDown(self, brdObject):
     """Move the person down."""
     if collisionChecker(brdObject, self, self.x + 1, self.y) == 0:
         editMatrix(brdObject, self, self.x + 1, self.y)
         self.place(self.x + 1, self.y)
     else:
         return 1
Esempio n. 3
0
 def insertNew(self, brdObject, x, y):
     """Insert the person."""
     if collisionChecker(brdObject, self, x, y) == 0:
         editMatrix(brdObject, self, x, y)
         self.place(x, y)
         return 0
     return -1
Esempio n. 4
0
    def makeBoundary(self, brdObject):
        """Make the boundary."""
        brd = brdObject.getMatrix()
        for j in range(0, 4):
            for i in range(0, brdObject.length):
                brd[i][j] = 'x'

        for i in range(0, 2):
            for j in range(0, brdObject.breadth):
                brd[i][j] = 'x'

        for i in range(brdObject.length - 2, brdObject.length):
            for j in range(0, brdObject.breadth):
                brd[i][j] = 'x'

        for j in range(brdObject.breadth - 4, brdObject.breadth):
            for i in range(0, brdObject.length):
                brd[i][j] = 'x'

        x = 4
        y = 8
        while x < (brdObject.length - 4):
            while y < (brdObject.breadth - 8):
                editMatrix(brdObject, self, x, y)
                y += 4 + self.breadth
            x += 2 + self.length
            y = 8
Esempio n. 5
0
 def placeBomb(self, brdObject, x, y):
     """Place the bomb randomly."""
     if self.count == 0:
         self.createdAt = time.time()
         self.x = x
         self.y = y
         self.count = 1
         editMatrix(brdObject, self, x, y)
Esempio n. 6
0
 def destroy(self, brdObject):
     """Destroy the person."""
     if self.destroyed is False:
         self.destroyed = True
         for i in range(0, self.length):
             for j in range(0, self.breadth):
                 self.matrix[i][j] = ' '
         editMatrix(brdObject, self, self.x, self.y)
         brdObject.score += 100
Esempio n. 7
0
 def randomPlace(self, brdObject):
     """Place an enemy randomly."""
     flag = 1
     while flag != 0:
         a = 4 * randint(1, 7)
         b = 2 * randint(1, 30)
         if collisionChecker(brdObject, self, a, b) == 0:
             editMatrix(brdObject, self, a, b)
             self.place(a, b)
             flag = 0
Esempio n. 8
0
 def randomPlace(self, brdObject):
     """Place the brick randomly."""
     flag = 1
     while flag != 0:
         a = 2 * randint(1, 15)
         b = 4 * randint(1, 15)
         if collisionChecker(brdObject, self, a, b) == 0:
             editMatrix(brdObject, self, a, b)
             self.x = a
             self.y = b
             flag = 0
Esempio n. 9
0
 def updateBomb(self, brdObject, bricks, enemy, plr):
     """Update the bomb."""
     if self.createdAt is not None:
         stamp = time.time() - self.createdAt
         if stamp <= 1 and stamp > 0:
             editMatrix(brdObject, self, self.x, self.y)
         elif stamp <= 2 and stamp > 1:
             for i in range(self.x, self.x + self.length):
                 for j in range(self.y, +self.y + self.breadth):
                     brdObject.matrix[i][j] = '2'
         elif stamp <= 3 and stamp > 2:
             for i in range(self.x, self.x + self.length):
                 for j in range(self.y, +self.y + self.breadth):
                     brdObject.matrix[i][j] = '1'
         else:
             for i in range(self.x, self.x + self.length):
                 for j in range(self.y, +self.y + self.breadth):
                     brdObject.matrix[i][j] = ' '
             self.explodeBomb(brdObject, bricks, enemy, plr)
             self.createdAt = None
             self.count = 0