예제 #1
0
def structureEnter(stageN):
    global structure
    object_structure.TESTINGGAME = TESTINGGAME
    for i in lo.loadState.structData[stageN]:
        l, d, x, y = i
        st = object_structure.Box("box", l, d, x, y, 100, 100, "NPC", "box",
                                  100)
        st.collision = collider.Collision(st)
        structure.append(st)
예제 #2
0
def enemyEnter(selectEnemy, countEnenmy):
    global enemy, enemyList, MOVE_TIME
    p = lo.loadState.enemy[selectEnemy]
    #MOVE_TIME = delta_time.deltaTime()
    object_enemy.MOVE_TIME = MOVE_TIME
    object_enemy.TESTINGGAME = TESTINGGAME
    for i in range(countEnenmy):
        enemy = object_enemy.enemy(
            p["name"],
            p["x"] + 450 + (random.randint(100, 200) * random.randint(-1, 1)),
            p["y"] + 450 + (random.randint(100, 200) * random.randint(-1, 1)),
            p['rad'], p["rotateForce"], p['SpeedForce'], p["ai"], p["width"],
            p['high'], p["attackDelay"])
        enemy.collision = collider.Collision(enemy)
        enemyList.append(enemy)
예제 #3
0
def playerEnter(selectPlayer):
    global player, MOVE_TIME
    p = lo.loadState.player[selectPlayer]
    #MOVE_TIME = delta_time.deltaTime()
    object_player.MOVE_TIME = MOVE_TIME
    object_player.TESTINGGAME = TESTINGGAME
    player = object_player.Player(selectPlayer, p["name"], p['x'], p['y'],
                                  p['hp'], p['rad'], p['rotateSpeed'],
                                  p['fowardSpeed'], p['backSpeed'], p['width'],
                                  p['high'], p['weaponKind'], p["attackCool"])
    player.collision = collider.Collision(player)
    if notFirstGame:
        setDB()
        player.hp = playerCurHp
        for i in range(player.weaponCount):
            player.wp[i] = playerCurMagnize[i]
예제 #4
0
def enemyUpdate():
    global player, enemy, test, MOVE_TIME, pp

    for e in enemyList:
        #print(e.state,e.blocked)
        e.found = collider.isInRange(player, e, e.searchR, False)
        #print(e.found)
        if e.found:
            e.attack = collider.isInRange(player, e, e.attackR, False)
            if e.attack:
                e.tx, e.ty, e.dist = collider.isInRange(
                    player, e, e.attackR, True)
                e.state = 'attack'
            else:
                e.tx, e.ty, e.dist = collider.isInRange(
                    player, e, e.searchR, True)
                e.state = 'found'
            #e.collision.isCollider(player)
        for ae in enemyList:
            if e.count != ae.count:
                if e.collision.isCollider(ae):
                    e.blocked = collider.isBlocked(ae, e)
                    dist = math.sqrt((ae.x - e.x)**2 + (ae.y - e.y)**2)
                    tx, ty, dist = collider.isInRange(ae, e, 0, True)
                    #print(math.asin(e.visualR/dist))

            e.attackCool = MOVE_TIME
            if e.state == 'attack':
                e.attackIdle += e.attackCool
                # enmey attack delay
                if e.attackIdle >= e.attackDelay:
                    missiles = object_projectile.projectile(
                        e.name, "cannonball", e.x, e.y, e.rad, "enemy", 500,
                        20, 10, "box", 10, 10)
                    missiles.collision = collider.Collision(missiles)
                    projectile.append(missiles)
                    e.attackIdle = 0.0

        # if lo.C_WIDTH-100 < e.x < 100 :
        #     e.x += -math.cos(e.rad)
        #     print("what?x")
        # if lo.C_HIEGHT-100 < e.y < 100:
        #     e.y += -math.sin(e.rad)
        #     print("what?y")

        # if lo.C_WIDTH < e.tx < 0

        for s in structure:
            if s.collision.vector[2][0] <= e.tx<= s.collision.vector[0][0] and\
                    s.collision.vector[2][1] <= e.ty<= s.collision.vector[0][1]:
                e.tx = s.x + random.randint(-1, 1) * s.w
                e.ty = s.y + random.randint(-1, 1) * s.h
                #print(e.tx,e.ty)

        if lo.C_WIDTH < e.x or e.x < 0:
            e.x += -math.cos(e.rad)
        if lo.C_HIEGHT - 50 < e.y or e.y < 0:
            e.y += -math.sin(e.rad)

        # if (-e.ai <= e.x - e.tx <= e.ai) or (-e.ai <= e.y - e.ty <= e.ai):
        #     e.collisionTime += MOVE_TIME
        #     if e.collisionTime > 3.0:
        #         print(e.count, "doesnt", e.x - e.tx, e.y - e.ty)
        #         e.tx += random.randint(-50, 50)
        #         e.ty += random.randint(-50, 50)
        # else:
        #     e.collisionTime = 0.0
        EnemyCheckOverlap()
        e.update()
