void Player::Attack(bool isTransformed, Sprite* effect, b2Body* effectBody, float chargeCount)
{
	effectBody->SetActive(true);
	
	if (chargeCount < 5.0f)
	{
		if (!isTransformed)
		{
			playerAction(UNATTACK);
		}

		else
		{
			playerAction(TNATTACK);
		}
	}

	else
	{
		if (!isTransformed)
		{
			playerAction(UCATTACK);
		}

		else
		{
			playerAction(TCATTACK);
		}
	}

	effect->setPosition(Vec2(playerPos.x + 90, playerPos.y + 30));
	effect->setScale(0.2f);
}
示例#2
0
void Game::gameLoop() {
  while (_isActive && _vPlayers.size()) {
    _playerTurn = _gameTurn % _vPlayers.size();
    playerAction(*_vPlayers[_playerTurn]);
    _gameTurn++;
  }
}
void Player::Jump(bool isTransformed)
{
	if (!isTransformed)
	{
		playerAction(UJUMP);

		auto jumpUp = MoveBy::create(0.5f, Vec2(0, 50));
		auto jumpDown = jumpUp->reverse();
		jumpAction = Sequence::create(jumpUp, jumpDown, CallFunc::create(CC_CALLBACK_0(Player::playerAction, this, UWALK)), nullptr);
		playerSprite->runAction(jumpAction);
	}

	else
	{
		playerAction(TJUMP);

		auto jumpUp = MoveBy::create(0.5f, Vec2(0, 50));
		auto jumpDown = jumpUp->reverse();
		jumpAction = Sequence::create(jumpUp, jumpDown, CallFunc::create(CC_CALLBACK_0(Player::playerAction, this, TWALK)), nullptr);
		playerSprite->runAction(jumpAction);
	}
}
示例#4
0
文件: match.c 项目: nuskarthik/cs3210
void main(int argc, char *argv[]) {
    //time_t start, end;
    //time(&start);
    int teamPos[2][5][2] = {{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
                            {{128, 64}, {128, 64}, {128, 64}, {128, 64}, {128, 64}}};

    int teamSkill[2][5][3] = {{{2, 6, 7}, {4, 3, 8}, {2, 3, 10}, {3, 6, 6}, {5, 5, 5}},
    			      {{2, 6, 7}, {4, 3, 8}, {2, 3, 10}, {3, 6, 6}, {5, 5, 5}}};

    int rank, numtasks, isPlayer, winnerRank;
    int teamA[5] = {0, 1, 2, 3, 4}, teamB[5] = {5, 6, 7, 8, 9};

    MPI_Init(&argc, &argv);

    MPI_Comm_rank(MPI_COMM_WORLD, &rank);

    isPlayer = rank < 10;
    int round = 1;
    srand(time(NULL) + rank);
    Player player;

    if (isPlayer) {
       int teamId = rank/5;
       int playerNum = rank % 5;
       player.x = teamPos[teamId][playerNum][0];
       player.y = teamPos[teamId][playerNum][1];
       player.speed = teamSkill[teamId][playerNum][0];
       player.dribble = teamSkill[teamId][playerNum][1];
       player.shoot = teamSkill[teamId][playerNum][2];
       playerAction(player, rank);
    } else {
       fieldAction(rank, teamPos, teamSkill);
    }

    MPI_Finalize();
    //time(&end);
    //printf("%lf", difftime(end, start));
}