Exemple #1
0
def enter():
    global isaac, background, is_key_pressed, is_attack_key_pressing, bullet_dir, gushers, is_bullet_create
    global BackGround_Width, BackGround_Height, invincibility_time, shot_term, bullets, door, indoor, monster_count
    global rocks
    game_world.objects = [[], []]
    BackGround_Width = 1280
    BackGround_Height = 960
    isaac = Isaac()
    monster_count = 10
    gushers = [Gusher() for i in range(monster_count)]
    background = BackGround()
    door = Door()
    door.x = door_position[1]
    indoor = InDoor()
    indoor.x = door_position[1]
    rocks = [Rock(900, 400), Rock(900, 600), Rock(400, 400), Rock(400, 600)]
    game_world.add_object(background, 0)
    game_world.add_objects(rocks, 0)
    game_world.add_object(indoor, 1)
    game_world.add_object(door, 1)
    game_world.add_object(isaac, 1)
    game_world.add_objects(gushers, 1)
    is_key_pressed = 0
    is_attack_key_pressing = 0
    bullet_dir = 0
    is_bullet_create = False
    invincibility_time = 0
    shot_term = 0
    bullets = []

    pass
Exemple #2
0
    def __init__(self):

        # Initialize pygame for the game class, as well as initializing the font.
        pygame.init()
        pygame.font.init()

        # Set the display accordingly (x,y) and set the title for the game.
        self.screen = pygame.display.set_mode((800, 600))
        pygame.display.set_caption("Game")

        # Initialize the classes
        self.player = Node(0, 580, 3.5)
        self.key = Key(600, 0)
        self.door = Door(760, 550)
        #Current floor values are probably going to be level 1
        self.floors = [
            Floor(300, 0, 20, 50),
            Floor(500, 1, 20, 50),
            Floor(100, 2, 20, 50),
            Floor(200, 3, 20, 50),
            Floor(400, 4, 20, 50),
            Floor(250, 5, 20, 50),
            Floor(50, 6, 20, 50),
            Floor(150, 7, 20, 50),
            Floor(550, 8, 20, 50),
            Floor(450, 9, 20, 50)
        ]
        self.counter = Counter(675, 10)

        self.RUN = True

        self.playerFoundKey = False

        self.gameOver = False
Exemple #3
0
    def addNeighbour(self, room, direction):
        """
        Adds a neighbour in the given heading.

        Keyword arguments:
        room - a Room object to add as a neighbour
        direction - the heading of the new room relative to this Room ("N", "E", "S" or "W")
        """
        self.__neighbours[direction] = room
        if (direction == "N"):
            center = Vector((self.__top_right.x + self.__top_left.x) / 2,
                            self.__top_right.y)
            d = Door("N", center)
        elif (direction == "E"):
            center = Vector(self.__bot_right.x,
                            (self.__bot_right.y + self.__top_right.y) / 2)
            d = Door("E", center)
        elif (direction == "S"):
            center = Vector((self.__bot_right.x + self.__bot_left.x) / 2,
                            self.__bot_left.y)
            d = Door("S", center)
        else:
            center = Vector(self.__bot_left.x,
                            (self.__bot_left.y + self.__top_left.y) / 2)
            d = Door("W", center)
        self.__doors[d] = direction
Exemple #4
0
def find_doors(door_positions):
    size = 0
    horizontal_doors = []
    horizontal_one_width_doors = []
    # determine length of doors by getting count of matching y values
    for i in range(0, len(door_positions)):
        # continuous door is found
        if i + 1 is len(door_positions):
            next_door = None
        else:
            next_door = door_positions[i + 1]

        this_door = door_positions[i]
        if next_door is not None and this_door[0] == next_door[0] and this_door[1] == next_door[1] - 1:
            size = size + 1
        else:
            # don't count 1 width doors
            if size > 0:
                door_origin_position = door_positions[i - size]
                door = Door(door_origin_position, size + 1)
                horizontal_doors.append(door)
                size = 0
            else:
                horizontal_one_width_doors.append(Door(this_door, 1))

    # sort doors by y value
    door_positions.sort(key=lambda tup: tup[1])

    vertical_doors = []
    vertical_one_width_doors = []
    size = 0
    # determine length of doors by getting count of matching x values
    for j in range(0, len(door_positions)):
        # continuous door is found
        if j + 1 == len(door_positions):
            next_door = None
        else:
            next_door = door_positions[j + 1]

        this_door = door_positions[j]
        if next_door is not None and this_door[1] == next_door[1] and this_door[0] == next_door[0] - 1:
            size = size + 1
        else:
            # don't count 1 width doors
            if size > 0:
                door_origin_position = door_positions[j - size]
                door = Door(door_origin_position, size + 1)
                vertical_doors.append(door)
                size = 0
            else:
                vertical_one_width_doors.append(Door(this_door, 1))

    one_width_doors = []
    for k in range(len(horizontal_one_width_doors)):
        for l in range(len(vertical_one_width_doors)):
            if horizontal_one_width_doors[k].origin[0] == vertical_one_width_doors[l].origin[0] \
                    and horizontal_one_width_doors[k].origin[1] == vertical_one_width_doors[l].origin[1]:
                one_width_doors.append(horizontal_one_width_doors[k])

    return horizontal_doors + vertical_doors + one_width_doors
