Ejemplo n.º 1
0
bool World::move(WorldObject* const worldObject, const int direction,
				 const int maxPower, int& usedPower)
{
	Position p(0,0);
	WorldObject *object;

	WorldObjectList* list;
	if ( maxPower < usedPower)
		return false;
	p.x = worldObject->p->x;
	p.y = worldObject->p->y;

	Direction::computePosition(&p,direction);
	if (checkPosition(&p) == false ) 
		return false;

	list = world[p.x][p.y];
	list->setToFirst();
	while(object = list->getNext())
		if(!object->conditionalMovement(worldObject,direction,maxPower,usedPower))
			return false;
		if(!moveObject(worldObject,direction))
			return false;
	return true;
}
Ejemplo n.º 2
0
int main() {
  // initialize audio system
  YSE::System().init();

  // load a sound in memory and get a pointer to it
  sound1.create("drone.ogg", NULL, true).play();
  sound2.create("kick.ogg", NULL, true).play();
  reset();

  std::cout << "Initial positions (xyz) are:" << std::endl;
  std::cout << "Listener:  0 / 0 / 0" << std::endl;
  std::cout << "Sound 1 : -5 / 0 / 5" << std::endl;
  std::cout << "Sound 2 :  5 / 0 / 5" << std::endl;
  std::cout << std::endl;
  std::cout << "Press 1 to select sound 1, 2 for sound 2 and 3 for listener." << std::endl;
  std::cout << "Use adws to move selected object (left/right/forward/backward)." << std::endl;
  std::cout << "Press 'r' to reset all objects to the initial positions." << std::endl;
  std::cout << "Press 'e' to exit this program." << std::endl;

  while (true) {
    if (_kbhit()) {
      char ch = _getch();
      switch (ch) {
      case '1': selectedObject = 1; break;
      case '2': selectedObject = 2; break;
      case '3': selectedObject = 3; break;
      case 'a': moveObject(LEFT); break;
      case 'd': moveObject(RIGHT); break;
      case 'w': moveObject(FORWARD); break;
      case 's': moveObject(BACKWARD); break;
      case 'r': reset(); break;
      case 'e': goto exit;
      }
    }

    YSE::System().sleep(100);
    //YSE::Vec pos = sound1.getPosition();
    //pos.x = sin(std::clock() / static_cast<Flt>(CLOCKS_PER_SEC)) * 10;
    //sound1.setPosition(pos);
    YSE::System().update();
  }

exit:
  YSE::System().close();
  return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {
	printf("Testing memcpy/memmove with function pointers for array size ");
	printf("%d", ARRAY_SIZE);
#ifdef NO_TAGS
	printf(" (no tags)");
#endif
#ifdef FAKE_TAGS
	printf(" (fake tags)");
#endif
	printf("...\n");
	Object *p = createEvilObject();
	fillArray(p);
	printf("Calling function on original object...\n");
#ifndef NO_TAGS
	printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn)));
	assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR);
#endif
	p->fn();
	Object *q = copyObject(p);
	checkArray(q);
	printf("Calling function on memcpy'ed copy of object...\n");
#ifndef NO_TAGS
	printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn)));
	assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR);
	printf("Tag on q function pointer is %d\n", (int)load_tag(&(q->fn)));
	assert(load_tag(&(q->fn)) == __RISCV_TAG_CLEAN_FPTR);
#endif
	q->fn();
	Object *r = moveObject(p);
	checkArray(r);
	printf("Calling function on memmove'ed copy of object...\n");
#ifndef NO_TAGS
	printf("Tag on p function pointer is %d\n", (int)load_tag(&(p->fn)));
	assert(load_tag(&(p->fn)) == __RISCV_TAG_CLEAN_FPTR);
	printf("Tag on q function pointer is %d\n", (int)load_tag(&(q->fn)));
	assert(load_tag(&(q->fn)) == __RISCV_TAG_CLEAN_FPTR);
	printf("Tag on r function pointer is %d\n", (int)load_tag(&(r->fn)));
	assert(load_tag(&(r->fn)) == __RISCV_TAG_CLEAN_FPTR);
