Example #1
0
 def get_door_cost(self):
     '''
     Get the cost of the door panels
     '''
     D = self.D
     Nd = len(D)
     self.door_costs = []
     for i in range(Nd):
         model = doors.Door(D[i])
         door_panels = model.get_design()
         panel_areas = [np.prod(i) for i in door_panels]
         total_area = sum(panel_areas)
         total_cost = self.ca * total_area
         self.door_costs.append(total_cost)
     return self.door_costs
Example #2
0
def set_doors(frame, game='instructions'):
    doors_frame = tk.Frame(frame,
                           bg=FRAME_BG,
                           width=400,
                           height=200,
                           name="doors_frame")
    door_patches = dict()
    door_nums = (1, 2, 3) if game == 'instructions' else game.doors.keys()

    for door_num in door_nums:
        prize = False if game == 'instructions' else game.check_prize(door_num)
        door_patches[door_num] = doors.Door(doors_frame, door_num, 0, door_num,
                                            prize)

    return doors_frame, door_patches
Example #3
0
        paper.zap()
    if keys[pygame.K_m] and (abs(player.rect.x - lever1_x) <
                             150) and (abs(player.rect.y - lever1_y) < 150):
        if lever1_pressed == 0:
            lever1_pressed = 1
    if keys[pygame.K_m] and (abs(player.rect.x - lever2_x) <
                             150) and (abs(player.rect.y - lever2_y) < 150):
        if lever2_pressed == 0:
            lever2_pressed = 1

    if lever1_pressed == 1:
        for d in door_sprites:
            x_d, _ = d.rect.center
            y_d = d.rect.top
        door_sprites.empty()
        door_sprites.add(doors.Door(x_d, y_d + 128))
        lever1_pressed = 2

    if lever2_pressed == 1:
        for d in door_sprites:
            x_d, _ = d.rect.center
            y_d = d.rect.top
        door_sprites.empty()
        door_sprites.add(doors.Door(x_d, y_d))
        lever2_pressed = 2

    for b in bullet_sprites:
        hit = pygame.sprite.spritecollide(b, block_sprites, dokill=False)
        if not hit:
            b.move(bull_speed)
        else:
Example #4
0
def drawHall(hall):
    length = hall.parent.hallLength[hall.direction]
    start = hall.parent.loc
    if (hall.direction == 0):
        start += Vec(0, 0, 0)
        start = start.e(hall.offset)
        stepw = Vec(1, 0, 0)
        stepl = Vec(0, 0, 1)
        dd1 = 5
        dd2 = 4
        torch_dat = 3
    elif (hall.direction == 1):
        start += Vec(hall.parent.parent.room_size - 1, 0, 0)
        start = start.s(hall.offset)
        stepw = Vec(0, 0, 1)
        stepl = Vec(-1, 0, 0)
        dd1 = 3
        dd2 = 2
        torch_dat = 2
    elif (hall.direction == 2):
        start += Vec(0, 0, hall.parent.parent.room_size - 1)
        start = start.e(hall.offset)
        stepw = Vec(1, 0, 0)
        stepl = Vec(0, 0, -1)
        dd1 = 5
        dd2 = 4
        torch_dat = 4
    else:
        start += Vec(0, 0, 0)
        start = start.s(hall.offset)
        stepw = Vec(0, 0, 1)
        stepl = Vec(1, 0, 0)
        dd1 = 3
        dd2 = 2
        torch_dat = 1
    for j in xrange(length):
        pen = start + stepl * j
        # First wall
        for k in xrange(hall.parent.parent.room_height - 1):
            hall.parent.parent.setblock(pen.down(k), materials._wall)
        # hallway (ceiling and floor)
        for x in xrange(hall.size - 2):
            pen += stepw
            hall.parent.parent.setblock(pen, materials._ceiling)
            for k in xrange(1, hall.parent.parent.room_height - 2):
                hall.parent.parent.setblock(pen.down(k), materials.Air)
            hall.parent.parent.setblock(
                pen.down(hall.parent.parent.room_height - 2), materials._floor)
        # Second wall
        pen += stepw
        for k in xrange(hall.parent.parent.room_height - 1):
            hall.parent.parent.setblock(pen.down(k), materials._wall)

    # Possible torches.
    pen = start + stepl * length
    hall.parent.parent.torches[pen.down(1)] = torch_dat
    hall.parent.parent.torches[pen.down(1) + (stepw *
                                              (hall.size - 1))] = torch_dat

    # Possible doors
    # Only halls of width 1 and 2 can have doors (single and double doors)
    if (3 <= hall.size <= 4):
        # find a starting position at the end of the hall
        pen = start + stepl * (length - 1)
        pen = pen.down(1)
        door = pen
        # Look for adjacent doors. We don't want doors upon doors.
        box = Box(door, 0, 0, 0)
        abort = False
        for x in iterate_points_surrounding_box(box):
            if (x in hall.parent.parent.doors):
                abort = True
        # Create the door
        if (abort == False):
            # Give this door a direction.
            hall.parent.parent.doors[door] = doors.Door()
            hall.parent.parent.doors[
                door].material = hall.parent.parent.doormaterial
            hall.parent.parent.doors[door].direction = hall.direction
            # place the actual door positions
            for x in xrange(hall.size - 2):
                pen += stepw
                hall.parent.parent.doors[door].doors.append(pen)