Exemple #5
0
    def __init__(self, director, player):
        Level.__init__(self, director, player)
        self.player.rect.x = 782
        self.player.rect.y = 912
        self.dead_sub_boss = 0      #Counts the dead Centurions.
        self.enemyGroup.add([Legionnaire(987, 768, self.player, director),
                             Legionnaire(1083, 768, self.player, director),
                             Legionnaire(1119, 768, self.player, director),
                             Legionnaire(987, 834, self.player, director),
                             Legionnaire(477, 747, self.player, director),
                             Legionnaire(645, 738, self.player, director),
                             Legionnaire(477, 891, self.player, director),
                             Legionnaire(645, 788, self.player, director),
                             Centurion(150, 288, self.player, director),
                             Centurion(1455, 288, self.player, director),
                             Centurion(1329, 1248, self.player, director)]) 

        self.door = Door(760, 575, 'door_sheet.png', -1, 'coordDoor.txt', [2], 'door_open.wav')     
        self.doorGroup = EntityGroup([])
        self.doorGroup.add(self.door)
        self.groups.append(self.doorGroup)

        self.bg = load_image("map_caesar_a_img.png", Constants.MAP_DIR)
        self.collisionBg = load_image(
            "map_caesar_a_bg.png", Constants.BG_MAP_DIR)

        load_music("level_one.it")
        pygame.mixer.music.set_volume(1)
        pygame.mixer.music.play(-1)

        player.setWeapons([WpnBlade("wpns2.png", -1, pygame.Rect(344, 342, 28, 28), "blade_swing.wav", 0.5), \
                          WpnBow("items-1.png", None, pygame.Rect(0, 24, 24, 24))])
Exemple #6
0
class LevelOneA(Level):

    def __init__(self, director, player):
        Level.__init__(self, director, player)
        self.player.rect.x = 782
        self.player.rect.y = 912
        self.dead_sub_boss = 0      #Counts the dead Centurions.
        self.enemyGroup.add([Legionnaire(987, 768, self.player, director),
                             Legionnaire(1083, 768, self.player, director),
                             Legionnaire(1119, 768, self.player, director),
                             Legionnaire(987, 834, self.player, director),
                             Legionnaire(477, 747, self.player, director),
                             Legionnaire(645, 738, self.player, director),
                             Legionnaire(477, 891, self.player, director),
                             Legionnaire(645, 788, self.player, director),
                             Centurion(150, 288, self.player, director),
                             Centurion(1455, 288, self.player, director),
                             Centurion(1329, 1248, self.player, director)]) 

        self.door = Door(760, 575, 'door_sheet.png', -1, 'coordDoor.txt', [2], 'door_open.wav')     
        self.doorGroup = EntityGroup([])
        self.doorGroup.add(self.door)
        self.groups.append(self.doorGroup)

        self.bg = load_image("map_caesar_a_img.png", Constants.MAP_DIR)
        self.collisionBg = load_image(
            "map_caesar_a_bg.png", Constants.BG_MAP_DIR)

        load_music("level_one.it")
        pygame.mixer.music.set_volume(1)
        pygame.mixer.music.play(-1)

        player.setWeapons([WpnBlade("wpns2.png", -1, pygame.Rect(344, 342, 28, 28), "blade_swing.wav", 0.5), \
                          WpnBow("items-1.png", None, pygame.Rect(0, 24, 24, 24))])

    def processEvent(self, event):
        if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
            nextLevel = LevelTwo(self.director, self.player)
            self.director.setScene(nextLevel)
        if event.type == pygame.KEYDOWN and event.key == pygame.K_F1:
            self.door.setActive(True)
            # nextLevel = LevelOneB(self.director, self.player)
            # self.director.setScene(nextLevel)

        Level.processEvent(self, event)
    
    def update(self, time):
        Level.update(self, time)
        if not self.door.active and self.dead_sub_boss == 3:
            #When all Centurions are dead we open the door
            self.door.setActive(True)
        if len(pygame.sprite.spritecollide(self.player,self.doorGroup,False)) == 1: 
            if self.door.active == False:
                m = MessageScene(self.director, self, 'Warning', 'You shall not pass!', 'Press to continue')
                self.director.setScene(m)
                self.player.rect.y+=25
            if self.door.active == True:
                nextLevel = LevelOneB(self.director, self.player)
                self.director.setScene(nextLevel)    
