Beispiel #1
0
def get_bosses():
    itemlist = []
    bosslist = []
    itemlist.append(Item("Twisted Bow",20000000))
    itemlist.append(Item("Elder Maul",2000000))
    bosslist.append(Boss('Chambers of Xeric', itemlist).jsoned())
    itemlist=[]
    itemlist.append(Item("Scythe of Vitur",20000000))
    itemlist.append(Item("Ghrazi Rapier",2000000))
    bosslist.append(Boss('Theater of Blood', itemlist).jsoned())
    itemlist=[]
    itemlist.append(Item("Pegasian Crystal",20000000))
    itemlist.append(Item("Primordial Crystal",2000000))
    bosslist.append(Boss('Cerberus', itemlist).jsoned())
    itemlist=[]
    itemlist.append(Item("Smoke Battlestaff",20000000))
    itemlist.append(Item("Amulet",2000000))
    bosslist.append(Boss('Thermonuclear Smoke Devil', itemlist).jsoned())
    itemlist=[]
    itemlist.append(Item("Hydra Leather",20000000))
    itemlist.append(Item("Hydras Claw",2000000))
    bosslist.append(Boss('Alchemical Hydra', itemlist).jsoned())
    

    sim = Simulator()
    print({'bosses' : bosslist}, file=sys.stderr)
    total = 0
    trials=1
    #for i in range(trials):
    print(sim.simulate(bosslist[0]['items']))
    #    total+=i1
    #print(total/trials)

    return {'bosses' : bosslist}
Beispiel #2
0
 def __init__(self, f, l):
     Boss.__init__(self, f, l)
     self.mark = 0
     self.inAir = 0
     self.superjump = 16
     self.superpower = 0
     self.jump = 8
Beispiel #3
0
def get_boss():
    itemlist = []
    itemlist.append(Item("Pegasian Crystal",30000000))
    itemlist.append(Item("Eternal Crystal",2654963))
    boss = Boss('Cerberus', itemlist)
    print(boss.jsoned(), file=sys.stderr)
    return boss.jsoned()
def create_boss(ai_settings, screen, bosses):
    boss = Boss(ai_settings, screen)
    screen_rect = screen.get_rect()
    boss.rect.x = screen_rect.centerx
    boss.rect.y = 0
    boss.shoot()
    bosses.add(boss)
Beispiel #5
0
    def __init__(self):

        self.width = 1400
        self.screenWidth = 170
        self.height = 45
        self.grid = [[' ' for i in range(self.width)]
                     for j in range(self.height)]
        self.getch = getInput._getChUnix()
        self.bricks = []
        self.enemies = []
        self.smartEnemies = []
        self.bullets = []
        self.bridge = Bridge()
        self.boss = Boss()
        self.coins = []
        self.bossBullets = []
        self.springs = []
        self.black = '\u001b[30;1m'
        self.red = '\u001b[31;1m'
        self.green = '\u001b[32;1m'
        self.yellow = '\u001b[33;1m'
        self.blue = '\u001b[34;1m'
        self.magenta = '\u001b[35;1m'
        self.cyan = '\u001b[36;1m'
        self.white = '\u001b[37;1m'
        self.reset = '\u001b[0m'
Beispiel #6
0
def main():
    print('1 - Add Employee')
    print('2 - Add Boss')
    print('3 - Print employees')
    print('4 - Remove employee by index')
    print('5 - Save company to file')
    print('6 - Read company to file')
    print('7 - Exit')

    company = Company()
    while True:
        command = input('Enter command: ')
        if command == '1':
            emp = Employee()
            company.add_employee(emp.read_from_console())
        elif command == '2':
            boss = Boss()
            company.add_employee(boss.read_from_console())
        elif command == '3':
            print(company)
        elif command == '4':
            index = int(input('Enter index: '))
            del company.employees[index]
        elif command == '5':
            fname = input('Enter file name: ')
            company.write_to_file(fname)
        elif command == '6':
            fname = input('Enter file name: ')
            company = Company.read_from_file(fname)
        elif command == '7':
            break
        else:
            print('Wrong command!')
 def __init__(self):  #Créer le constructeur de la classe
     self.is_playing = False  #Dire que le jeu n'as pas commencé
     self.end_game = False  #Signaler que le jeu n'est pas terminé
     self.all_players = pygame.sprite.Group()  #Créer le groupe du joueur
     self.player = Player(self)  #Ajouter le joueur au jeu
     self.all_players.add(self.player)  #Ajouter le joueur au groupe
     self.all_monsters = pygame.sprite.Group(
     )  #Créer le groupe des monstres
     self.pressed = {
     }  #Définir le dictionnaire pour savoir si des touches sont pressées
     self.comet_event = CometFallEvent(self)  #Stocker la classe des comètes
     self.score = 0  #Définir la score initial
     self.font = pygame.font.Font("assets/Righteous-Regular.ttf",
                                  25)  # Créer la police du texte du score
     self.sound_manager = SoundManager()  #Stocker la classe des sons
     self.all_boss = pygame.sprite.Group()  # Créer le groupe du monstre
     self.boss = Boss(self)  # Stocker la classe du boss
     self.projectile = True
     self.event = 1
     self.paused = False
     self.end_text = self.font.render(
         "Congratulations ! You have completed the game !!!", 1,
         (0, 0, 0))  # Créer le texte des vies globales
     self.general_data = {}
     self.infinite = False
     self.recovback()
def create_boss(ai_settings, screen, boss):
    """create an alien and place it in the row"""
    boss = Boss(ai_settings, screen)
    boss_width = boss.rect.width
    boss.x = boss_width
    boss.rect.x = boss.x
    boss.rect.y = boss.rect.height
    boss.add(boss)
    def spawnBoss(self):

        bossModel = "resources/lordMonkey"
        boss = Boss(bossModel, 9000)

        boss.setPos(-245,245,20)
        boss.setAI()
        base.enemyList.append(boss)
Beispiel #10
0
def create_boss(ai_settings, screen, aliens, bloods):
    """创建一个外星boss"""
    boss = Boss(ai_settings, screen)
    boss.x = random.randint(100, 500)
    boss.rect.x = boss.x
    boss.rect.y = 0
    blood = Blood(ai_settings, screen, boss)
    bloods.add(blood)
    aliens.add(boss)
Beispiel #11
0
def do_task(city, query):
    boss = Boss(city, query)
    boss.open_url()

    lagou = Lagou(city, query)
    lagou.open_url()

    zhilian = Zhilian(city, query)
    zhilian.open_url()
Beispiel #12
0
    def reset(self):
        self.boss = Boss()
        self.rewards = []
        self.players = {}
        self.next_id = 0

        self.time = 0.0
        self.reset_time = 1e30

        for i in range(REWARD_COUNT):
            self.gen_reward()
