Esempio n. 1
0
void Enemy::updateEnemy(float delta)
{
	if (getFaceDir() == F_RIGHT) {
		setFlippedX(true);
	}
	else {
		setFlippedX(false);
	}
	updatePeople(delta);
	onDieEnemy();
	updateFireBullet();
}
/**
 * @brief Adds a person to the database.
 * Should not be called directly.
 *
 * @param People
 * @return bool
 */
bool DatabaseManager::insertNewPeople(People &people)
{
    QSqlQuery l_query(m_db);
    // If a people with the same name exist, we update it
    // else we insert
    if(existPeople(people.name())) {
        Macaw::DEBUG("[DatabaseManager.insertNewPeople] Name already known");
        People l_peopleToUpdate = getOnePeopleByName(people.name());
        people.setId(l_peopleToUpdate.id());
        if(!updatePeople(people)) {

            return false;
        }
    } else {
        l_query.prepare("INSERT INTO people ("
                                                "name, "
                                                "birthday, "
                                                "biography, "
                                                "imported, "
                                                "id_tmdb "
                                            ") VALUES ("
                                                ":name, "
                                                ":birthday, "
                                                ":biography, "
                                                ":imported, "
                                                ":id_tmdb "
                                            ")"
                        );
        l_query.bindValue(":name", people.name());
        l_query.bindValue(":birthday", people.birthday().toString(DATE_FORMAT));
        l_query.bindValue(":biography", people.biography());
        l_query.bindValue(":imported", people.isImported());
        l_query.bindValue(":id_tmdb", people.tmdbId());

        if (!l_query.exec()) {
            Macaw::DEBUG("In insertNewPeople():");
            Macaw::DEBUG(l_query.lastError().text());

            return false;
        }
        people.setId(l_query.lastInsertId().toInt());
    }

    return true;
}
Esempio n. 3
0
int SPQR_Game()
{
	//initializeAllObjects();

	int randomizer = 0;                    //Used for random timing of events

   inGame = 1;
	//The main game loop
	while (inGame)
    {

/*
	All timers use the format:

	if (timerVar less than 'X' and not the same as last time)
	{
		do_something;
	}
	else if (more than 'X')
	{
		do_something_else;
		reset timerVar;
	}

*/

			//Timer for updating money
			if (time(0) % 3 == 0 && moneyNotDone)//excecute every 3 seconds
			{
				updateMoney();
				moneyNotDone = 0;
			}
			else if (time(0) % 3 != 0)
			{
            moneyNotDone = 1;
			}

         /*Counter for playing ambient sounds, and updating resources     60 BPM*/
         if (economyCounter != economyCounterCheck)
			{
            checkThresholds();
            updateResources();
				calculatePopulation();
				if (!(economyCounter % 5)) // every 5 cycles
				{
					updateHousing();
				}
            economyCounterCheck = economyCounter;
				//playAmbientSound();
				if (!(randomizer = rand() % 2))
				{
					play_sample(ambientSound[rand() % NUMABIENTSOUNDS], 255, 127, 1000, 0);
				}
			}

			/*Counter for updating atributes of people        4 BPS*/
          if (updateCounter < 100000 && updateCounterCheck != updateCounter)
          {
              updatePeople();
					sortPeople();
              updateCounterCheck = updateCounter;
          }
          else
          {
              updateCounter = 0;
          }

			/*Counter for animation of people                 8 BPS*/
          if (animateCounter < 100000 && animateCounterCheck != animateCounter)
          {
              animatePeople();
					movePeople();
					sortPeople();
					calculatePercentages();
              animateCounterCheck = animateCounter;
          }
          else
          {
              animateCounter = 0;
          }

			/*Main logic vs. visuals loop                      60 BPS*/
			if (speedCounterCheck == speedCounter)
			{
			}
			else if (speedCounter > 1)
			{
              speedCounter = 0;
              gameVisuals();
			}
         else if (speedCounterCheck != speedCounter)
         {
              getInput();
              speedCounterCheck = speedCounter;
         }
    }
	return 0;
}