Exemple #7
0
def main():
    door = Door(19, 26, 16, 20)

    try:
        doorStatus = door.getDoorStatus()
        print doorStatus
    except KeyboardInterrupt, e:
        pass
Exemple #8
0
 def createDoors(self, width, height):
     door1 = Door(0,2,False, True)
     door2 = Door(4,3, True)
     door3 = Door(7,8)
     door4 = Door(7,12)
     self.doors = [door1, door2, door3, door4]
     # Clean positions of doors
     for wall in self.Walls:
         for door in self.doors:
             if ((wall.x == door.x) and (wall.y == door.y )):
                 self.Walls.remove(wall)
Exemple #9
0
    def __init__(self, center, width, height, type="none"):
        self.__center = center
        self.__width = width
        self.__height = height
        self.__top_left = Vector(self.__center.x - self.__width / 2,
                                 self.__center.y - self.__height / 2)
        self.__top_right = Vector(self.__center.x + self.__width / 2,
                                  self.__center.y - self.__height / 2)
        self.__bot_left = Vector(self.__center.x - self.__width / 2,
                                 self.__center.y + self.__height / 2)
        self.__bot_right = Vector(self.__center.x + self.__width / 2,
                                  self.__center.y + self.__height / 2)
        self.__walls = [
            Wall(self.__top_left, self.__top_right, "N"),
            Wall(self.__top_right, self.__bot_right, "E"),
            Wall(self.__bot_right, self.__bot_left, "S"),
            Wall(self.__bot_left, self.__top_left, "W")
        ]
        self.__type = type
        self.__characters = []
        self.__neighbours = {"N": None, "E": None, "S": None, "W": None}
        self.__doors = {}
        self.__enemies = []

        self.__tileset = simplegui.load_image(
            "https://i.imgur.com/a55akyp.png")
        self.__wall_sprite_size = (32, 32)
        self.__wall_sprite_pos_dict = {
            "N": (16, (64 + self.__wall_sprite_size[1] / 2)),
            "E": ((32 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2)),
            "S": ((96 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2)),
            "W": ((64 + self.__wall_sprite_size[0] / 2),
                  (64 + self.__wall_sprite_size[1] / 2))
        }
        self.__corner_sprite_pos_dict = {
            "NW": ((128 + 16), (64 + 16)),
            "NE": (16, (96 + 16)),
            "SE": ((32 + 16), (96 + 16)),
            "SW": ((64 + 16), (96 + 16))
        }
        self.__door_sprite_size = (64, 32)
        self.__door_sprite_pos = ((128),
                                  (128 + self.__door_sprite_size[1] / 2))

        if (type == "end"):
            self.__ladder_pos = ((96 + 16), (96 + 16))
            self.__ladder_size = (32, 32)
            self.__level_door = Door("C", self.__center)
Exemple #10
0
 def loadEnvironment(self):
     """Loads the environment model into the world"""
     #Load the environment
     self.env = loader.loadModel("models/level")
     self.env.reparentTo(render)
     self.env.setScale(2)
     self.env.setPos(0, 0, 0)
     self.env.setP(270)
     
     
     self.doorModel=loader.loadModel("models/door")
     self.doors=[]
     self.doors.append(Door(self.doorModel,1,38,-12,0))
     self.doors.append(Door(self.doorModel,2,20,-6,90))
     self.doors.append(Door(self.doorModel,3,4,18,0))
Exemple #11
0
    def Step1(self):

        while self.step1_finisher:
            for event in pygame.event.get():  #종료 이벤트
                if event.type == pygame.QUIT:
                    pygame.quit()
                    exit(0)
            pygame.display.update()

            self.screen.fill((135, 135, 135))

            self.screen.blit(self.board, (50, 100))

            for i in range(3):
                for j in range(3):
                    self.desk = Desk(self.screen, 275 + self.width / 5 * i,
                                     340 + self.height / 5 * j)
                    self.desk.draw()
                    self.desks.append(self.desk)

            self.study.study()

            self.door = Door(self.screen, 1050, 600)
            self.door.draw()
            self.player.move()

            if self.face_timer == 0:
                if self.face == "front":
                    self.face_timer = 500
                    self.face = "back"

                elif self.face == "back":
                    self.face_timer = 300
                    self.face = "front"
            if self.face == "front":
                self.screen.blit(self.front, (700, 50))
            elif self.face == "back":
                self.screen.blit(self.back, (700, 50))
            self.face_timer -= 1

            if self.face == "front":
                if self.study.invincibility_flag == True:
                    pass
                else:
                    self.wl.print()

            if self.player.colliderect(self.door):
                self.step1_finisher = False