Beispiel #13
0
    def __init__(self):
        self.mrq = MyRedisQueue()
        self.boss_obj = Boss()
        self.lagou_obj = Lagou()

        self.boss_key = 'boss'
        self.boss_task_level = 2
        self.boss_url_level = 1

        self.lagou_key = 'lagou'
        self.lagou_task_level = 2
        self.lagou_url_level = 1
 def create_monsters(self):
     monsters = []
     boss = Boss()
     boss.level = self.area_number
     monsters.append(boss)
     skeletons = []
     number_of_skeletons = randrange(2, 5)
     for i in range(number_of_skeletons):
         skeletons.append(Skeleton('Skeleton_' + str(i + 1)))
     skeletons[0].has_key = True
     for skeleton in skeletons:
         skeleton.level = self.area_number
         monsters.append(skeleton)
     return monsters
 def _create_boss(self):
     """Создание боса и размещение его в центре."""
     count = 1
     for point in self.bossstation.turrel_list:
         if count <= self.stats.level:
             new_boss = Boss(self)
             new_boss.x = (point[0] + self.bossstation.rect.x -
                           new_boss.rect.width / 2)
             new_boss.y = (point[1] + self.bossstation.rect.y -
                           new_boss.rect.height / 2)
             new_boss.index_in_station = self.bossstation.turrel_list.index(
                 point)
             self.bosses.add(new_boss)
         count += 1
Beispiel #16
0
def create_object(ch, x, y):
    if ch in ['1', '2', '3', '4', '5', '6']:
        obj = Jelly(ord(ch) - ord('1'), x, y)
        gfw.world.add(gfw.layer.item, obj)
        #print('creating Jelly', x, y)
    elif ch in ['O', 'P']:
        dy = 1 if ch == 'O' else 3  #4
        y -= dy * BLOCK_SIZE // 2
        x -= BLOCK_SIZE // 2
        obj = Platform(ord(ch) - ord('O'), x, y)
        gfw.world.add(gfw.layer.platform, obj)
        #print('creating Platform', x, y)
    elif ch in ['B']:
        e = Boss(x, y - 10)
        gfw.world.add(gfw.layer.boss, e)
    else:
        if ch == 'X':
            y -= 105
        elif ch == 'Y':
            y -= 33
        elif ch == 'Z':
            y += 10
        ao = factory.create(ch, x, y)
        if ao is None:
            global ignore_char_map
            if ch not in ignore_char_map:
                print("Error? I don't know about: '%s'" % ch)
                ignore_char_map |= {ch}
            return
        l, b, r, t = ao.get_bb()
        ao.pass_wh(r - l, t - b)
        gfw.world.add(gfw.layer.enemy, ao)
def enter():
    global boss_exist, middle_boss_exist
    boss_exist = 0
    middle_boss_exist = 0
    global boss_gauge
    boss_gauge = 0
    global hero
    global cursor
    global boss
    global boss_right_arm
    global boss_left_arm
    global enemy_genarate
    global middle_boss

    map = Map()
    cursor = Cursor()
    boss = Boss()
    boss_right_arm = Boss_right_arm()
    boss_left_arm = Boss_left_arm()
    middle_boss = Middle_boss()
    hero = Hero()

    hide_cursor()
    game_world.add_object(map, 0)

    enemy_genarate = Enemy_genarate()
    game_world.add_object(hero, 1)
    game_world.add_object(cursor, 4)

    game_world.add_object(enemy_genarate, 0)
Beispiel #18
0
    def move(self, movement, grid):
        new_dragon_cords = {}
        for i in self.__dragon_coordinates:
            new_dragon_cords[i + movement[0]] = []
            for j in self.__dragon_coordinates[i]:
                new_dragon_cords[i + movement[0]].append(j + movement[1])

        for i in new_dragon_cords:
            for j in new_dragon_cords[i]:
                if grid[i][j].blocking == 1:
                    return
        li = list(self.__dragon_coordinates.keys())
        li.sort()
        self.upper_coordinate = li[0]
        for i in self.__dragon_coordinates:
            for j in self.__dragon_coordinates[i]:
                grid[i][j] = Playarea()

        self.__dragon_coordinates.clear()
        cnt1 = 0
        cnt2 = 0
        for i in new_dragon_cords:
            self.__dragon_coordinates[i] = []
            cnt2 = 0
            for j in new_dragon_cords[i]:
                grid[i][j] = Boss(self.__dragon_disp[cnt1][cnt2])
                self.__dragon_coordinates[i].append(j)
                cnt2 += 1
            cnt1 += 1
        return
Beispiel #19
0
    def __restartCurrentLevelOver(self, instance):

        if (self.gameOverSound.state == "play"):
            self.gameOverSound.stop()
        if (self.gameWinSound.state == "play"):
            self.gameWinSound.stop()

        self.player = Player()
        self.player.pos = [200, 10]
        self.lobo = Boss()

        self.niveis[self.nivelCorrente] = None
        self.niveis[self.nivelCorrente] = Nivel1(
            player=self.player,
            backgroundImage="./images/fundo.png",
            boss=self.lobo)

        self.niveis[0].soundOn = self.soundOn
        self.lobo.pos = [self.niveis[0].tamanhoFase / 3, 10]

        self.add_widget(self.niveis[0])
        self.add_widget(self.player)
        self.add_widget(self.lobo)
        self.add_widget(self.gameMenu)
        self.remove_widget(self.gameOverMenu)
        self.gamePause = False
    def fillBricks(self, num):
        array = []
        array2 = []
        if num == 1:
            a = 0
            for i in range(0, 18, 3):
                for j in range(0, 144, 8):
                    stren = random.randint(1, 5)
                    hl = int(j / 8)
                    whbrick = np.random.choice(2, 1, p=[0.9, 0.1])
                    if whbrick:
                        stren = 3
                    if (hl == a or hl == a + 1 or hl == 17 - a
                            or hl == 17 - a - 1) and int(i / 3) != 5:
                        stren = 6
                        whbrick = 0
                    array.append(
                        Brick(9 + i, 30 + j, 3, 8, 0, 0, stren, whbrick))

                    if (stren == 3 or stren == 4):
                        array2.append(
                            PowerUp(9 + i, 30 + j, 1, 1, 0, 0,
                                    random.choice(POWERUPS)))
                a += 2
        if num == 2:
            a = 10
            for i in range(0, 18, 3):
                for j in range(0, 144, 8):
                    stren = random.randint(1, 5)
                    hl = int(j / 8)
                    whbrick = np.random.choice(2, 1, p=[0.9, 0.1])
                    if whbrick:
                        stren = 3
                    if (hl == a or hl == a + 1 or hl == 17 - a
                            or hl == 17 - a - 1) and int(i / 3) != 0:
                        stren = 6
                        whbrick = 0

                    if not ((int(i / 3) == 0 and int(j / 8) == 0) or
                            (int(i / 3) == 0 and int(j / 8) == 17)):
                        array.append(
                            Brick(9 + i, 30 + j, 3, 8, 0, 0, stren, whbrick))
                        if (stren == 3 or stren == 4):
                            array2.append(
                                PowerUp(9 + i, 30 + j, 1, 1, 0, 0,
                                        random.choice(POWERUPS)))
                a -= 2
        if num == 3:
            array.append(Boss(0, int(FRAMEWIDTH / 2), 7, 33, 0, 1, 20, 0))
            for i in range(9, 18, 3):
                for j in range(0, 144, 8):
                    stren = random.randint(1, 5)
                    if stren == 5:
                        array.append(Brick(9 + i, 30 + j, 3, 8, 0, 0, stren,
                                           0))

        return array, array2
