示例#1
0
    def update(self):
        self.time += mainframe.frame_time

        if self.shootCheck == True:
            self.shootTime += mainframe.frame_time

        # update
        self.update_AI()
        self.update_anim()

        # 맵 밖을 나가면 몬스터를 없앤다.
        if (self.posX < 0 - self.sizeX) or (self.posX >
                                            static.canvas_width + self.sizeX):
            return True
        elif (self.posY < 0 - self.sizeY):
            return True
        # 체력이 다되면 몬스터를 없앤다.
        elif (self.hp <= 0):
            game_world.add_object(
                Effect(self.posX, self.posY, 'random_effect', '',
                       self.originSizeX, self.originSizeY), EFFECT)
            game_world.curtain_object(PLAYER, 0).parsingScoreBar(
                random.randint(100, 500) * self.difficulty)
            game_world.add_object(
                Coin(self.posX, self.posY, 1.5, 1.5,
                     random.randint(1, 5) * (self.difficulty) * 100), COIN)
            Monster.sound.get(str(random.randint(1, 2))).play()
            return True
        else:
            return False
示例#2
0
    def collideActive(self, opponent):
        if opponent.bulletType == 'Anim_Stop':
            return

        if self.posY <= 700:
            self.hp -= opponent.attackDamage
            game_world.curtain_object(PLAYER, 0).parsingScoreBar(
                opponent.attackDamage * random.randint(2, 5))
            Boss.sound.get('hit').play()
示例#3
0
def handle_events():
    global mouse
    events = get_events()
    for event in events:
        if (event.type == SDL_QUIT):
            mainframe.quit()
        else:
            if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE):
                mainframe.quit()
            elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_c):
                game_world.curtain_object(PLAYER, 0).parsingMoneyBar(1000000)

        mouse.handle_events(event)
示例#4
0
    def __init__(self, posX, posY, moveSpeed, sizeX, sizeY):
        self.posX = posX
        self.posY = posY
        self.moveSpeed = moveSpeed
        self.sizeX = sizeX
        self.sizeY = sizeY
        self.originSizeX = sizeX
        self.originSizeY = sizeY
        self.rectSizeX = 0
        self.rectSizeY = 0
        self.frame = 0
        self.shootTime = 0
        self.shootDelay = 0
        self.shootCheck = False
        self.collideCheck = False
        self.hp = 0
        self.attackDamage = 0
        self.time = 0
        self.difficulty = 1

        if Monster.sound == None:
            self.initialize_sound()

        # 부모
        self.player = None
        if len(game_world.get_layer(PLAYER)) > 0:
            self.player = game_world.curtain_object(PLAYER, 0)
            self.playerAttackDamage = self.player.attackDamage
def initialize():
    global mouse
    # stage
    global stage
    global stageCount
    global stageCountMax
    # spawn
    global monsterSpawnCheck
    global bossCheck
    # map
    global totalmap
    global map1
    global map2
    # player
    global player
    global monsterpattern
    # bgm
    global bgm
    global bossbgm
    # mouse
    mouse = game_world.curtain_object(MOUSE, 0)

    # stage
    stage = 1
    stageCount = 0
    stageCountMax = 5
    # spawn
    monsterpattern = None
    monsterSpawnCheck = True
    bossCheck = False

    # shop state
    shop_state.price = 500

    # map
    # stage 별로 리스트에 보관
    map1 = [Map(1, 0, 2000, mapSpeed)]
    map2 = [Map(2, 0, 2000, mapSpeed)]
    # 리스트 별로 딕셔너리에 스테이지 번호와 함께 보관
    totalmap = {1: map1, 2: map2}
    # player
    player = Player()
    # monster
    monsterpattern = Monster_Pattern()
    Monster_Pattern.difficulty = 1
    game_world.add_object(player, PLAYER)

    # bgm
    bgm = load_music(
        os.path.join(os.getcwd(), 'resources', 'sound', 'back', 'stage.mp3'))
    bgm.set_volume(60)
    bgm.repeat_play()

    bossbgm = load_music(
        os.path.join(os.getcwd(), 'resources', 'sound', 'back', 'boss.mp3'))
    bossbgm.set_volume(30)