예제 #5
0
def playerUpdate():
    global player, enemy, test, MOVE_TIME, projectile, playerSoundTime, playerAttackDelay, playerAttackGeneral, playerAttackUlti
    player.update()
    if player.barrel.reload:
        p = lo.loadState.projectile[player.barrel.weapon]
        #print(player.barrel.weapon,p["name"])
        if player.barrel.attack:
            #print("playerUpdate!!!!!!---------------------,",playerAttackDelay)
            player.barrel.attack = False
            if playerAttackDelay == 0.0:
                playerAttackDelay += MOVE_TIME
                if player.barrel.weapon in lo.loadState.attackKind[0]:
                    missiles = object_projectile.projectile(
                        player.name, p["name"], player.barrel.gpx,
                        player.barrel.gpy, player.barrel.rad, "player",
                        p["speed"], p["visualR"], p["damage"], p["colType"],
                        p['width'], p['high'])

                    lo.loadSound.playerSound[p["name"]][0].set_volume(6)
                    lo.loadSound.playerSound[p["name"]][0].repeat_play()

                    missiles.collision = collider.Collision(missiles)
                    playerAttackUlti = False
                    playerAttackGeneral = True
                elif player.barrel.weapon in lo.loadState.attackKind[1]:
                    missiles = object_projectile.frameProjectile(
                        player.name, p["name"], player.barrel.gpx,
                        player.barrel.gpy, player.barrel.rad, "player",
                        p["speed"], p["visualR"], p["damage"], p["colType"],
                        p['width'], p['high'])

                    lo.loadSound.playerSound[p["name"]][0].set_volume(6)
                    lo.loadSound.playerSound[p["name"]][0].repeat_play()

                    missiles.collision = collider.Collision(missiles)
                    playerAttackUlti = True
                    playerAttackGeneral = False
                projectile.append(missiles)
            else:
                if playerAttackGeneral:
                    playerAttackDelay += MOVE_TIME * 80
                elif playerAttackUlti:
                    playerAttackDelay += MOVE_TIME * 30

                if playerAttackDelay >= player.attackCool:
                    playerAttackDelay = 0.0

    if lo.C_WIDTH < player.x or player.x < 0:
        player.body.x += -math.cos(player.rad) * 20
        print("x out!")
    if lo.C_HIEGHT < player.y or player.y < 0:
        player.body.y += -math.sin(player.rad) * 20
        print("y out!")

    if player.body.moved:
        if playerSoundTime == 0.0:
            lo.loadSound.playerSound["move"][1].set_volume(5)
            lo.loadSound.playerSound["move"][1].play(1)
            playerSoundTime += MOVE_TIME * 10
        elif 0 < playerSoundTime <= 4.3:
            playerSoundTime += MOVE_TIME
        else:
            playerSoundTime = 0.0
    else:
        lo.loadSound.playerSound["move"][1].stop()
        playerSoundTime = 0.0