Beispiel #21
0
 def insert(self, grid):
     i2 = 0
     j2 = 0
     for i in self.__dragon_coordinates:
         j2 = 0
         for j in self.__dragon_coordinates[i]:
             grid[i][j] = Boss(self.__dragon_disp[i2][j2])
             j2 += 1
         i2 += 1
Beispiel #22
0
    def __init__(self):

        # 初始化 pygame
        pygame.init()

        # 初始化時間,遊戲幀數為每秒60幀
        self.mainClock = pygame.time.Clock()
        self.mainClock.tick(60)
        self.tick = 0

        # 初始化「繪圖」、「聲音」、「主角」
        self.renderer = Renderer()
        self.character = Character()
        self.sound = Sound()
        self.bgm = Sound()
        '''遊戲參數初始化設定'''
        self.pause = False  # 可控制遊戲暫停
        self.quit = False  # 可退出當前遊戲
        self.pause_button = 0  # 遊戲暫停選單按鍵
        self.game_over_button = 0  # 遊戲死亡選單按鍵
        '''遊戲參數初始化設定結束'''
        '''遊戲精靈群組初始化'''
        self.allsprite = pygame.sprite.Group()  # 精靈群組的總群組
        self.bulletsprite = pygame.sprite.Group()  # 子彈群組
        self.bricksprite = pygame.sprite.Group()  # 子彈邊界群組
        self.bosssprite = pygame.sprite.Group()  # 魔王群組

        self.score_sprite = pygame.sprite.Group()
        self.shoes_sprite = pygame.sprite.Group()
        self.heart_sprite = pygame.sprite.Group()
        self.bonus_lst = [
            self.score_sprite, self.shoes_sprite, self.heart_sprite
        ]  # 突發class清單
        self.direction = 0
        self.num = 0
        self.speed_adjust = 0
        self.map_changex = 0
        self.map_changey = 0
        self.speed_up = False
        self.speed_up_time = 0
        # 魔王加群組
        self.boss = Boss()
        # boss = Boss(const.screen_width // 2 + self.map_changex, const.screen_height // 2 + self.map_changey)
        self.bosssprite.add(self.boss)
        '''遊戲精靈群組初始化結束'''

        self.volume_dct = {
            "v_0": pygame.image.load("images/volume/volume.png"),
            "v_1": pygame.image.load("images/volume/volume5.png"),
            "v_2": pygame.image.load("images/volume/volume4.png"),
            "v_3": pygame.image.load("images/volume/volume3.png"),
            "v_4": pygame.image.load("images/volume/volume2.png"),
            "v_5": pygame.image.load("images/volume/volume1.png"),
            "v_6": pygame.image.load("images/volume/volume0.png")
        }

        self.screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
Beispiel #23
0
    def boss_level(self):
        self._paddle = Paddle()
        self._boss = Boss()

        x = random.randint(
            int(config.WIDTH / 2 - config.PADDLE_LEN / 2) + 1,
            int(config.WIDTH / 2 + config.PADDLE_LEN / 2) - 1,
        )

        position = np.array([x, config.HEIGHT - 3 - 1])

        velocity = np.array([0.0, 0.0])

        self._ball = Ball(position=position, velocity=velocity)

        self._timer = 0
        self._firerate = 0
        self._bombrate = 0
        self._lasertimeleft = 0
        self._maxheight = 0

        self._paddle_bounce_vel = np.array([0.0, 0.0])

        self._objects = {
            "paddle": [self._paddle],
            "ball": [self._ball],
            "brick": [],
            "powerup": [],
            "bullet": [],
            "boss": [self._boss],
            "bomb": [],
            "bossdef": [],
        }

        self._active_powers = []
        self._total_breakable_bricks = 0

        for i in range(9):
            position = np.array(
                [config.WIDTH / 2 - 20 * (4.3 - i), 25 + (i % 2) * 5])
            self._maxheight = max(self._maxheight, 30)
            brick = Brick(4, position)
            self._objects["brick"].append(brick)
def run_game():
    #初始化pygame、设置和屏幕对象
    pygame.init()
    pygame.mixer.init()
    ai_settings = Settings()
    ms = Musics()
    ms.fplay()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Aline Invasion")
    #创建Play按钮
    play_button = Button(ai_settings, screen, "Play")
    #创建一个用于存储游戏统计信息的实例,并创建记分牌
    stats = GameStats(ai_settings)
    sb = Scoreboard(ai_settings, screen, stats)
    #创建一艘飞船,一个用于存储子弹的编组和一个外星人编组
    ship = Ship(ai_settings, screen)
    boss = Boss(ai_settings, screen)
    sd = Start_end(ai_settings, screen)
    bullets = Group()
    aliens = Group()
    alien1s = Group()
    #创建外星人群
    gf.create_fleet(ai_settings, screen, ship, aliens)
    #获取当前系统的字体
    #print(pygame.font.get_fonts())
    #开始游戏的主循环
    while True:
        gf.check_events(ai_settings, screen, stats, sb, play_button, ship,
                        aliens, alien1s, bullets, ms)
        if stats.game_active:
            ship.update()
            boss.update()
            gf.update_bullets(ai_settings, screen, stats, sb, ship, aliens,
                              bullets, alien1s, ms)
            gf.update_aliens(ai_settings, stats, screen, sb, ship, aliens,
                             alien1s, bullets, ms)
            gf.update_alien1s(ai_settings, stats, screen, sb, ship, aliens,
                              alien1s, bullets, ms)
            gf.update_boss(ai_settings, stats, sb, boss, bullets, ms)
            gf.add_alien(ai_settings, screen, boss, aliens, alien1s)
        gf.update_screen(ai_settings, screen, stats, sb, ship, aliens, bullets,
                         boss, alien1s, play_button, sd)