Exemple #12
0
def main():
    # Call getLogger with no args to set up the handler
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    fh = logging.FileHandler('/home/pi/doorLog.log', mode='a')
    fh.setLevel = logging.DEBUG
    formatter = logging.Formatter('%(asctime)s:%(message)s')
    fh.setFormatter(formatter)
    logger.addHandler(fh)

    door = Door(19, 26, 16, 20)
    try:
        result = door.closeDoor()
        logger.info(result)
    except KeyboardInterrupt, e:
        pass
Exemple #13
0
 def __init__(self,
              room,
              floor,
              building,
              host,
              port,
              command_topic,
              status_topic,
              actuator_pin,
              pin_numbering='BCM',
              activeState=1,
              CS=8,
              MOSI=10,
              MISO=9,
              SCLK=11):
     self.room = room
     self.floor = floor
     self.building = building
     self.id = str(self.room) + str(building)
     self.mqtt = MQTT_Client(
         room,
         floor,
         building,
         host,
         port,
         command_topic,
         status_topic,
     )
     self.door = Door(actuator_pin=actuator_pin,
                      numbering=pin_numbering,
                      activeState=activeState)
     self.rfid = RFID_Reader(CS=CS, MOSI=MOSI, MISO=MISO, SCLK=SCLK)
     self.available_commands = {b'open': self.door.open}
Exemple #14
0
def test():
    w = Window(2)
    d = Door(2.0)
    l = Light(95)
    r = Rad(3000)
    r = Room("Living room", 12, 15, 10, 10.5, r, d, l, w)
    print(r.get_length())
    print(r.get_width())
    print(r.get_height())
    print(r.getSqrFt())
    print(r.get_area())

    r.set_length(9)
    r.set_width(15)
    r.set_height(12)

    print(r.get_length())
    print(r.get_width())
    print(r.get_height())
    print(r.getSqrFt())
    print(r.get_area())

    r.change_temp(-1)
    print(r.get_temp())

    print(r)
def enter():
    global isaac, background, is_key_pressed, is_attack_key_pressing, bullet_dir, gushers, is_bullet_create
    global BackGround_Width, BackGround_Height, invincibility_time, shot_term, bullets, door,  monster_count
    global  flies, big_flies, enemy_bullets, is_enemy_bullet_create, is_bullet_upgrade, is_black_bullet_create
    global duke,is_monster_create


    game_world.objects = [[],[]]
    BackGround_Width = 1280
    BackGround_Height = 960
    isaac = Isaac()
    isaac.x = 200
    isaac.y = BackGround_Height//2
    isaac.body_x, isaac.body_y = isaac.x - 5, isaac.y - 50
    isaac.now_health = main_state_4.hp
    isaac.body_is_move = False
    duke = Duke()
    monster_count = 0
    background = BackGround(1)
    entrance_door = Door()
    entrance_door.x = door_position[0]
    entrance_indoor = InDoor()
    entrance_indoor.x = door_position[0]

    game_world.add_object(background,0)
    game_world.add_object(isaac, 1)
    game_world.add_object(duke,1)
    game_world.add_object(entrance_door, 1)
    game_world.add_object(entrance_indoor, 1)
    is_key_pressed = 0
    is_attack_key_pressing = 0
    bullet_dir = 0
    is_bullet_create = False
    is_enemy_bullet_create = False
    is_bullet_upgrade = main_state_4.is_bullet_upgrade
    is_black_bullet_create = False
    is_monster_create = False
    invincibility_time = 100
    shot_term = 0
    flies = []
    big_flies = []
    bullets = []
    enemy_bullets = []
    pass
