当前位置: 首页>>代码示例>>C++>>正文


C++ Human类代码示例

本文整理汇总了C++中Human的典型用法代码示例。如果您正苦于以下问题:C++ Human类的具体用法?C++ Human怎么用?C++ Human使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Human类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onPlayersData

void Game::onPlayersData(sf::Packet & packet)
{
	std::cout << "players data received!\n";
	Entity::Type myType;
	packet >> myType;


	if (myType == Entity::Type::Zombie)
	{
		Entity::ID myID;
		packet >> myID;
		Zombie * me = mGameWorld.createEntity<Zombie>(myID, myType);
		mGameWorld.setPlayerEntity(me->getID());
		mPlayer.setEntity(me);


		sf::Int32 humanCount;
		packet >> humanCount;
		std::cout << "You are the zombie! human count: " << humanCount << std::endl;


		for (sf::Int32 i = 0; i < humanCount; ++i)
		{
			Entity::ID id;
			packet >> id;
			Human * h = mGameWorld.createEntity<Human>(id, Entity::Type::Human);
			mGameWorld.addEntity(h->getID());
		}
	}
开发者ID:kiwon0905,项目名称:PT,代码行数:29,代码来源:ClientGame.cpp

示例2: PlayerMove

/*******************************************************************************************************
* PALYER MOVE - checks user input and sets thier heading
*******************************************************************************************************/
int PlayerMove(Human & human, StringOO & move, std::vector<int> attachedLoc)
{
	// attached locations vector = { N, S , E, W }
	int newLocation = 0;
	StringOO moveTo = move.StringLowercase();
	// set the new location variable to the corresponding room number in the attachedLoc vector
	if (moveTo.StringCompare("move north"))
	{
		newLocation = attachedLoc[0];
		human.SetHeading(0);
	}
	else if (moveTo.StringCompare("move south"))
	{
		newLocation = attachedLoc[1];
		human.SetHeading(1);
	}
	else if (moveTo.StringCompare("move east"))
	{
		newLocation = attachedLoc[2];
		human.SetHeading(2);
	}
	else if (moveTo.StringCompare("move west"))
	{
		newLocation = attachedLoc[3];
		human.SetHeading(3);
	}
	else
	{
		newLocation = -1;
	}
	return newLocation;
}
开发者ID:borgosity,项目名称:AIE-term-1,代码行数:35,代码来源:GameFunctions.cpp

示例3: main

int main()
{
	Human	bob;

	std::cout << bob.identify() << std::endl;
	std::cout << bob.getBrain().identify() << std::endl;
}
开发者ID:bensisko69,项目名称:projet_42,代码行数:7,代码来源:main.cpp

示例4: humanGameStart

void Player::humanGameStart(Human& h)
{
	cout << " The player game is setting " << endl;

	h.humanSettingGame();
	h.humanDisplayGame();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例5: id

void ZombieObserver::updateAgent(AgentPackage package){
  repast::AgentId id(package.id, package.proc, package.type);
  if (id.agentType() == humanType) {
    Human * human = who<Human> (id);
    human->set(package.infected, package.infectionTime);
  }
}
开发者ID:joaotrindade,项目名称:hpc-project,代码行数:7,代码来源:ZombieObserver.cpp

示例6: throwError

void CartWheel3D::addHuman(const string& name, const std::string& characterFile, const std::string& controllerFile, const std::string& actionFile,
        const Math::Point3d& pos, double heading) {
    bool foundMatch = (_humans.find(name) != _humans.end());
    if (foundMatch) {
        ostringstream osError;
        osError << name << " already exists!";
        throwError(osError.str().c_str());
    }

    string sFile = _path + characterFile;
    _world->loadRBsFromFile(sFile.c_str(), _path.c_str(), name.c_str());
    Character* ch = new Character(_world->getAF(_world->getAFCount() - 1));
//    printf("AF: %s\n", _world->getAF(_world->getAFCount() - 1)->getName());
    ArticulatedRigidBody* body = ch->getArticulatedRigidBody(4);
    printf("Trying to get a Body\n");
    if (body==NULL)
        printf("Body not found\n");
    else {
        printf("Body found!!!\n");
////        body->addMeshObj("data/models/bipv3/head.obj", Vector3d(0,0,0), Vector3d(0.5,2,0.5));
//        body->replaceMeshObj("data/models/box3.obj");
//        body->getMesh(0)->scale(Vector3d(0.06,0.06,0.06));
//        body->getMesh(0)->computeNormals();
//        body->setColour(1,0,0,1);
//        body->setMass(-10);
    }

    CompositeController* con = new CompositeController(ch, _oracle, controllerFile.c_str());
    ActionCollectionPolicy* policy = new ActionCollectionPolicy(con);
    policy->loadActionsFromFile(actionFile.c_str());

    // Create a new human
    Human* human = new Human(name, ch, con, policy);
    // Initialize
    human->init();

    human->setHeading(heading);
    human->setPosition(pos);

    ch->setHeading(heading);

    _humans[name] = human;
    ch->getState(&_hStates[name]);
//    doBehavior("Standing", name, NULL);
    setController(name, 0);
    
    
//    printf("\n\nJoints:\n");
//    for(int i=0; i<ch->getJointCount(); i++) {
//        Point3d p1 = ch->getJoint(i)->getChildJointPosition();
//        Point3d p2 = ch->getJoint(i)->getParentJointPosition();
//        printf("Joint: %s, Parent-Joint: %s, Pos: (%f, %f, %f)\n", ch->getJoint(i)->getName(), ch->getJoint(i)->getParent()->getName(), p2.x, p2.y, p2.z);
//        printf("Joint: %s, Child-Joint: %s, Pos: (%f, %f, %f)\n\n", ch->getJoint(i)->getName(), ch->getJoint(i)->getChild()->getName(), p1.x, p1.y, p1.z);
//    }
    printf("\n\n\nArticulated Rigid Bodies:\n");
    for(int i=0; i<ch->getArticulatedRigidBodyCount(); i++) {
        Vector3d p = ch->getArticulatedRigidBody(i)->getCMPosition();
        printf("ARB: %s, Pos: (%f, %f, %f)\n", ch->getArticulatedRigidBody(i)->getName(), p.x, p.y, p.z);
    }
}
开发者ID:ninod2014,项目名称:ua-cartwheel,代码行数:60,代码来源:CartWheel3D.cpp

示例7: main

int main() {
    Human *mark = new Human(5);
    std::cout << "mark's age is " << mark->getAge() << std::endl;
    Human *mark2 = (Human*)mark->clone();
    std::cout << "mark2's age is " << mark2->getAge() << std::endl;
    return 0;
}
开发者ID:mjaimin,项目名称:DesignPatterns,代码行数:7,代码来源:Prototype.cpp

示例8: main

int main()
{
#if 0
    //9.1.2
    double Pi = 3.1415; // a double declared as a local variable(on stack)
    Human Tom; // An object of class Human declared as a local variable
    int * pNumber = new int; // an integer allocated dynamically on free store
    delete pNumber; // de-allocating the memory
    Human * pAnotherHuman = new Human(); // dynamically allocated Huaman
    delete pAnotherHuman; // de-allocating memory allocated for a Human
#elif 1
    // 9.1.3
    Human Tom; // an instance of Human
    Tom.DateOfBirth = "1970";
    Tom.IntroduceSelf();

    Human * pTom = new Human();
    pTom->DateOfBirth = "1970";
    (*pTom).IntroduceSelf();
    pTom->IntroduceSelf();
    delete pTom;
#else
    // 9.1.4
    Human Tom;
    Human *pTom = &Tom;
    pTom->DateOfBirth = "1970";
    pTom->IntroduceSelf();
#endif
    return 0;
}
开发者ID:aemonair,项目名称:Learning_About_C,代码行数:30,代码来源:_9.1.cpp

示例9: Human

/*
  Gets data from a TrackedPersons msg in the human map. This msg contains a list of agens with
  their positions and orientations.
 */
void GroupHumanReader::groupTrackCallback(const spencer_tracking_msgs::TrackedGroups::ConstPtr& msg) {
    tf::StampedTransform transform;
    ros::Time now = ros::Time::now();
    std::stringstream humId;

    try {
        std::string frame;
        frame = msg->header.frame_id;

        //transform from the groupTrack frame to map
        listener_.waitForTransform("/map", frame,
                msg->header.stamp, ros::Duration(3.0));
        listener_.lookupTransform("/map", frame,
                msg->header.stamp, transform);

        //for every group present in the tracking message
        for (int i = 0; i < msg->groups.size(); i++) {
            spencer_tracking_msgs::TrackedGroup group = msg->groups[i];
            humId << " group" << group.group_id;
            //create a new human with the same id as the message
            Human* curHuman = new Human(humId.str());

            //get the pose of the agent in the groupTrack frame and transform it to the map frame
            geometry_msgs::PoseStamped groupTrackPose, mapPose;
            //geometry_msgs::PoseStamped optitrackPose, mapPose;

            groupTrackPose.pose.position = group.centerOfGravity.pose.position;
            groupTrackPose.pose.orientation = group.centerOfGravity.pose.orientation;
            groupTrackPose.header.stamp = msg->header.stamp;
            groupTrackPose.header.frame_id = frame;
            listener_.transformPose("/map", groupTrackPose, mapPose);

            //set human position
            bg::model::point<double, 3, bg::cs::cartesian> humanPosition;
            humanPosition.set<0>(mapPose.pose.position.x);
            humanPosition.set<1>(mapPose.pose.position.y);
            humanPosition.set<2>(mapPose.pose.position.z);

            //set the human orientation
            std::vector<double> humanOrientation;

            //transform the pose message
            humanOrientation.push_back(0.0);
            humanOrientation.push_back(0.0);
            humanOrientation.push_back(tf::getYaw(mapPose.pose.orientation));

            //put the data in the human
            curHuman->setOrientation(humanOrientation);
            curHuman->setPosition(humanPosition);
            curHuman->setTime(now.toNSec());

            lastConfig_[humId.str()] = curHuman;
        }
    } catch (tf::TransformException ex) {
        ROS_ERROR("%s", ex.what());


    }
}
开发者ID:globox1,项目名称:toaster,代码行数:63,代码来源:GroupHumanReader.cpp

示例10: main

int		main(void)
{
	Human bob;

	std::cout << bob.identify() << std::endl;
	std::cout << bob.getBrain().identify() << std::endl;
	return (0);
}
开发者ID:bsautron,项目名称:PiscineCpp,代码行数:8,代码来源:main.cpp

示例11: main

int main(void)
{
	Human human;
	human.action("melee", "Zaz");
	human.action("ranged", "Thor");
	human.action("intimidating", "Tanguy");
	return (0);
}
开发者ID:tcarmet,项目名称:Piscine_cpp,代码行数:8,代码来源:main.cpp

示例12: testInstanceOf

void testInstanceOf() {
	Human* h = new Human();
	
	testing("InstanceOf");
	assertEqual(h->instanceOf(Human), true, "Same class");
	assertEqual(h->instanceOf(Alive), true, "Inherited");
	assertEqual(h->instanceOf(Base), true, "Base class");
	assertEqual(h->instanceOf(Inventory), false, "Different class");
}
开发者ID:mff-dungeon,项目名称:mff-dungeon,代码行数:9,代码来源:tester.cpp

示例13: main

int main()
{
	Human human1 = Human();
	Human human2 = Human("Athinodoros", "Fafoutis", 26);
	Human maxHuman = Max(human1, human2);
	cout << maxHuman.GetName() << " " << maxHuman.GetSurname();
	system("PAUSE");
    return 0;
}
开发者ID:athinodwros,项目名称:CPPLessons,代码行数:9,代码来源:AthOperatorsAndTemplates.cpp

示例14: main

int main()
{
	Animal Lion;
	Human jisu;
	jisu.move();
	jisu.setAge(22);
	//jisu.parentAge(Lion);
	std::cout << jisu.getAge() << std::endl;
	return 0;
}
开发者ID:JeHwanYoo,项目名称:StudyCpp,代码行数:10,代码来源:Overriding.cpp

示例15: provideContent

void ZombieObserver::provideContent(RelogoAgent* agent, std::vector<AgentPackage>& out) {
	AgentId id = agent->getId();
	AgentPackage content = { id.id(), id.startingRank(), id.agentType(), id.currentRank(), 0, false };
	if (id.agentType() == humanType) {
		Human* human = static_cast<Human*> (agent);
		content.infected = human->infected();
		content.infectionTime = human->infectionTime();
	}
	out.push_back(content);
}
开发者ID:joaotrindade,项目名称:hpc-project,代码行数:10,代码来源:ZombieObserver.cpp


注:本文中的Human类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。