#endif
	r->fn();
	printf("Success!\n");
	deleteObject(p);
	deleteObject(q);
	deleteObject(r);
	return 0;
}
Ejemplo n.º 4
0
void updateGame() {
    if(msgTime>0) --msgTime;

    player.x += player.xVel;
    player.y += player.yVel;

    if      (player.x>SCREENW-TILEW) player.x = 0;
    else if (player.x<0)             player.x = SCREENW-TILEW;
    else if (player.y>SCREENH-TILEH) player.y = 0;
    else if (player.y<0)             player.y = SCREENH-TILEH;

    if(someObject != NULL) {
        someObject->xVel = 0;
        someObject->yVel = 0;

        if(!someObject->xVel) moveObject(someObject,someObject->direction);

        if(someObject->x<0) someObject->direction = RIGHT;
        else if(someObject->x>SCREENW-TILEW) someObject->direction = LEFT;

        someObject->x += someObject->xVel;
        someObject->y += someObject->yVel;

        if(xCollision(&player, someObject)) {
            player.x -= player.xVel << 1;
            someObject->x -= someObject->xVel;
            message = "hit!";
            msgTime = 50;
        }
        if(yCollision(&player, someObject)) {
            player.y -= player.yVel << 1;
            message = "hit!";
            msgTime = 50;
        }
        if(!yCollision(&player, someObject)) ++player.y;
        if( yCollision(&player, someObject)) --player.y;
    }

    bgX -= 1;
    bgY -= 1;

    if(bgX<=-TILEW) bgX = 0;
    if(bgY<=-TILEH) bgY = 0;
}
Ejemplo n.º 5
0
void LocalBackEnd::consumeSingleEvent(GameEvent* event) {
  switch(event->type) {
    case RawData:
      Debug("Received raw data from server");
      unpackRaws((RawDataEvent*)event);
      break;
    case AreaData:
      Debug("Area data received from server");
      _world.processWorldEvent(event);
      changeArea();
      break;
    case TileData:
      //Debug("Tile data received from server");
      _world.processWorldEvent(event);
      updateMap((TileDataEvent*)event);
      break;
    case ObjectData:
      updateObject((ObjectDataEvent*)event);
      break;
    case CharacterReady:
      Debug("Character is ready");
      changeArea();
      _characterID = ((CharacterReadyEvent*)event)->ID;
      break;
    case CharacterNotReady:
      Debug("Character not ready - " << ((CharacterNotReadyEvent*)event)->reason);
      break;
    case ThingMoved:
      moveObject((ThingMovedEvent*)event);
      break;
    case MoveFailed:
      Debug("Failed to move - " << ((MoveFailedEvent*)event)->reason);
      break;
    default:
      Warn("Unhandled game event type " << event->type);
      break;
  }
}
Ejemplo n.º 6
0
void executeGet(const char *noun)
{
   OBJECT *obj = getVisible("what you want to get", noun);
   if (obj == NULL)
   {
      // already handled by getVisible
   }
   else if (obj == player)
   {
      printf("You should not be doing that to %s.\n", obj->description);
   }
   else if (obj->location == player)
   {
      printf("You already have %s.\n", obj->description);
   }
   else if (obj->location == guard)
   {
      printf("You should ask %s nicely.\n", obj->location->description);
   }
   else
   {
      moveObject(obj, player);
   }
}
Ejemplo n.º 7
0
/*JUEGO*/
void game(){
  u8 atkObj = 0;

  initVariables(1);
  initPlayer(map);
  initNivel();
  initEnemies(map);

   cpct_clearScreen(0);
   drawMap(map);
   while (1){
    if(finish == 1) return;
    //Esperar el retrazado
    cpct_waitVSYNC();

    //Desdibujar personajes
    erases();

    //Dibujar pickups
    if(temp == 10)
        drawPickUps(n.corazon,n.bullet);

    //Dibujar personajes
    draws();

    //Dibujar fatiga
    if(temp == 10){
        if(player.atk < 20) drawFatiga(player.atk,2);
        else if(player.atk > 20) drawFatiga(player.atk,1);
        else drawFatiga(player.atk,0);
    }
    //guardar datos anteriores
    if(temp%2 == 0){
        player.lx = player.x;
        player.ly = player.y;
    }

    if(enemy.life > 0){
        if(temp%2 == 1){
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
        }

       move();
        switch(checkCollisions(player.x, player.y, enemy.x, enemy.y, player.atk)){
          case 1:
            erase(enemy.lx,enemy.ly,0);
            enemy.x = enemy.ox;
            enemy.y = enemy.oy;
            enemy.lx = enemy.x;
            enemy.ly = enemy.y;
            enemy.ox = originse[map-1][4];
            enemy.oy = originse[map-1][5];
            enemy.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
          case 2:
            erase(player.lx,player.ly,0);
            player.x =originsp[map-1][0];
            player.y = originsp[map-1][1];
            player.lx =originsp[map-1][0];
            player.ly = originsp[map-1][1];
            player.life -= 1;
            player.atk = 20;
            enemy.pursue = 0;
            break;
        }
    }
    if(temp > 10)
        temp = 0;
    temp += 1;
    player.latk = player.atk;
      //Comprobar teclado
      cpct_scanKeyboard_f();
      player.sprite = checkKeyboard();
      checkBoundsCollisions(&n.corazon,&n.bullet);

      if(arrow == 1){
        moveObject();
        bound = checkArrowCollisions();
        if(object.dir == 2 || object.dir == 8)
            atkObj = 21;
        else
            atkObj = 22;
       if(enemy.life > 0 && checkCollisions(object.x, object.y, enemy.x, enemy.y, atkObj) == 1 && bound == 0){
         enemy.life -= 1;
         erase(enemy.lx,enemy.ly,0);
         enemy.x = enemy.ox;
         enemy.y = enemy.oy;
         enemy.lx = enemy.x;
         enemy.ly = enemy.y;
         enemy.pursue = 0;
         object.vivo = 0;
         bound = 1;
       }
      }
      
      if(player.life == 0){
        gameOver();
        finish = 1;
      } 
      

   }
}
Ejemplo n.º 8
0
// Game Update function
// ==========================================================
void update() {
	theta += dtheta;

	// Move ship
	int i;
	for (i = 0; i < MAXSHIPS; i++) {
		moveObject(&(ships[i]));
	}

	// Move all laser shots
	int l;
	for (l=0; l < MAXSHOTS; l++) {
		moveObject(LAZORZ+l);
	}

	// // Move missile
	// int mt = 0;
	// // Aquire new target
	// while (!(asteroids[missileTarget].state & ASTEROID_ACTIVE) && mt < MAXASTEROIDS) {
		// missileTarget = (missileTarget+1) % MAXASTEROIDS;
		// mt++;
	// }
	// // Get vector from missile to target
	// vector tt = subVec(&(asteroids[missileTarget].pos), &(missile.pos));
	// tt = normalizeVec(&tt);
	// float angle = angleBetweenVec(&(missile.dir), &tt) - 1.0;
	// if (angle > 0.0001 || angle < -0.0001) {
		// turnObject(&missile, dtheta*missile.turn*angle);
	// }
	// vector acc = scaleVec(&(missile.dir), missile.spd*dtheta);
	// missile.vel = addVec(&(missile.vel), &acc);
	// float spd = lengthVec(&(missile.vel));
	// if (spd > MAXMISSILESPEED) 
		// missile.vel =  scaleVec(&(missile.vel), MAXMISSILESPEED/spd);
	// moveObject(&missile);

	// Move all asteroids
	int a;
	for (a=0; a<MAXASTEROIDS; a++) {
		if (asteroids[a].state & ASTEROID_ACTIVE) moveObject(asteroids+a);
	}

	// Move all ship gibs
	object ship;
	for (i=0; i < MAXSHIPS; i++) {
		ship = ships[i];
		if ((shipGibs+i*ship.size)->state & GIB_ACTIVE) {
			int sb;
			for (sb=0; sb<ship.size; sb++) {
				moveObject(shipGibs+i*ship.size+sb);		
			}
		}
	}
	
	// Move all asteroid gibs
	int aag;
	for (aag=0; aag<MAXASTEROIDS; aag++) {
		int ag;
		for (ag=0; ag<asteroids->size; ag++) {
			if(asteroidGibs[aag][ag].state & GIB_ACTIVE) {
				moveObject(asteroidGibs[aag]+ag);

				// Decrease lifetime by update amount and kill if < 0.0
				asteroidGibs[aag][ag].lifetime -= 
					0.2*dtheta + 0.4*dtheta*cos((float)rand());
				if (asteroidGibs[aag][ag].lifetime < 0.0) {
					asteroidGibs[aag][ag].state -= GIB_ACTIVE;
				}
			}
		}
	}	

	// shoot lasers
	object *shipi;
	for (i = 0; i < MAXSHIPS; i++) {
		shipi = ships+i;
		if (shipi->state & SHIP_SHOOTING && !(shipi->state & (SHIP_DED | SHIP_INACTIVE))) {
			initLazor(LAZORZ+shotIndex, shipi);
			shotIndex = (shotIndex + 1) % MAXSHOTS;
			shipi->state -= SHIP_SHOOTING;
		}
	}

	// // shoot missiles
	// if (ship.state & SHIP_SHOOTING_MISSILE && !(ship.state & SHIP_DED)) {
		// initMissile();
		// missileTarget = rand() % MAXASTEROIDS;
		// ship.state -= SHIP_SHOOTING_MISSILE;
	// }

	// check collisions
	checkCollisions();
}
Ejemplo n.º 9
0
void World::move(zf::Direction direction)
{
    if (player and player->canMove())
    {
        if (player->isGrabbing())
        {
            auto mod = zf::getModifier(direction);
            auto playerTargetPosition = player->position + mod;
            bool canMove = true;
            if (inRange(playerTargetPosition))
            {
                auto grabbed = player->getGrabbedObjects();
                auto destinationObject = getObject(playerTargetPosition);
                if (!destinationObject || std::find(grabbed.begin(), grabbed.end(), destinationObject) != grabbed.end())
                {
                    for (auto object : grabbed)
                    {
                        if (!object->canGrabbed(direction, *player, grabbed))
                        {
                            canMove = false;
                            break;
                        }
                    }
                    if (canMove)
                    {
                        moveObject(*player, player->position + mod);
                        player->objectMoved();
                        for (auto object : grabbed)
                        {
                            moveObject (*object, object->position + mod);
                        }
                        player->doWork(game.balance.Player_MoveCost + grabbed.size() * game.balance.Player_GrabCost);
                    }
                }
            }
        }
        else
        {
            auto mod = zf::getModifier(direction);
            auto targetPosition = player->position + mod;
            if (inRange(targetPosition))
            {
                auto object = getObject(targetPosition);
                auto objectTargetPosition = targetPosition + mod;
                if (!object)
                {
                    moveObject(*player, targetPosition);
                    player->objectMoved();
                    player->doWork(game.balance.Player_MoveCost);
                }
                else if (object->type == WorldObject::ObjectType::FoodObject)
                {
                    player->eat();
                    removeFromGrid(object);
                    removeFromList(object);
                    delete object;
                    moveObject(*player, targetPosition);
                    player->objectMoved();
                }
                else if (inRange(objectTargetPosition))
                {
                    auto objectObstacle = getObject(objectTargetPosition);
                    if (!object->isPushable())
                    {
                    }
                    else if (!objectObstacle)
                    {
                        moveObject(*player, targetPosition);
                        player->objectMoved();
                        moveObject(*object, targetPosition + mod);
                        player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost);
                    }
                    /// cant push, see if we can combine
                    else if (object->type == WorldObject::ObjectType::SandObject && objectObstacle->type == WorldObject::ObjectType::SandObject)
                    {
                        // merge the sand object
                        auto sandSource = static_cast<SandObject*>(object);
                        auto sandTarget = static_cast<SandObject*>(objectObstacle);
                        if (sandSource->count + sandTarget->count <= 4)
                        {
                            // can only merge if their total is < 4
                            sandTarget->count += sandSource->count;
                            // respawn sandSource
                            sandSource->count = 1;
                            removeFromGrid(sandSource);
                            removeFromList(sandSource);
                            moveObject(*player, targetPosition);
                            player->objectMoved();
                            if (spawnSand())
                            {
                                spawnObject(sandSource);
                            }
                            else
                            {
                                delete sandSource;
                            }
                        }
                        player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost);
                    }
                    else if (object->type == WorldObject::ObjectType::SandObject && objectObstacle->type == WorldObject::ObjectType::WaterObject)
                    {
                        auto sandSource = static_cast<SandObject*>(object);
                        auto waterTarget = static_cast<WaterObject*>(objectObstacle);
                        if (waterTarget->flood)
                        {
                            removeFromGrid(waterTarget);
                            removeFromList(waterTarget);
                            waterTarget->flood = false;
                            waterTarget->floodMeter = 0;
                            outputBlocks.push_back(waterTarget);
                            sandSource->count-=1;
                            if (sandSource->count <= 0)
                            {
                                removeFromGrid(sandSource);
                                removeFromList(sandSource);
                                delete sandSource;
                            }
                            else
                            {
                                moveObject(*sandSource, objectTargetPosition);
                            }
                            moveObject(*player, targetPosition);
                            player->objectMoved();
                        }
                        player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost);
                    }
                    else if (object->type == WorldObject::ObjectType::TreeObject && objectObstacle->type == WorldObject::ObjectType::WaterObject)
                    {
                        auto treeSource = static_cast<TreeObject*>(object);
                        auto waterTarget = static_cast<WaterObject*>(objectObstacle);
                        if (treeSource->grow())
                        {
                            removeFromGrid(waterTarget);
                            removeFromList(waterTarget);
                            delete waterTarget;
                            moveObject(*treeSource, objectTargetPosition);
                            moveObject(*player, targetPosition);
                            player->objectMoved();
                        }
                        player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost);
                    }
                    else if (object->type == WorldObject::ObjectType::StoneObject && objectObstacle->type == WorldObject::ObjectType::VolcanoObject)
                    {
                        auto volcanoTarget = static_cast<VolcanoObject*>(objectObstacle);
                        volcanoTarget->blocked = true;
                        removeFromGrid(object);
                        removeFromList(object);
                        delete object;
                        moveObject(*player, targetPosition);
                        player->objectMoved();
                        player->doWork(game.balance.Player_MoveCost + game.balance.Player_PushCost);
                    }
                }
            }
        }
    }
}
Ejemplo n.º 10
0
void executeGive(const char *noun)
{
   moveObject(getPossession(player, "give", noun), actorHere());
}
Ejemplo n.º 11
0
void executeAsk(const char *noun)
{
   moveObject(getPossession(actorHere(), "ask", noun), player);
}
Ejemplo n.º 12
0
void executeDrop(const char *noun)
{
   moveObject(getPossession(player, "drop", noun), player->location);
}
Ejemplo n.º 13
0
/**
    Exécution des éléments
**/
void PlayState::loop(){
    /**
        Gestion des entrées claviers
    */

//    //! Pauser le jeu
//   if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Return))pause();
//
//    //! Control du joueur 1
//    if (sf::Keyboard::IsKeyPressed(sf::Keyboard::M))m_playerOne->Jump();
//    m_playerOne->TurnUp(sf::Keyboard::IsKeyPressed(sf::Keyboard::Up));
//    m_playerOne->Turn(sf::Keyboard::IsKeyPressed(sf::Keyboard::Left),sf::Keyboard::IsKeyPressed(sf::Keyboard::Right));
//    if(sf::Keyboard::IsKeyPressed(sf::Keyboard::N))m_playerOne->Shoot();
//
//
//    //! Control du joueur 2
//    if (sf::Keyboard::IsKeyPressed(sf::Keyboard::G))m_playerTwo->Jump();
//    m_playerTwo->TurnUp(sf::Keyboard::IsKeyPressed(sf::Keyboard::W));
//    m_playerTwo->Turn(sf::Keyboard::IsKeyPressed(sf::Keyboard::A),sf::Keyboard::IsKeyPressed(sf::Keyboard::D));
//    if(sf::Keyboard::IsKeyPressed(sf::Keyboard::F))m_playerTwo->Shoot();

    if(!m_start){
        m_startCoutdown.Reset();
        m_start=true;
    }
    if(m_startCoutdown.GetElapsedTime()>4000){
        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Return))pause();

        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::L))m_playerTwo->Degat(-40);
        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Numpad3))m_playerOne->Jump();
        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::Numpad2))m_playerOne->Shoot();
        m_playerOne->TurnUp(sf::Keyboard::IsKeyPressed(sf::Keyboard::Up));
        m_playerOne->Turn(sf::Keyboard::IsKeyPressed(sf::Keyboard::Left),sf::Keyboard::IsKeyPressed(sf::Keyboard::Right));

        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::G))m_playerTwo->Jump();
        if (sf::Keyboard::IsKeyPressed(sf::Keyboard::F))m_playerTwo->Shoot();
        m_playerTwo->TurnUp(sf::Keyboard::IsKeyPressed(sf::Keyboard::W));
        m_playerTwo->Turn(sf::Keyboard::IsKeyPressed(sf::Keyboard::A),sf::Keyboard::IsKeyPressed(sf::Keyboard::D));