def enter():
    global isaac, background, is_key_pressed, is_attack_key_pressing, bullet_dir, gushers, is_bullet_create
    global BackGround_Width, BackGround_Height, invincibility_time, shot_term, bullets, door, indoor, monster_count
    global flies, big_flies, enemy_bullets, is_enemy_bullet_create, needles, rocks

    game_world.objects = [[], []]
    BackGround_Width = 1280
    BackGround_Height = 960
    isaac = Isaac()
    isaac.x = 200
    isaac.y = BackGround_Height // 2
    isaac.body_x, isaac.body_y = isaac.x - 5, isaac.y - 50
    isaac.velocity_x = main_state.isaac.velocity_x
    isaac.velocity_y = main_state.isaac.velocity_y
    isaac.now_health = main_state.hp
    isaac.body_is_move = False
    monster_count = 12
    background = BackGround()
    needles = [
        Needle(400, 500),
        Needle(300, 700),
        Needle(600, 200),
        Needle(900, 700),
        Needle(750, 400)
    ]
    rocks = [Rock(850, 400), Rock(1000, 600), Rock(400, 300), Rock(600, 600)]
    door = Door()
    door.x = door_position[1]
    entrance_door = Door()
    entrance_door.x = door_position[0]
    indoor = InDoor()
    indoor.x = door_position[1]
    entrance_indoor = InDoor()
    entrance_indoor.x = door_position[0]
    flies = [Fly() for i in range(7)]
    big_flies = [BigFly() for i in range(5)]
    game_world.add_object(background, 0)
    game_world.add_objects(needles, 0)
    game_world.add_objects(rocks, 0)
    game_world.add_object(indoor, 1)
    game_world.add_object(door, 1)
    game_world.add_object(isaac, 1)
    game_world.add_object(entrance_door, 1)
    game_world.add_object(entrance_indoor, 1)
    game_world.add_objects(flies, 1)
    game_world.add_objects(big_flies, 1)
    is_key_pressed = 0
    is_attack_key_pressing = 0
    bullet_dir = 0
    is_bullet_create = False
    is_enemy_bullet_create = False
    invincibility_time = 100
    shot_term = 0

    bullets = []
    enemy_bullets = []
    pass
Exemple #17
0
    def __init__(self, config: Config):
        self.config = config

        self.initChoiceStrategy: ChoiceStrategy = config.initChoiceStrategy(
            self)
        self.openingStrategy: ChoiceStrategy = config.openingStrategy(self)
        self.choiceStrategy: ChoiceStrategy = config.strategy(self)
        self.positioningStrategy: ChoiceStrategy = config.positioningStrategy(
            self)

        self.openDoors = []
        self.doors = [Door(i) for i in range(config.totalDoors)]
        self.closedDoors = self.doors.copy()
        self.chosenDoors = []

        self.chosenDoor = None
        self.rewardDoor = None
Exemple #18
0
def main():
    try:
        os.nice(-15)
    except OSError:
        print("Process priority could not be decreased!")

    EntryHR = OuterHandReader.OHandReader(12, 18, 1)
    print("Entry Hand Reader Initialized!")
    ExitHR = ExitHandReader.ExitHandReader(32, 31)
    print("Exit Hand Reader Initialized!")
    MD = MaskDetector.MaskDetector(headless=False)
    print("Mask Detector Initialized!")
    door = Door()
    print("Door Initialized!")
    B = Buzzer(33)

    while True:
        controller.STATE = controller.DORMANT
        while controller.STATE == controller.DORMANT:
            if (ExitHR.read()):
                controller.STATE = controller.UNLOCKED
                print("The door is unlocked!")
                B.positiveresponse()
                door.exit()
                sleep(1)
            sleep(0.1)

        controller.STATE = controller.VERIFICATION
        print("Verification state")
        MD.start_display()
        while controller.STATE == controller.VERIFICATION:
            result = EntryHR.read()
            if (HAND_APPROVED == result):
                print("Checking face mask.")
                result = MD.last_label()
                if result == "Mask":
                    print("Greetings. The door is unlocked.")
                    #controller.STATE = controller.UNLOCKED
                    B.positiveresponse()
                    door.entrance()
                elif result == "Improper Mask":
                    print(
                        "Please wear your mask properly. When you do, have your hand measured again. Thank you!"
                    )
                    B.ringwarning()
                else:
                    print(
                        "You do not have a mask on! Please leave the door front area!"
                    )
                    B.ringerror()
                    #controller.STATE = controller.LOCKED

        sleep(5)
Exemple #19
0
    def from_xml_local(cls, xml_tree):
        arena = Arena()
        locs = []
        rooms = []
        doors = []
        for child in xml_tree.getchildren():
            if child.tag == 'LOCATION':
                locs.append(Location.from_xml_local(child))
            elif child.tag == 'ROOM':
                rooms.append(Room.from_xml_local(child))
            elif child.tag == 'DOOR':
                doors.append(Door.from_xml_local(child))

        arena.locations = locs
        arena.rooms = rooms
        arena.doors = doors

        return arena
Exemple #20
0
    def GenerateDoor(self, room1ID, room2JSON):

        room2ID = room2JSON["Room"]

        room2Direction = room2JSON["Direction"]
        room1Direction = "N"
        if (room2Direction == "N"):
            room1Direction = "S"
        elif (room2Direction == "L"):
            room1Direction = "E"
        elif (room2Direction == "E"):
            room1Direction = "L"

        door = Door(room1ID, room1Direction, room2ID, room2Direction,
                    room2JSON["Opened"] == "True")
        self.DoorsList.append(door)

        return door
