bool MainClass::update()
{
	if (m_isHelpOpened && (
		Engine::instance().getJoystickMgr().isPressed(JoystickManager::PLAYER_ONE, JoystickManager::BUTTON_X) || 
		Engine::instance().getJoystickMgr().isPressed(JoystickManager::PLAYER_ONE, JoystickManager::BUTTON_START) || 
		Engine::instance().getJoystickMgr().isPressed(JoystickManager::PLAYER_TWO, JoystickManager::BUTTON_X) ||
		Engine::instance().getJoystickMgr().isPressed(JoystickManager::PLAYER_TWO, JoystickManager::BUTTON_START)))
	{
		m_isHelpOpened = false;
	}

	iterateList(m_clouds, Cloud*)
	{
		(*it)->manage();
	}

	if (!m_burning->isGameOver() && !m_isHelpOpened)
	{
		m_chara->manage(m_collisionImage, m_waterSystem);
		
		m_cannon->manage(m_swarm, *m_engineSystem, m_burning->hasCannonDamage());
	
		m_burning->manage(m_cannon->getCollisionPos());
		
		m_engineSystem->manage(m_burning);

		std::list<WaterDrop*>& waterDrops = m_waterSystem->manage();
		iterateList(waterDrops, WaterDrop*)
		{
			m_burning->checkCollisions(*it);
		}
Example #2
0
void Widget::drawWidget(QPainter &qp) {

    QString num[] = { "75", "150", "225", "300", "375", "450",
                      "525", "600", "675" };

    int asize = sizeof(num)/sizeof(num[1]);

    QColor redColor(255, 175, 175);
    QColor yellowColor(255, 255, 184);

    int width = size().width();

    Burning *burn = (Burning *) m_parent;
    int cur_width = burn->getCurrentWidth();

    int step = (int) qRound((double)width / DIVISIONS);
    int till = (int) ((width / MAX_CAPACITY) * cur_width);
    int full = (int) ((width / MAX_CAPACITY) * FULL_CAPACITY);

    if (cur_width >= FULL_CAPACITY) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, full, 30);
        qp.setPen(redColor);
        qp.setBrush(redColor);
        qp.drawRect(full, 0, till-full, PANEL_HEIGHT);

    } else if (till > 0) {

        qp.setPen(yellowColor);
        qp.setBrush(yellowColor);
        qp.drawRect(0, 0, till, PANEL_HEIGHT);
    }

    QColor grayColor(90, 80, 60);
    qp.setPen(grayColor);

    for (int i=1; i <=asize; i++) {

        qp.drawLine(i*step, 0, i*step, LINE_WIDTH);
        QFont newFont = font();
        newFont.setPointSize(7);
        setFont(newFont);

        QFontMetrics metrics(font());

        int w = metrics.width(num[i-1]);
        qp.drawText(i*step-w/2, DISTANCE, num[i-1]);
    }
}
Example #3
0
void Widget::paintEvent(QPaintEvent *event)
{
  QPainter painter(this);
  painter.setPen(QColor("#d4d4d4"));

  int width = size().width();

  Burning *burn = (Burning*) m_parent;
  int cur_width = burn->getCurrentWidth();

  int step = (int) qRound(width/10.0);

  int till = (int) ((width / 750.0) * cur_width);
  int full = (int) ((width / 750.0) * 700 );

  if (cur_width >= 700) {
    painter.setPen(QColor(255,255,184));
    painter.setBrush(QColor(255,255,184));
    painter.drawRect(0,0,full,30);
    painter.setPen(QColor(255, 175, 175));
    painter.setBrush(QColor(255, 175, 175));
    painter.drawRect(full, 0, till-full, 30);
  } else {
    painter.setPen(QColor(255,255,184));
    painter.setBrush(QColor(255,255,184));
    painter.drawRect(0,0,till,30);
  }

  painter.setPen(QColor(90, 80, 60));
  for(int i=1; i <= asize; i++) {
    painter.drawLine(i*step, 0, i*step, 6);
    QFont newFont = font();
    newFont.setPointSize(7);
    setFont(newFont);
    
    QFontMetrics metrics(font());
    int w = metrics.width(num[i-1]);
    painter.drawText(i*step - w/2, 19, num[i-1]);
  }

  QFrame::paintEvent(event);
}