Beispiel #25
0
def init_game(player_images, ai_images, stage):
    if stage == 1:
        # wall group loading map
        wall_group = load_map_1()
    elif stage == 2:
        wall_group = load_map_2()
    else:
        wall_group = load_map_3()

    # ai_tank
    if stage == 3:
        ai_number = 1
        now_ai_number = 1
        ai = BossTank_2(ai_images)
        ai_group = Group()
        ai_group.add(ai)
    else:
        ai_number = 20
        now_ai_number = 3
        ai_1 = AiTank(ai_images)
        ai_2 = AiTank(ai_images)
        ai_3 = AiTank(ai_images)
        ai_group = Group()
        ai_group.add(ai_1)
        ai_group.add(ai_2)
        ai_group.add(ai_3)

    # boss
    boss = Boss(450, 560)
    # boss group
    boss_group = Group()
    boss_group.add(boss)

    # player
    player = Tank(player_images)

    # player bullet group
    bullet_group = Group()

    # ai_tank bullet group
    ai_bullet_group = Group()

    # tank group
    player_group = Group()
    player_group.add(player)

    gift_group = Group()

    tag_point = [(925 + (i % 2) * 25, 100 + (i // 2) * 25)
                 for i in range(ai_number)]

    return player, boss, player_group, boss_group, ai_group, bullet_group, ai_bullet_group, wall_group,\
        gift_group, now_ai_number, tag_point
 def get_initial_boss_limb_formation(self, boss_img, starting_xcor,
                                     starting_ycor):
     initial_formation = []
     for row in range(1):
         for col in range(1):
             current_xcor = starting_xcor + col * boss_img.get_width()
             current_ycor = starting_ycor + row * boss_img.get_height()
             initial_formation.append(
                 Boss(boss_img, current_xcor, current_ycor))
             self.xcor = current_xcor
             self.ycor = current_ycor
     return initial_formation
Beispiel #27
0
def big():
    for i in range(1):
        # This represents a block
        boss = Boss()

        # Set a random location for the block
        boss.rect.x = 1000
        boss.rect.y = 350

        # Add the block to the list of objects
        boss_list.add(boss)
        all_sprites_list.add(boss)
Beispiel #28
0
def run_game():

    # Initialize pygame, settings, and screen object.
    pygame.init()
    pygame.mixer.init()
    ai_settings = Settings()
    screen = pygame.display.set_mode(
        (ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption("Hell")
    # Set the games frame rate
    clock = pygame.time.Clock()
    #set up the sound channels
    channel1 = pygame.mixer.Channel(0)
    channel2 = pygame.mixer.Channel(1)
    shot = pygame.mixer.Sound('sounds/ship_shot.wav')
    hit = pygame.mixer.Sound('sounds/ship_hit.wav')
    boss_hit = pygame.mixer.Sound('sounds/boss_hit.wav')
    # Make a counter for the timed attackes
    ai_counter = 0
    # Make the Play button
    play_button = Button(ai_settings, screen, "Start")
    # Make a ship and group of bullets and a group of boss bullets
    ship = Ship(ai_settings, screen)
    bullets = Group()
    boss_bullets = Group()
    # Make a boss.
    boss = Boss(ai_settings, screen)
    # Create an instance to store game statistics and the ui
    stats = GameStats(ai_settings)
    ui = Ui(ai_settings, screen, stats)
    # Start the main loop for the game.
    while True:
        gf.check_events(ai_settings, screen, stats, play_button, ship, bullets,
                        shot)

        if stats.game_active and ai_settings.boss_health > 0:
            if ai_settings.boss_health == 700 and not ship.second_stage:
                gf.start_stage2(ai_settings, boss, ship)
            clock.tick(60)
            ai_counter = gf.update_counter(ai_counter)
            gf.update_boss_ai(ai_settings, screen, boss, boss_bullets,
                              ai_counter, ship)
            ship.update()
            gf.update_bullets(ai_settings, screen, ship, boss, bullets,
                              boss_hit)
            gf.update_boss(ai_settings, ai_counter, screen, ship, boss,
                           bullets)
            gf.update_boss_bullets(ai_settings, stats, screen, ship, boss,
                                   bullets, boss_bullets, hit)

        gf.update_screen(ai_settings, screen, stats, ship, boss, boss_bullets,
                         bullets, play_button, ui)
Beispiel #29
0
    def init(self):
        self.camera_pos = 0, 0
        self.game_over = False
        self.display = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
        self.surface = pygame.Surface((self.width, self.height))
        self.screen_width, self.screen_height = pygame.display.get_surface(
        ).get_size()
        self.clock = pygame.time.Clock()
        self.buildings.clear()
        self.objects.clear()
        self.enemies.clear()
        self.fellows.clear()
        if self.boss is not None:
            self.boss.game = None
        self.boss = None
        with open('Map/map.txt', 'r') as f:
            x = 0
            y = 0
            for line in f.readlines():
                for s in line:
                    if s == '#':
                        self.buildings.append(MainBuilding(x, y, self))
                    if s == '1':
                        self.buildings.append(HighBuilding(x, y, self))
                    if s == '@':
                        self.buildings.append(GreenBuilding(x, y, self))
                    if s == 'U':
                        self.buildings.append(UrfuBuilding(x, y, self))
                        self.boss = Boss(x - 200, y - 200, self)
                    x += Building.size * 2
                x = 0
                y += Building.size
        self.player = Player(150, 150, self)
        self.objects.append(self.player)
        self.objects.extend(self.buildings)
        self.keydown_handlers.clear()
        self.keyup_handlers.clear()
        self.mouse_handlers.clear()
        self.player.setup_handlers(self.keydown_handlers, self.keyup_handlers,
                                   self.mouse_handlers)

        for i in range(MAX_ENEMIES_COUNT // 2):
            self.enemies.append(self.create_hero(Enemy))
        for i in range(MAX_ENEMIES_COUNT // 2):
            self.enemies.append(self.create_hero(ShootingEnemy))
        self.objects.append(Citizen(150, 250, self))
        for i in range(MAX_CITIZENS_COUNT):
            self.objects.append(self.create_hero(Citizen))
        self.objects.extend(self.enemies)
        self.player.on_pos_changed = self.change_camera_pos
        self.ui = lives.Lives(10, 10, self)
Beispiel #30
0
    def init(self):
        margin = self.width * 0.10
        pygame.font.init()

        self.score = 0

        # Ship
        Ship.init(self.width)
        self.shipGroup = pygame.sprite.Group(Ship(self.width/2, \
                                                  self.height - margin))
        col = self.width // 10
        self.enemies = pygame.sprite.Group()

        # Boss
        Boss.init(self.width, 'images/boss.png')
        wB, hB = Boss.image.get_size()
        for i in range(3, 7):
            x = i * col + wB / 2
            y = margin
            self.enemies.add(Boss(x, y))

        # Guards
        Guard.init(self.width)
        for i in range(1, 9):
            for j in range(2, 4):
                x = i * col + wB / 2 + 1  # centered based on boss
                y = margin * j
                self.enemies.add(Guard(x, y))

        # Grunts
        Grunt.init(self.width)
        for i in range(10):
            for j in range(4, 6):
                x = i * col + wB / 2 + 1  # centered based on boss
                y = margin * j
                self.enemies.add(Grunt(x, y))

        self.bullets = pygame.sprite.Group()
Beispiel #31
0
def enter():
    import os
    os.chdir('D:/2016/2d gp/project/image')
    global nom,be,boss,life,attack,items,item2,back
    game_framework.reset_time()
    boss=Boss()
    nom=Nom()
    be=load_image("bossba.png")
    attack = [BossAttack() for i in range(12)]
    life=Life()
    items = [attack_item() for i in range(10)]
    item2=bonus_item()
    back=load_image("back.png")
    pass
Beispiel #32
0
    def addBoss1(self):
        new_baddie = Boss(10,self.boss1_width, self.boss1_height, self.width, 100, self.boss1_color, 1, 4)
        new_baddie.setHitPoints(100)
        new_baddie.canGetHit = False
        self.boss.append(new_baddie)
        self.turrets = 0

        new_baddie = Baddie(11,self.turret1_width, self.turret1_height, self.width-20, 300, self.turret1_color, 1, 5)
        new_baddie.setHitPoints(1)
        new_baddie.isTurret = True
        self.baddies.append(new_baddie)

        self.turrets += 1

        new_baddie = Baddie(11,self.turret1_width, self.turret1_height, self.width-20, 500, self.turret1_color, 1, 6)
        new_baddie.setHitPoints(1)
        new_baddie.isTurret = True
        self.baddies.append(new_baddie)
        self.turrets += 1
Beispiel #33
0
 def update(self):
     """Update game objects"""
     if self.state == 1:
         #self.player.immortal = 60
         # In Game
         # Spawn Things
         t = (pygame.time.get_ticks() - self.start) / 1000.0
         if self.spawn == 0:
             #Spawn Something
             if t < 30:
                 what = random.randint(0,8)
             elif t < 60:
                 what = random.randint(0,14)
             elif t < 90:
                 what = random.randint(0,15)
             elif t < 120:
                 what = random.randint(0,20)
             elif t < 150:
                 what = [random.randint(0,1),random.randint(9,14)]
                 what = what[random.randint(0,1)]
             elif t < 210:
                 what = random.randint(0,20)
             elif t > 220 and t < 300:
                 what = 100
             else:
                 what = -1
             # White blood cell
             if what == 100:
                 if not self.boss:
                     self.boss = Boss(600,0,screenSize)
             if what in range(0,1):
                 self.cells.append(WhiteBloodCell(801, random.randint(16, 368)))
             # Sickle cell
             if what in range(9,14):
                 for i in range(0,random.randint(1,10)):
                     x,y = random.randint(200,600), random.randint(0,1)
                     yvel = 0
                     xvel = 0
                     if x < 400:
                         xvel = 1
                     else:
                         xvel = -1
                     if y == 0:
                         y = -48
                         yvel = 1
                     else:
                         y = 480
                         yvel = -1
                     self.enemies.append(SickleCell(x, y, xvel * random.randint(0,5), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
             # Infected cell
             if what in range(2,8):
                 x,y = random.randint(200,600), random.randint(0,1)
                 yvel = 0
                 xvel = 0
                 if x < 400:
                     xvel = 1
                 else:
                     xvel = -1
                 if y == 0:
                     y = -48
                     yvel = 1
                 else:
                     y = 480
                     yvel = -1
                 self.enemies.append(InfectedCell(x, y, xvel * random.randint(0,3), yvel * random.randint(1,3), random.randint(725,9381), self.enemyprojectile))
             # Valve
             if what == 15 and not self.valves:
                 self.valves.append(Valve(screenSize, self.valveimage))
             # Viruses
             if what in range(16,20):
                 x,y = 800, random.randint(16,416)
                 self.enemies.append(Virus(x, y, -random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
             self.spawn = random.randint(5, 30)
         else:
             self.spawn -= 1
             
         # Spawn Valves at background transitions
         if (int(t) == 60) and self.v == 0:
             self.valves.append(Valve(screenSize, self.valveimage))
             self.v += 1
             self.spawn = random.randint(5, 30)
         if (int(t) == 120) and self.v == 1:
             self.valves.append(Valve(screenSize, self.valveimage))
             self.v += 1
             self.spawn = random.randint(5, 30)
         if (int(t) == 180) and self.v == 2:
             self.valves.append(Valve(screenSize, self.valveimage))
             self.v += 1
             self.spawn = random.randint(5, 30)
         if (int(t) == 200) and self.v == 3:
             self.valves.append(Valve(screenSize, self.valveimage))
             self.v += 1
             self.spawn = random.randint(5, 30)
         
         if self.boss:
             if self.spawn == 0:
                 if self.boss.phase == 0:
                     for i in range(0, random.randint(1, 10)):
                         x,y = random.randint(300,500), random.randint(0,1)
                         yvel = 0
                         if y == 0:
                             y = -48
                             yvel = 1
                         else:
                             y = 480
                             yvel = -1
                         self.enemies.append(SickleCell(x, y, (-1 ** random.randint(0,1)), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                 elif self.boss.phase == 1:
                     if random.randint(0,5):
                         x,y = random.randint(300,500), random.randint(0,1)
                         yvel = 0
                         if y == 0:
                             y = -48
                             yvel = 1
                         else:
                             y = 480
                             yvel = -1
                         self.enemies.append(InfectedCell(x, y, (-1 ** random.randint(0,1)) * random.randint(0,1), yvel * random.randint(1,3), random.randint(725,9381), self.enemyprojectile))
                     else:
                         x, y = random.randint(300,500), random.randint(0,1)
                         xvel = -3
                         yvel = 2 * ((-1)**y)
                         y = (y * 540) - 60
                         ncell = WhiteBloodCell(x, y, xvel, yvel)
                         self.cells.append(ncell)
                 elif self.boss.phase == 2:
                     for i in range(0, random.randint(1, 10)):
                         x,y = random.randint(300,500), random.randint(0,1)
                         yvel = 0
                         if y == 0:
                             y = -48
                             yvel = 1
                         else:
                             y = 480
                             yvel = -1
                         self.enemies.append(SickleCell(x, y, (-1 ** random.randint(0,1)), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                 self.spawn = random.randint(40, 50)
             else:
                 self.spawn -= 1
         
             
         # Do the updates
         p = self.player.update()
         if p:
             self.projectiles = self.projectiles + p
         if self.boss:
             p = self.boss.update(self.player.rect.centerx, self.player.rect.centery)
             if p:
                 self.eprojectiles = self.eprojectiles + p
         for i in self.enemies:
             if isinstance(i, Virus):
                 p = i.update(self.player.rect.x, self.player.rect.y)
                 if p:
                     self.eprojectiles = self.eprojectiles + p
             else:
                 p = i.update()
                 if p:
                     self.eprojectiles = self.eprojectiles + p
         for i in self.projectiles + self.eprojectiles + self.cells + self.valves:
             i.update()
         
         # Check for collisions, deal damage
         #   Check projectiles against enemies and player
         #   Check player/enemies against cells and each other self.enemies + 
         for e1 in self.cells + [self.player]:
             for p in self.projectiles + self.eprojectiles:
                 if collision_detect(p, e1):
                     # Handle WhiteCellProj splitting
                     if isinstance(p, WhiteCellProj):
                         np = p.take_damage(-1)
                         if np:
                             self.projectiles = self.projectiles + np
                     else:
                         p.take_damage(-1)
                     e1.take_damage(p.damage)
             for e2 in self.enemies + self.cells + [self.player]:
                 if e1 != e2:
                     if collision_detect(e1, e2):
                         e1.take_damage(e2.damage)
                         e2.take_damage(e1.damage)
         for e1 in self.enemies:
             for p in self.projectiles:
                 if collision_detect(p, e1):
                     if isinstance(p, WhiteCellProj):
                         np = p.take_damage(-1)
                         if np:
                             self.projectiles = self.projectiles + np
                     else:
                         p.take_damage(-1)
                     e1.take_damage(p.damage)
         for v in self.valves:
             for e in self.enemies + self.cells + self.projectiles + self.eprojectiles + [self.player]:
                 if valve_collision_detect(v, e):
                     e.take_damage(-1)
         
         if self.boss:
             for p in self.projectiles + [self.player]:
                 np = self.boss.collide(p)
                 if np:
                     self.projectiles = self.projectiles + np
         
         np = False
         for c in self.cells:
             w1 = self.player.rect.width // 2
             w2 = c.rect.width // 2
             np = np or (math.sqrt(((self.player.rect.x + w2) - (c.rect.x + w2))**2 + ((self.player.rect.y + w2) - (c.rect.y + w2))**2) < (w1 + w2 + 128))
         self.player.nearpower = np
         
         # If off the screen by 64 pixels, set health to 0 (might need tweaking for spawning)
         for i in self.enemies + self.projectiles + self.eprojectiles + self.cells:
             i.check_off_screen(screenSize[0], screenSize[1], boundaryTolerance)        
         
         # Cull dead items
         for i in self.enemies:
             self.enemies = [e for e in self.enemies if e.health != 0]
         for i in self.projectiles:
             self.projectiles = [p for p in self.projectiles if p.health != 0]
         for i in self.eprojectiles:
             self.eprojectiles = [p for p in self.eprojectiles if p.health != 0]
         for i in self.cells:
             self.cells = [c for c in self.cells if c.health != 0]
         
         t = (pygame.time.get_ticks() - self.start) / 1000.0
         
         if t >= 300:
             self.lives = 0
             
         if self.lives == 0:
             if self.themeplaying:
                 pygame.mixer.music.stop()
                 pygame.mixer.music.load("sfx/beat.wav")
                 pygame.mixer.music.play(-1)
                 self.themeplaying = False
             self.state = 2
         if self.player.health == 0:
             self.player = Player(screenSize, self.playerprojectile)
             self.lives -= 1
         if self.boss and self.boss.health == 0:
             if self.themeplaying:
                 pygame.mixer.music.stop()
                 pygame.mixer.music.load("sfx/beat.wav")
                 pygame.mixer.music.play(-1)
                 self.themeplaying = False
             self.state = 3
             
         self.score = int(300 - t)
Beispiel #34
0
class Game(object):
    def __init__(self):
        """Initialize the game"""
        pygame.init()
        self.screen = pygame.display.set_mode(screenSize, pygame.FULLSCREEN)
        pygame.display.set_caption("Tumor Raider")
        self.clock = pygame.time.Clock()
        self.enemies = []
        self.projectiles = []
        self.eprojectiles = []
        self.cells = []
        self.valves = []
        self.player = None
        self.player = None
        self.spawn = 20
        self.state = 0
        self.overlay = pygame.image.load("gfx/UIOverlay.png").convert_alpha()
        self.shipicon = pygame.image.load("gfx/shipicon.png").convert_alpha()
        self.menu = pygame.image.load("gfx/menu.png").convert_alpha()
        self.gameover = pygame.image.load("gfx/gameover.png").convert_alpha()
        self.winrar = pygame.image.load("gfx/WinScreen.png").convert()
        self.wintext = pygame.image.load("gfx/WinScreentext.png").convert_alpha()
        self.numbers = pygame.image.load("gfx/Numbers.png").convert_alpha()
        self.playerprojectile = pygame.image.load("gfx/playerprojectile.png").convert_alpha()
        self.enemyprojectile = pygame.image.load("gfx/enemyprojectile.png").convert_alpha()
        self.valveimage = pygame.image.load("gfx/valve.png").convert_alpha()
        pygame.mixer.music.load("sfx/beat.wav")
        pygame.mixer.music.play(-1)
        self.themeplaying = False
        self.lives = 3
        self.shieldcolor = (61,196,240)
        self.healthcolor = (250,25,20)
        self.bosshealthcolor = (25,250,20)
        self.mitem = 0
        self.map = Map(pygame.time.get_ticks())
        self.start = pygame.time.get_ticks()
        self.v = 0
        self.score = 0
        
    def reset(self):
        self.clock = pygame.time.Clock()
        self.map = Map(pygame.time.get_ticks())
        self.enemies = []
        self.projectiles = []
        self.eprojectiles = []
        self.cells = []
        self.valves = []
        self.player = Player(screenSize, self.playerprojectile)
        self.boss = None
        self.spawn = 20
        self.lives = 3
        self.mitem = 0
        self.start = pygame.time.get_ticks()
        self.v = 0
        if not self.themeplaying:
            pygame.mixer.music.stop()
            pygame.mixer.music.load("sfx/themesong.wav")
            pygame.mixer.music.play(-1)
            self.themeplaying = True
        
    def update(self):
        """Update game objects"""
        if self.state == 1:
            #self.player.immortal = 60
            # In Game
            # Spawn Things
            t = (pygame.time.get_ticks() - self.start) / 1000.0
            if self.spawn == 0:
                #Spawn Something
                if t < 30:
                    what = random.randint(0,8)
                elif t < 60:
                    what = random.randint(0,14)
                elif t < 90:
                    what = random.randint(0,15)
                elif t < 120:
                    what = random.randint(0,20)
                elif t < 150:
                    what = [random.randint(0,1),random.randint(9,14)]
                    what = what[random.randint(0,1)]
                elif t < 210:
                    what = random.randint(0,20)
                elif t > 220 and t < 300:
                    what = 100
                else:
                    what = -1
                # White blood cell
                if what == 100:
                    if not self.boss:
                        self.boss = Boss(600,0,screenSize)
                if what in range(0,1):
                    self.cells.append(WhiteBloodCell(801, random.randint(16, 368)))
                # Sickle cell
                if what in range(9,14):
                    for i in range(0,random.randint(1,10)):
                        x,y = random.randint(200,600), random.randint(0,1)
                        yvel = 0
                        xvel = 0
                        if x < 400:
                            xvel = 1
                        else:
                            xvel = -1
                        if y == 0:
                            y = -48
                            yvel = 1
                        else:
                            y = 480
                            yvel = -1
                        self.enemies.append(SickleCell(x, y, xvel * random.randint(0,5), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                # Infected cell
                if what in range(2,8):
                    x,y = random.randint(200,600), random.randint(0,1)
                    yvel = 0
                    xvel = 0
                    if x < 400:
                        xvel = 1
                    else:
                        xvel = -1
                    if y == 0:
                        y = -48
                        yvel = 1
                    else:
                        y = 480
                        yvel = -1
                    self.enemies.append(InfectedCell(x, y, xvel * random.randint(0,3), yvel * random.randint(1,3), random.randint(725,9381), self.enemyprojectile))
                # Valve
                if what == 15 and not self.valves:
                    self.valves.append(Valve(screenSize, self.valveimage))
                # Viruses
                if what in range(16,20):
                    x,y = 800, random.randint(16,416)
                    self.enemies.append(Virus(x, y, -random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                self.spawn = random.randint(5, 30)
            else:
                self.spawn -= 1
                
            # Spawn Valves at background transitions
            if (int(t) == 60) and self.v == 0:
                self.valves.append(Valve(screenSize, self.valveimage))
                self.v += 1
                self.spawn = random.randint(5, 30)
            if (int(t) == 120) and self.v == 1:
                self.valves.append(Valve(screenSize, self.valveimage))
                self.v += 1
                self.spawn = random.randint(5, 30)
            if (int(t) == 180) and self.v == 2:
                self.valves.append(Valve(screenSize, self.valveimage))
                self.v += 1
                self.spawn = random.randint(5, 30)
            if (int(t) == 200) and self.v == 3:
                self.valves.append(Valve(screenSize, self.valveimage))
                self.v += 1
                self.spawn = random.randint(5, 30)
            
            if self.boss:
                if self.spawn == 0:
                    if self.boss.phase == 0:
                        for i in range(0, random.randint(1, 10)):
                            x,y = random.randint(300,500), random.randint(0,1)
                            yvel = 0
                            if y == 0:
                                y = -48
                                yvel = 1
                            else:
                                y = 480
                                yvel = -1
                            self.enemies.append(SickleCell(x, y, (-1 ** random.randint(0,1)), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                    elif self.boss.phase == 1:
                        if random.randint(0,5):
                            x,y = random.randint(300,500), random.randint(0,1)
                            yvel = 0
                            if y == 0:
                                y = -48
                                yvel = 1
                            else:
                                y = 480
                                yvel = -1
                            self.enemies.append(InfectedCell(x, y, (-1 ** random.randint(0,1)) * random.randint(0,1), yvel * random.randint(1,3), random.randint(725,9381), self.enemyprojectile))
                        else:
                            x, y = random.randint(300,500), random.randint(0,1)
                            xvel = -3
                            yvel = 2 * ((-1)**y)
                            y = (y * 540) - 60
                            ncell = WhiteBloodCell(x, y, xvel, yvel)
                            self.cells.append(ncell)
                    elif self.boss.phase == 2:
                        for i in range(0, random.randint(1, 10)):
                            x,y = random.randint(300,500), random.randint(0,1)
                            yvel = 0
                            if y == 0:
                                y = -48
                                yvel = 1
                            else:
                                y = 480
                                yvel = -1
                            self.enemies.append(SickleCell(x, y, (-1 ** random.randint(0,1)), yvel * random.randint(2,5), random.randint(725,9381), self.enemyprojectile))
                    self.spawn = random.randint(40, 50)
                else:
                    self.spawn -= 1
            
                
            # Do the updates
            p = self.player.update()
            if p:
                self.projectiles = self.projectiles + p
            if self.boss:
                p = self.boss.update(self.player.rect.centerx, self.player.rect.centery)
                if p:
                    self.eprojectiles = self.eprojectiles + p
            for i in self.enemies:
                if isinstance(i, Virus):
                    p = i.update(self.player.rect.x, self.player.rect.y)
                    if p:
                        self.eprojectiles = self.eprojectiles + p
                else:
                    p = i.update()
                    if p:
                        self.eprojectiles = self.eprojectiles + p
            for i in self.projectiles + self.eprojectiles + self.cells + self.valves:
                i.update()
            
            # Check for collisions, deal damage
            #   Check projectiles against enemies and player
            #   Check player/enemies against cells and each other self.enemies + 
            for e1 in self.cells + [self.player]:
                for p in self.projectiles + self.eprojectiles:
                    if collision_detect(p, e1):
                        # Handle WhiteCellProj splitting
                        if isinstance(p, WhiteCellProj):
                            np = p.take_damage(-1)
                            if np:
                                self.projectiles = self.projectiles + np
                        else:
                            p.take_damage(-1)
                        e1.take_damage(p.damage)
                for e2 in self.enemies + self.cells + [self.player]:
                    if e1 != e2:
                        if collision_detect(e1, e2):
                            e1.take_damage(e2.damage)
                            e2.take_damage(e1.damage)
            for e1 in self.enemies:
                for p in self.projectiles:
                    if collision_detect(p, e1):
                        if isinstance(p, WhiteCellProj):
                            np = p.take_damage(-1)
                            if np:
                                self.projectiles = self.projectiles + np
                        else:
                            p.take_damage(-1)
                        e1.take_damage(p.damage)
            for v in self.valves:
                for e in self.enemies + self.cells + self.projectiles + self.eprojectiles + [self.player]:
                    if valve_collision_detect(v, e):
                        e.take_damage(-1)
            
            if self.boss:
                for p in self.projectiles + [self.player]:
                    np = self.boss.collide(p)
                    if np:
                        self.projectiles = self.projectiles + np
            
            np = False
            for c in self.cells:
                w1 = self.player.rect.width // 2
                w2 = c.rect.width // 2
                np = np or (math.sqrt(((self.player.rect.x + w2) - (c.rect.x + w2))**2 + ((self.player.rect.y + w2) - (c.rect.y + w2))**2) < (w1 + w2 + 128))
            self.player.nearpower = np
            
            # If off the screen by 64 pixels, set health to 0 (might need tweaking for spawning)
            for i in self.enemies + self.projectiles + self.eprojectiles + self.cells:
                i.check_off_screen(screenSize[0], screenSize[1], boundaryTolerance)        
            
            # Cull dead items
            for i in self.enemies:
                self.enemies = [e for e in self.enemies if e.health != 0]
            for i in self.projectiles:
                self.projectiles = [p for p in self.projectiles if p.health != 0]
            for i in self.eprojectiles:
                self.eprojectiles = [p for p in self.eprojectiles if p.health != 0]
            for i in self.cells:
                self.cells = [c for c in self.cells if c.health != 0]
            
            t = (pygame.time.get_ticks() - self.start) / 1000.0
            
            if t >= 300:
                self.lives = 0
                
            if self.lives == 0:
                if self.themeplaying:
                    pygame.mixer.music.stop()
                    pygame.mixer.music.load("sfx/beat.wav")
                    pygame.mixer.music.play(-1)
                    self.themeplaying = False
                self.state = 2
            if self.player.health == 0:
                self.player = Player(screenSize, self.playerprojectile)
                self.lives -= 1
            if self.boss and self.boss.health == 0:
                if self.themeplaying:
                    pygame.mixer.music.stop()
                    pygame.mixer.music.load("sfx/beat.wav")
                    pygame.mixer.music.play(-1)
                    self.themeplaying = False
                self.state = 3
                
            self.score = int(300 - t)

            
    def process_events(self):
        """Process the event queue"""
        ret = True
        if self.state in [0,2,3]:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                if event.type == pygame.KEYDOWN:
                    # Exit on Escape
                    if event.key == pygame.K_RETURN:
                        if self.mitem == 1:
                            ret = False
                        else:
                            self.reset()
                            self.state = 1
                    if event.key == pygame.K_ESCAPE:
                        ret = False
                    if event.key == pygame.K_LEFT or event.key == pygame.K_UP:
                        self.mitem = 0
                    if event.key == pygame.K_RIGHT or event.key == pygame.K_DOWN:
                        self.mitem = 1
        if self.state == 1:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()
                if event.type == pygame.KEYDOWN:
                    # Exit on Escape
                    if event.key == pygame.K_ESCAPE:
                        self.state = 0
                        if self.themeplaying:
                            pygame.mixer.music.stop()
                            pygame.mixer.music.load("sfx/beat.wav")
                            pygame.mixer.music.play(-1)
                            self.themeplaying = False
                    if event.key == pygame.K_LEFT:
                        self.player.input[0] = True
                    if event.key == pygame.K_RIGHT:
                        self.player.input[1] = True
                    if event.key == pygame.K_UP:
                        self.player.input[2] = True
                    if event.key == pygame.K_DOWN:
                        self.player.input[3] = True
                    if event.key == pygame.K_SPACE:
                        self.player.input[4] = True
                    if event.key == pygame.K_s:
                        self.player.input[5] = True
                elif event.type == pygame.KEYUP:
                    if event.key == pygame.K_LEFT:
                        self.player.input[0] = False
                    if event.key == pygame.K_RIGHT:
                        self.player.input[1] = False
                    if event.key == pygame.K_UP:
                        self.player.input[2] = False
                    if event.key == pygame.K_DOWN:
                        self.player.input[3] = False
                    if event.key == pygame.K_SPACE:
                        self.player.input[4] = False
                    if event.key == pygame.K_s:
                        self.player.input[5] = False
        return ret
        
    def draw_numbers(self, x, y, number):
        """Draw numbers on the screen."""
        digits = []
        if not number:
            digits = [0]
        while number:
            digits.insert(0, number % 10)
            number /= 10
        for place, digit in enumerate(digits):
            self.screen.blit(self.numbers, pygame.Rect(x + place * 14, y, 14, 18), pygame.Rect(digit * 14, 0, 14, 18))

    def draw(self):
        """Draw game objects"""
        if self.state == 0:
            # Draw menu and box around current selection beased on self.mitem
            self.map.draw(self.screen)
            self.screen.blit(self.menu, pygame.Rect(50,40,700,400), pygame.Rect(700 * self.mitem, 0, 700, 400))
        if self.state == 1:
            self.map.draw(self.screen)
            for i in self.cells + self.valves + self.enemies + [self.player, self.boss] + self.projectiles + self.eprojectiles:
                if i:
                    i.draw(self.screen)
            self.screen.blit(self.overlay, pygame.Rect(0, 0, 800, 25))
            #draws the shield bar for the hud
            self.screen.fill(self.shieldcolor, pygame.Rect(310, 6, self.player.shieldenergy * 5/6, 16))
            #draws the health bar for the hud
            self.screen.fill(self.healthcolor, pygame.Rect(632,6, 1.0 * self.player.health / self.player.fullhealth * 164,16))
            #draws the ship icons, for lives left
            if self.boss:
                self.screen.fill(self.bosshealthcolor, pygame.Rect(200,460, 1.0 * self.boss.health / self.boss.maxhealth * 350,16))
            for i in range(self.lives):
                self.screen.blit(self.shipicon, pygame.Rect(97 + i*52, 1, 26, 25))
            #draws the score
            self.draw_numbers(0, screenSize[1] - 18, self.score)#test values
            
        if self.state == 2:
            # Draw game over menu and box around current selection based on self.mitem
            self.map.draw(self.screen)
            self.screen.blit(self.gameover, pygame.Rect(50,40,700,400), pygame.Rect(700 * self.mitem, 0, 700, 400))
        if self.state == 3:
            self.screen.blit(self.winrar, pygame.Rect(0,0,800,480), pygame.Rect(0, 0, 800, 480))
            self.draw_numbers(480, 85, 300 - self.score)
            self.screen.blit(self.wintext, pygame.Rect(400 * self.mitem,0,400,480), pygame.Rect(400 * self.mitem, 0, 400, 480))