Exemple #21
0
    def __init__(self, x, y, spritesheet, maze_sprite_group, void_sprite_group,
                 door_sprite_group, tile_scale):
        self.pillar_sprite = Sprite(spritesheet, (32, 16, 16, 16),
                                    scale=tile_scale)
        self.door_sprite = Door(spritesheet, (0, 32, 16, 26), scale=tile_scale)
        self.void_sprite = Sprite(spritesheet, (48, 64, 16, 16),
                                  scale=tile_scale)
        self.floor_sprites = {
            0: Sprite(spritesheet, (32, 0, 16, 16), scale=tile_scale),
            1: Sprite(spritesheet, (0, 16, 16, 16), scale=tile_scale),
            2: {
                0:
                Sprite(spritesheet, (16, 0, 16, 16),
                       scale=tile_scale,
                       rotation=1),
                1:
                Sprite(spritesheet, (0, 0, 16, 16),
                       scale=tile_scale,
                       rotation=2)
            },
            3: Sprite(spritesheet, (48, 0, 16, 16),
                      scale=tile_scale,
                      rotation=2),
            4: Sprite(spritesheet, (64, 0, 16, 16), scale=tile_scale)
        }
        self.x = x
        self.y = y
        self.maze_sprite_group = maze_sprite_group
        self.void_sprite_group = void_sprite_group
        self.door_sprite_group = door_sprite_group
        self.tile_type = self.TYPE_VOID
        self.tile_size = tile_scale * 16
        self.sprite = None
        self.step_neighbours = {}
        self.direct_neighbours = {}

        # Pathfinding variables
        self.h_score = 0
        self.g_score = 0
        self.is_seen = False
        self.is_visited = False
        self.parent = None
Exemple #22
0
    def generate_objects(self, surface, layer, camera, group):

        terms = {'Oxygen': O2Term, 'Energy': EnergyTerm, 'Main': MainTerm}

        for obj in layer:
            if layer.name == 'walls':
                Wall(obj.image, obj.x, obj.y, group['walls'])

            elif layer.name == 'doors':
                Door(obj.image, obj.x, obj.y, group['doors'],
                     obj.properties['condition'])

            elif layer.name == 'player':
                pass

            elif layer.name == 'terminals' and obj.name != None:
                if obj.name == 'Energy':
                    terms[obj.name](obj.image, obj.name, obj.x, obj.y,
                                    group['terms'], obj.properties['text'],
                                    obj.properties['answer'],
                                    obj.properties['improved_text'],
                                    obj.properties['task'],
                                    obj.properties['broken'])
                else:
                    terms[obj.name](obj.image, obj.name, obj.x, obj.y,
                                    group['terms'], obj.properties['text'],
                                    obj.properties['answer'],
                                    obj.properties['improved_text'],
                                    obj.properties['broken'])

            elif layer.name == 'volvo':
                Valve(obj.image, group['valves'], obj.x, obj.y,
                      obj.properties['waste'])

            elif layer.name == 'shattle':
                Shattle(obj.image, group['shattle'], obj.x, obj.y)

            else:
                Wall(obj.image, obj.x, obj.y, group['other'])
Exemple #23
0
def test():
    w1 = Window(2)
    w2 = Window(2)
    w3 = Window(2)
    w4 = Window(2)
    w5 = Window(2)
    w6 = Window(2)

    d1 = Door(1.5)
    d2 = Door(1.5)
    d3 = Door(1.5)
    d4 = Door(1.5)
    d5 = Door(1.5)
    d6 = Door(1.5)

    r1 = Room("Kitchen", 12, 10, 8, 10.7, True, d1, w1)
    r2 = Room("Kitchen", 12, 10, 8, 11.1, True, d2, w2)
    r3 = Room("Kitchen", 12, 10, 8, 10.3, True, d3, w3)
    r4 = Room("Kitchen", 12, 10, 8, 10.9, True, d4, w4)
    r5 = Room("Kitchen", 12, 10, 8, 11.3, True, d5, w5)
    r6 = Room("Kitchen", 12, 10, 8, 11.7, True, d6, w6)

    b = Heater([r1, r2, r3])

    h = House(True, [r1, r2, r3], b, -25.004, 30.032)
    h.insulate()
    h.is_insulated()
    print(h.get_rooms())
    h.set_rooms([r4, r5, r6])
    h.add_room("Living room")
    print(h.get_rooms())
    print(h.get_lat())
    h.set_lon(12.651)
    print(h.get_lon())
    print(h.get_average_temp())

    print(h)