示例#6
0
    def update(self):

        self.time += mainframe.frame_time

        if self.shootCheck == True:
            self.shootTime += mainframe.frame_time
        if self.delayCheck == True:
            self.delayTime += mainframe.frame_time

        if self.deadCheck == False:
            self.update_AI()
            self.update_anim()

        if (self.hp <= 0):
            # hand
            if self.type == 'Left' or self.type == 'Right':
                self.type = 'None'
                game_world.add_object(
                    Effect(self.posX, self.posY, 'random_effect', '',
                           self.originSizeX * 2, self.originSizeY * 2), EFFECT)
                game_world.curtain_object(PLAYER, 0).parsingScoreBar(
                    random.randint(1, 10) * self.difficulty * 1000)
                Boss.sound.get('bossexplode').play()
                return True

            # head
            if self.deadCheck == False:
                Boss.sound.get('dying').play()
                self.deadCheck = True
            check = self.deadProcess()
            if check == True:
                game_world.add_object(
                    Effect(self.posX, self.posY, 'random_effect', '',
                           self.originSizeX * 3, self.originSizeY * 3), EFFECT)
                game_world.curtain_object(PLAYER, 0).parsingScoreBar(
                    random.randint(1, 5) * self.difficulty * 200)
                Boss.sound.get('bossexplode').play()
                return True
            else:
                return False
示例#7
0
    def __init__(self, type, headinfo):
        posX = 0
        posY = 0
        moveSpeed = 10
        sizeX = 1.75
        sizeY = 1.75
        Boss.__init__(self, posX, posY, moveSpeed, sizeX, sizeY)
        #image
        if BossHand.image == None:
            BossHand.image = {
                'Left':
                load_image(
                    os.path.join(os.getcwd(), 'resources', 'boss',
                                 'Hand_L.png')),
                'Right':
                load_image(
                    os.path.join(os.getcwd(), 'resources', 'boss',
                                 'Hand_R.png'))
            }
        self.type = type
        self.image = BossHand.image.get(self.type)
        # 부모
        self.headinfo = headinfo
        # size of png
        self.pngSizeX = 85
        self.pngSizeY = 49
        # size
        self.rectSizeX = (self.pngSizeX // 2) * self.sizeX
        self.rectSizeY = (self.pngSizeY // 2) * self.sizeY
        self.sizeX = self.pngSizeX * self.sizeX
        self.sizeY = self.pngSizeY * self.sizeY
        self.bulletsizeX = 0
        self.bulletsizeY = 0
        #
        self.angle = 270
        self.angleSpeed = 350
        # for AI check
        self.moveMode = True
        self.attackMode = False
        self.specialMoveMode = False
        self.specialAttMode = False
        self.attackInfoInit = False
        self.attackID = 99
        # for AI move
        self.moveLocation = 0
        self.moveT = 0
        self.speedT = 50
        self.moveT_Curv = 0
        self.curvSpeedT = 200
        # for AI shoot
        self.originShootDelay = 0
        self.shootDelay = 0
        self.shootSpeed = 0

        self.shootMax = 0
        self.shootCount = 0
        self.shootterm = False
        self.shootAngle = 0

        self.tmpCount = 0

        # for AI pos
        self.originPosX = []
        self.originPosY = []
        self.startPos = []
        self.currentPos = []
        self.curvPos = []
        self.initialize_course()

        # 부모
        self.player = None
        if len(game_world.get_layer(PLAYER)) > 0:
            self.player = game_world.curtain_object(PLAYER, 0)

        # abilities
        self.hp = 100
        self.attackDamage = 10

        self.modify_abilities()
def cheat_key(event):
    global monsterSpawnCheck
    global rectCheck
    global stage
    global stageCountMax
    global stageCount
    global shop_cheat
    global bossCheck

    # 난이도 조절
    if (event.type, event.key) == (SDL_KEYDOWN, SDLK_q):
        monsterSpawnCheck = True
        stage -= 1
        stageCount = 0
        stageCountMax -= 5
        Monster_Pattern.difficulty -= 1
        for map in totalmap.get(2):
            map.speed -= 100
        player.stage_number.setNumbers(stage)
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_w):
        monsterSpawnCheck = True
        stage += 1
        stageCount = 0
        stageCountMax += 1
        Monster_Pattern.difficulty += 1
        for map in totalmap.get(2):
            map.speed += 100
        player.stage_number.setNumbers(stage)

    # 충돌체 보이고 안보이고
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_p):
        if rectCheck == False:
            rectCheck = True
        else:
            rectCheck = False

    # 바로 보스
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_b):
        monsterSpawnCheck = False
        game_world.clear_layer(MONSTER)

    # 상점
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_n):
        mainframe.push_state(shop_state)
        shop_cheat = True

    # 바로 죽음
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_m):
        player.hp = 0

    # 플레이어 능력치 조절
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_z):
        player.parsingHPBar(50)
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_x):
        player.parsingBombBar(1)
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_c):
        player.parsingMoneyBar(1000000)

    # 보스 패턴
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_1):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 1
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_2):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 2
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_3):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 3
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_4):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 4
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_5):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 5
    elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_6):
        if game_world.curtain_object(BOSS, 2) != None:
            game_world.curtain_object(BOSS, 2).attackID = 6