//        const sf::Input &Input =m_gameEngine->m_app.GetInput();
//
//        //! Pauser le jeu
//       if(Input.IsKeyDown(sf::Key::Return))pause();
//
//        //! Control du joueur 1
//        if(Input.IsKeyDown(sf::Key::L))m_playerOne->Degat(-40);
//        if(Input.IsKeyDown(sf::Key::Numpad3))m_playerOne->Jump();
//        if(Input.IsKeyDown(sf::Key::Numpad2))m_playerOne->Shoot();
//        m_playerOne->TurnUp(Input.IsKeyDown(sf::Key::Up));
//        m_playerOne->Turn(Input.IsKeyDown(sf::Key::Left),Input.IsKeyDown(sf::Key::Right));
//
//
//        //! Control du joueur 2
//        if (Input.IsKeyDown(sf::Key::G))m_playerTwo->Jump();
//        m_playerTwo->TurnUp(Input.IsKeyDown(sf::Key::W));
//        m_playerTwo->Turn(Input.IsKeyDown(sf::Key::A),Input.IsKeyDown(sf::Key::D));
//        if(Input.IsKeyDown(sf::Key::F))m_playerTwo->Shoot();
    }
     else{
        if(m_coutdown.GetScale().x>2)m_scaleUp=false;
        if(m_coutdown.GetScale().x<1.2)m_scaleUp=true;

        if(m_scaleUp)m_coutdown.SetScale(m_coutdown.GetScale().x+0.002*m_gameEngine->m_app.GetFrameTime(),m_coutdown.GetScale().x+0.002*m_gameEngine->m_app.GetFrameTime());
        else m_coutdown.SetScale(m_coutdown.GetScale().x-0.002*m_gameEngine->m_app.GetFrameTime(),m_coutdown.GetScale().x-0.002*m_gameEngine->m_app.GetFrameTime());

        if(m_startCoutdown.GetElapsedTime()<=1000){
            m_coutdown.setAnimRow(0);
        }
        else if(m_startCoutdown.GetElapsedTime()<=2000){
            m_coutdown.setAnimRow(1);
        }
        else if(m_startCoutdown.GetElapsedTime()<=3000){
            m_coutdown.setAnimRow(2);
        }
        else{
            m_coutdown.setAnimRow(3);
        }
        m_coutdown.SetOrigin(GameConfig::g_imgManag["coutdown"].img.GetWidth()/2,(GameConfig::g_imgManag["coutdown"].img.GetHeight()/GameConfig::g_imgManag["coutdown"].nbrLine)*(1+m_coutdown.animRow()/2.f));
    }
    /**
        Gestion des personnages et objets
    */

 //! Déplacement du personnage 1
    movePlayer(*m_playerOne);

 //! Déplacement du personnage 2
    movePlayer(*m_playerTwo);
 //! Vérifie les items
    checkItems();

 //! Déplacement des objets
    moveObject();

 //! On vérifie si les personnages sont vivant
    if(m_playerOne->IsDead()){
        m_mapEntity->push_back(new GameAnim(GameConfig::g_imgManag["dead"].img,GameConfig::GameConfig::g_imgManag["dead"].nbrCollum,GameConfig::GameConfig::g_imgManag["dead"].nbrLine));
        m_mapEntity->back()->SetPosition(m_playerOne->GetPosition());
        m_mapEntity->back()->Move(0,9);
        m_mapEntity->back()->setDelay(35);
        m_playerOne->SetPosition(m_map->m_spawnLocationOne);
        m_gameMessage.AddMessage("Player 1 has been kill!");
    }
    if(m_playerTwo->IsDead()){
        m_mapEntity->push_back(new GameAnim(GameConfig::g_imgManag["dead"].img,GameConfig::GameConfig::g_imgManag["dead"].nbrCollum,GameConfig::GameConfig::g_imgManag["dead"].nbrLine));
        m_mapEntity->back()->SetPosition(m_playerTwo->GetPosition());
        m_mapEntity->back()->Move(0,8);
        m_mapEntity->back()->setDelay(35);
        m_mapEntity->back()->setAnimRow(1);
        m_playerTwo->SetPosition(m_map->m_spawnLocationTwo);
        m_gameMessage.AddMessage("Player 2 has been kill!");
    }

//! On vérifie si ils ont encore des vies
    if(m_playerOne->GetVie()<=0){
        m_gameEngine->m_gameState.at(3)->init();
        m_gameEngine->changeState(3);
    }
    if(m_playerTwo->GetVie()<=0){
        m_gameEngine->m_gameState.at(3)->stop();
        m_gameEngine->changeState(3);
    }
}
Ejemplo n.º 14
0
/**
* \ingroup Communication
* Move the Object on Z,Y axis synchronously
*
* \param from Object start position
* \param to Object end position
* \param speed Object speed
**/
void moveObject(const Eigen::Vector3d &from, const Eigen::Vector3d &to, int speed)
{ // speed > 6000 ? speed = 6000 : speed = speed;
   moveObject(to-from, speed);
}