Exemple #24
0
from Monitor import Monitor
from Oven import Oven
from Rad import Rad
from Room import Room
from Toaster import Toaster
from UtilityRoom import UtilityRoom
from UtilityRoomController import UtilityRoomController
from Window import Window

import threading
#import tkinter

livingRoomWindow = Window(3)
livingRoomRad = Rad(3000)
livingRoomLight = Light(90)
livingRoomDoor = Door(1.5)
livingRoom = Room("Living Room", 16, 20, 8, 12.0, livingRoomRad,
                  livingRoomDoor, livingRoomLight, livingRoomWindow)

kitchenWindow = Window(1)
kitchenRad = Rad(2000)
kitchenLight = Light(80)
kitchenDoor = Door(1.5)
kettle = Kettle(2, 100)
oven = Oven(300)
toaster = Toaster(10)
kitchen = Kitchen("Kitchen", 10, 16, 8, 12.0, kitchenRad, kitchenDoor, kitchenLight, kitchenWindow, \
                  kettle, oven, toaster)

bedroom1Window = Window(3)
bedroom1Rad = Rad(2500)
Exemple #25
0
pir_taller = DigitalInput(26,
                          'Taller',
                          active_high=True,
                          nSamples=3,
                          interval=5)
pir_hall = DigitalInput(27, 'Saleta', active_high=True, nSamples=3, interval=5)
pir_sala = DigitalInput(14, 'Sala', active_high=True, nSamples=3, interval=5)

vbat = VoltMeter(33)

powermeter = PowerMeter(39)

ldr_taller = LDR(36)

door = Door(34)

cfg = Settings(1)

pump = Pump(bomba, powermeter, cfg)

light_taller = Light(pir_taller, lamp_taller, ldr=ldr_taller)

alarm = Alarm(buzzer, door, [pir_sala], [pir_hall], cfg)


def get_events(req, resp):
    yield from picoweb.jsonify(resp, alarm.getEvents())