示例#9
0
def initialize():
    global mouse
    global bgm
    # background
    game_world.add_object(Others(250, 350, 1, 1, 'shop_back', 0.7), UIDEFAULT)
    # shop logo
    game_world.add_object(Others(250, 600, 1, 1, 'shop_logo', 1.0), UIDEFAULT)

    # money cap(not use)
    # game_world.add_object(Others(400, 570, 1.3, 1.3, 'money_capacity', 1.0), UIDEFAULT)

    # attUpgrade button
    playerAttID = game_world.curtain_object(PLAYER, 0).parsingID
    attUpgradeButton = Button(150, 440, 1, 1, 'default', 'attUpgrade')
    attUpgradeButton.set_numbers(attUpgradeButton.posX + 30,
                                 attUpgradeButton.posY - 25, 2, 2, 17,
                                 int(playerAttID))
    attUpgradeButton.set_additionalimage(attUpgradeButton.posX,
                                         attUpgradeButton.posY + 10, 1, 1,
                                         playerAttID, 1)
    attUpgradeButton.additionalImage.setOtherImageToIndex(int(playerAttID))
    # 가격
    if price == None:
        attUpgradeButton.numbers_others[1] = Numbers(190, 370, 1.5, 1.5, 17,
                                                     500)
    else:
        attUpgradeButton.numbers_others[1] = Numbers(190, 370, 1.5, 1.5, 17,
                                                     price)
    game_world.add_object(attUpgradeButton, UIDEFAULT)
    # 가격
    # game_world.add_object(Numbers(175, 370, 1.5, 1.5, 17, 1500), UIDEFAULT)

    # lifeUpgrade button
    lifeUpgradeButton = Button(350, 440, 1, 1, 'default', 'lifeUpgrade')
    lifeUpgradeButton.set_additionalimage(lifeUpgradeButton.posX,
                                          lifeUpgradeButton.posY, 1, 1,
                                          'posion', 1)
    game_world.add_object(lifeUpgradeButton, UIDEFAULT)
    # 가격
    game_world.add_object(Numbers(368, 370, 1.5, 1.5, 17, 500), UIDEFAULT)

    # magicaUpgrade button
    magicaUpgradeButton = Button(250, 280, 1, 1, 'default', 'magicaUpgrade')
    magicaUpgradeButton.set_additionalimage(magicaUpgradeButton.posX,
                                            magicaUpgradeButton.posY, 1, 1,
                                            'magica', 1)
    game_world.add_object(magicaUpgradeButton, UIDEFAULT)
    # 가격
    game_world.add_object(Numbers(275, 210, 1.5, 1.5, 17, 5000), UIDEFAULT)

    # restart button
    game_world.add_object(Button(250, 140, 0.8, 0.8, 'restart', 'resume'),
                          UIDEFAULT)

    mouse = game_world.curtain_object(MOUSE, 0)

    # bgm
    bgm = load_music(
        os.path.join(os.getcwd(), 'resources', 'sound', 'back', 'shop.mp3'))
    bgm.set_volume(64)
    bgm.repeat_play()