Example #5
0
def create_lvl(height, block_sprites, kill_sprites, door_sprites,
               bdoor_sprites):
    for _ in range(height - 192, height, 128):
        for i in range(9):
            block_sprites.add(Block.Block(64 + 128 * i, _))
        for i in range(13):
            block_sprites.add(Block.Block(1728 + 128 * i, _))  #1
    for i in range(9):
        block_sprites.add(Block.Block(64 + 128 * i, height + 64))
    for i in range(7):
        block_sprites.add(Block.Block(1664 - 64 + 128 * i, height + 64))
    for i in range(2):
        block_sprites.add(Block.Block(3200 - 64 + 128 * i, height + 64))  #3
    for i in range(9):
        block_sprites.add(Block.Block(64 + 128 * i, height + 192))
    for i in range(4):
        block_sprites.add(Block.Block(128 * 15 - 64 + 128 * i, height + 192))
    block_sprites.add(Block.Block(3200 + 64, height + 192))  #4
    for i in range(2):
        block_sprites.add(Block.Block(64 + 128 * i, height + 320))
    for i in range(3):
        block_sprites.add(Block.Block(128 * 8 - 64 + 128 * i, height + 320))
    for i in range(3):
        block_sprites.add(Block.Block(128 * 15 - 64 + 128 * i,
                                      height + 320))  #5
    block_sprites.add(Block.Block(64, height + 320 + 128))
    for i in range(3):
        block_sprites.add(
            Block.Block(128 * 15 - 64 + 128 * i, height + 320 + 128))  #6
    block_sprites.add(Block.Block(64, height + 320 + 128 * 2))
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 14 - 64 + 128 * i, height + 320 + 128 * 2))
    for i in range(5):
        block_sprites.add(
            Block.Block(128 * 21 - 64 + 128 * i, height + 320 + 128 * 2))  #7
    block_sprites.add(Block.Block(64, height + 320 + 128 * 3))
    for i in range(5):
        block_sprites.add(
            Block.Block(128 * 13 - 64 + 128 * i, height + 320 + 128 * 3))
    for i in range(7):
        block_sprites.add(
            Block.Block(128 * 20 - 64 + 128 * i, height + 320 + 128 * 3))  #8
    block_sprites.add(Block.Block(64, height + 320 + 128 * 4))
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 10 - 64 + 128 * i, height + 320 + 128 * 4))
    for i in range(3):
        block_sprites.add(
            Block.Block(128 * 15 - 64 + 128 * i, height + 320 + 128 * 4))
    for i in range(7):
        block_sprites.add(
            Block.Block(128 * 20 - 64 + 128 * i, height + 320 + 128 * 4))
    for i in range(10):
        kill_sprites.add(
            KillBlock.Block(128 * 27 - 64 + 128 * i,
                            height + 320 + 128 * 4))  #9
    block_sprites.add(Block.Block(64, height + 320 + 128 * 5))
    block_sprites.add(Block.Block(128 * 16 - 64, height + 320 + 128 * 5))
    block_sprites.add(Block.Block(128 * 20 - 64, height + 320 + 128 * 5))  #10
    for i in range(7):
        block_sprites.add(Block.Block(64 + 128 * i, height + 320 + 128 * 6))
    block_sprites.add(Block.Block(128 * 19 - 64, height + 320 + 128 * 6))  #11
    for i in range(8):
        block_sprites.add(Block.Block(64 + 128 * i,
                                      height + 320 + 128 * 7))  #12
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 5 - 64 + 128 * i, height + 320 + 128 * 8))  #13
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 7 - 64 + 128 * i, height + 320 + 128 * 9))
    for i in range(11):
        block_sprites.add(
            Block.Block(128 * 24 - 64 + 128 * i, height + 320 + 128 * 9))  # 0
    for i in range(8):
        block_sprites.add(
            Block.Block(128 * 8 - 64 + 128 * i, height + 320 + 128 * 10))
    for i in range(12):
        block_sprites.add(
            Block.Block(128 * 23 - 64 + 128 * i, height + 320 + 128 * 10))  #-1
    for i in range(9):
        block_sprites.add(
            Block.Block(128 * 10 - 64 + 128 * i, height + 320 + 128 * 11))
    for i in range(13):
        block_sprites.add(
            Block.Block(128 * 22 - 64 + 128 * i, height + 320 + 128 * 11))  #-2
    block_sprites.add(Block.Block(128 * 11 - 64, height + 320 + 128 * 12))
    for i in range(6):
        block_sprites.add(
            Block.Block(128 * 13 - 64 + 128 * i, height + 320 + 128 * 12))
    for i in range(14):
        block_sprites.add(
            Block.Block(128 * 21 - 64 + 128 * i, height + 320 + 128 * 12))  #-3
    for i in range(3):
        block_sprites.add(Block.Block(64 + 128 * i, height + 320 + 128 * 13))
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 14 - 64 + 128 * i, height + 320 + 128 * 13))
    for i in range(12):
        block_sprites.add(
            Block.Block(128 * 23 - 64 + 128 * i, height + 320 + 128 * 13))  #-4
    for i in range(2):
        block_sprites.add(
            Block.Block(128 * 3 - 64 + 128 * i, height + 320 + 128 * 14))
    for i in range(4):
        block_sprites.add(
            Block.Block(128 * 15 - 64 + 128 * i, height + 320 + 128 * 14))
    for i in range(10):
        block_sprites.add(
            Block.Block(128 * 25 - 64 + 128 * i, height + 320 + 128 * 14))  #-5
    for i in range(2):
        block_sprites.add(
            Block.Block(128 * 6 - 64 + 128 * i, height + 320 + 128 * 15))
    block_sprites.add(Block.Block(128 * 16 - 64, height + 320 + 128 * 15))
    for i in range(2):
        block_sprites.add(
            Block.Block(128 * 19 - 64 + 128 * i, height + 320 + 128 * 15))
    for i in range(10):
        block_sprites.add(
            Block.Block(128 * 25 - 64 + 128 * i, height + 320 + 128 * 15))  #-6
    block_sprites.add(Block.Block(128 * 10 - 64, height + 320 + 128 * 16))
    for i in range(10):
        block_sprites.add(
            Block.Block(128 * 25 - 64 + 128 * i, height + 320 + 128 * 16))  #-7
    for i in range(2):
        block_sprites.add(
            Block.Block(128 * 12 - 64 + 128 * i, height + 320 + 128 * 17))
    for i in range(11):
        block_sprites.add(
            Block.Block(128 * 24 - 64 + 128 * i, height + 320 + 128 * 17))  #-8
    for i in range(12):
        block_sprites.add(
            Block.Block(128 * 23 - 64 + 128 * i, height + 320 + 128 * 18))  #-9
    for i in range(20):
        block_sprites.add(
            Block.Block(128 * 15 - 64 + 128 * i,
                        height + 320 + 128 * 19))  #-10
    for i in range(18):
        block_sprites.add(
            Block.Block(128 * 17 - 64 + 128 * i,
                        height + 320 + 128 * 20))  #-11
    for i in range(16):
        kill_sprites.add(KillBlock.Block(64 + 128 * i,
                                         height + 320 + 128 * 20))
    for i in range(17):
        block_sprites.add(
            Block.Block(128 * 18 - 64 + 128 * i,
                        height + 320 + 128 * 21))  #-12
    for i in range(34):
        block_sprites.add(Block.Block(64 + 128 * i,
                                      height + 320 + 128 * 22))  #-13
    door_sprites.add(doors.Door(26 * 128 - 64, height + 320 + 128 * 6.5))
    bdoor_sprites.add(blockable_door.Doorb(128 * 9 + 64, 128 * 14 + 64))

    return block_sprites, kill_sprites, door_sprites, bdoor_sprites