def clear_events(req, resp):
Exemple #26
0
def load_level(nombre):
	mapa, fondo, musica, pared, graviswitch = Read_File(nombre)
	
	sprite_list = pygame.sprite.Group()
	updatable_list = pygame.sprite.Group() #Un grupo por tipo de accion a sprites.
	wall_list = pygame.sprite.Group()
	box_list = pygame.sprite.Group()
	col_list = pygame.sprite.Group()
	door_list = pygame.sprite.Group()
	bfilter_list = pygame.sprite.Group()
	checkpoint_list = pygame.sprite.Group()
	
	id_given = 0
	door_id = 0
	pos_y = 0
	for linea in mapa:
		pos_x = 0
		for cuadro in linea:
			if cuadro == 'W':
				wall = Wall(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				sprite_list.add(wall)
				col_list.add(wall)
				wall_list.add(wall)
				wall.ID = id_given #Cada bloque va a tener su propio ID, para comparar colisiones.
				id_given += 1 
			elif cuadro == 'P':
				p_inicio = (pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				p_id = id_given
				id_given += 1
			elif cuadro == 'B':
				box = Box(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				sprite_list.add(box)
				col_list.add(box)
				updatable_list.add(box)
				box_list.add(box)
				box.ID = id_given #Cada bloque va a tener su propio ID, para comparar colisiones.
				id_given += 1
			elif cuadro == 'J':
				box = JumpBox(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				sprite_list.add(box)
				col_list.add(box)
				updatable_list.add(box)
				box_list.add(box)
				box.ID = id_given #Cada bloque va a tener su propio ID, para comparar colisiones.
				id_given += 1
			elif cuadro == 'S':
				spike = Spike(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				sprite_list.add(spike)
				col_list.add(spike)
				spike.ID = id_given
				id_given += 1
			elif cuadro == 'D':
				door = Door(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				door.exitID = door_id
				door_list.add(door)
				door_id += 1
			elif cuadro == 'F':
				bfilter = Box_Filter(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				bfilter_list.add(bfilter)
				bfilter.ID = id_given
				id_given += 1
			elif cuadro == 'C':
				checkpoint = Checkpoint(pos_x*BLOCK_SIZE, pos_y*BLOCK_SIZE)
				checkpoint_list.add(checkpoint)
				checkpoint.ID = id_given
				id_given += 1
				
			pos_x += 1
		pos_y += 1
	
	grupos =[col_list, box_list, wall_list, door_list, updatable_list, sprite_list, bfilter_list, checkpoint_list]
	info = [p_id, p_inicio, fondo, musica, pared, graviswitch]
	return (info, grupos)
   Do you have a better chance of finding the car if you stay or switch?"""

#Import door class, switch class, and random module
from Door import Door
from Switch import switch
import random

#set number of simulations
trials = 100000

#create variable to count number of times found the car when switch doors
switchWins = 0
#run the simulation a number of times
for i in range(trials):
	#create 3 door objectts
	doorOne = Door()
	doorTwo = Door()
	doorThree = Door()

	#put car behind a random door
	x = random.randint(1,3)
	for case in switch(x):
		if case(1):
			doorOne.setCar(True)
			break
		if case(2):
			doorTwo.setCar(True)
			break
		if case():
			doorThree.setCar(True)
Exemple #28
0
class Game():
    def __init__(self):

        # Initialize pygame for the game class, as well as initializing the font.
        pygame.init()
        pygame.font.init()

        # Set the display accordingly (x,y) and set the title for the game.
        self.screen = pygame.display.set_mode((800, 600))
        pygame.display.set_caption("Game")

        # Initialize the classes
        self.player = Node(0, 580, 3.5)
        self.key = Key(600, 0)
        self.door = Door(760, 550)
        #Current floor values are probably going to be level 1
        self.floors = [
            Floor(300, 0, 20, 50),
            Floor(500, 1, 20, 50),
            Floor(100, 2, 20, 50),
            Floor(200, 3, 20, 50),
            Floor(400, 4, 20, 50),
            Floor(250, 5, 20, 50),
            Floor(50, 6, 20, 50),
            Floor(150, 7, 20, 50),
            Floor(550, 8, 20, 50),
            Floor(450, 9, 20, 50)
        ]
        self.counter = Counter(675, 10)

        self.RUN = True

        self.playerFoundKey = False

        self.gameOver = False

    def startGame(self):

        while self.RUN:
            pygame.time.delay(12)

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.RUN = False

            # Gets the current key pressed
            keyPressed = pygame.key.get_pressed()

            #Key press event for a
            if keyPressed[pygame.K_a] and self.player.x > 0:
                self.player.moveLeft()

            #Key press event for w
            if keyPressed[pygame.K_w] and self.player.y > 0:
                self.player.moveUp()

            #Key press event for w
            if keyPressed[pygame.K_s] and self.player.y >= 0:
                if self.player.y < 580:
                    self.player.moveDown()

            # Checks to see if the player has hit a key
            if self.player.hitKey(self.key):
                self.playerFoundKey = True

            # Checks to see if the player is within a range, if the floor is at the end, floorTurn is changed
            # The boolean value of floorTurn controls the floor movement
            for floor in self.floors:
                if self.player.detectCollision(floor):
                    self.player.color = (255, 0, 0)
                    self.gameOver = True
                    self.RUN = False

                if floor.x < 800 - floor.length and not floor.floorTurn:
                    floor.direction = 1
                    floor.x += floor.velocity
                else:
                    floor.direction = -1
                    floor.x += floor.velocity * floor.direction
                    floor.floorTurn = True
                    if floor.x < 0:
                        floor.floorTurn = False

            #Key press event for d
            if keyPressed[
                    pygame.K_d] and self.player.x < 800 - self.player.sizex:
                self.player.moveRight()

            # Pygame functions that draw the player and draw the screen, as well as drawing all the floors in the floors dynamic array
            self.screen.fill((0, 0, 0))
            self.player.drawPlayer(self.screen)

            self.door.drawDoor(self.screen)

            if not self.playerFoundKey:
                self.key.drawKey(self.screen)

            for floor in self.floors:
                floor.drawFloor(self.screen)

            # Displays the X and Y position counters, as well as if they player got the key
            self.counter.printXPOS(self.screen, self.player)
            self.counter.printYPOS(self.screen, self.player)
            self.counter.printKey(self.screen, self.playerFoundKey)

            pygame.display.update()
   Do you have a better chance of finding the car if you stay or switch?"""

#Import door class, switch class, and random module
from Door import Door
from Switch import switch
import random

#set number of simulations
trials = 100000

#create variable to count number of times found the car when switch doors
switchWins = 0
#run the simulation a number of times
for i in range(trials):
    #create 3 door objectts
    doorOne = Door()
    doorTwo = Door()
    doorThree = Door()

    #put car behind a random door
    x = random.randint(1, 3)
    for case in switch(x):
        if case(1):
            doorOne.setCar(True)
            break
        if case(2):
            doorTwo.setCar(True)
            break
        if case():
            doorThree.setCar(True)
Exemple #30
0
def test_find_password2():
    door_id = "abc"
    door = Door(door_id)
    assert (door.find_password2() == "05ace8e3")
Exemple #31
0
def test_find_password():
    door_id = "abc"
    door = Door(door_id)
    assert (door.find_password() == "18f47a30")