Exemplo n.º 1
0
void Wallbreaker::update(float frametime)
{
	if (m_status == PLAYING || m_status == READY)
	{
		Effect::update(frametime);

		// Update player paddle and make sure it remains inside bounds
		m_paddle.onUpdate(frametime);
		if (m_paddle.getX() < 0)
			m_paddle.setX(0);
		else if (m_paddle.getX() + m_paddle.getWidth() > m_width)
			m_paddle.setX(m_width - m_paddle.getWidth());

		if (m_status == PLAYING)
		{
			updateEntities(frametime);
		}
		else
		{
			Entity* ball = m_entities.front();
			// Keep the ball centered on the player pad
			ball->setPosition(m_paddle.getX() + (m_paddle.getWidth() - ball->getWidth()) / 2,
				              m_height - m_paddle.getHeight() - ball->getHeight());
		}
		m_particles.update(frametime);
	}
	updateLevelTexture();
}
Exemplo n.º 2
0
void Behavior::update(const sf::Time &deltaTime) {
    // Add entities to the active list
    while (!mAdded.empty()) {
        if (mAdded.front().expired()) {
            mAdded.pop();
            continue;
        }
        
        mActive.insert(mAdded.front());
        mAdded.pop();
    }
    
    // Remove entities from the active list
    while (!mRemoved.empty()) {
        EntityGroup::iterator search = mActive.find(mRemoved.front());
        if (search != mActive.end()) {
            mActive.erase(search);
        }
        mRemoved.pop();
    }
    
    mDelta = deltaTime;
    
    if (mIsActive) {
        updateEntities(mActive);
    }
}
void EntityManager::update( float deltaTime  )
{
    // flush the notification queue first as update registrations can occure during notifications
    flushNotificationQueue();

    // update internal entity lists and queues
    updateEntityLists();

    // now update all entities
    updateEntities( deltaTime );
}
Exemplo n.º 4
0
void
updatePlayState(PlayState *playState, GameContext *gameContext, UserInput *userInput,
                GameMemory *gameMemory) {

    updateScrollingBackground(playState->scrollingBackground, gameContext);

    updateCameraPosition(playState, gameContext);

    updateEntities(playState, &playState->entityList, gameContext, userInput, gameMemory);

}
	void animate(){
		frameCount++;
		updateEntities(wEntities);
		updateEntities(wWalls);
		updateEntities(wSoftEntities);

		checkCollisionsSelf(wEntities);
		checkCollisions(wEntities, wWalls);
		checkCollisions(wEntities, wSoftEntities);
		checkCollisions(wWalls, wSoftEntities);

		//update everything in the level that needs to be updated
		wScenes[currentLevel]->update();
		if(wScenes[currentLevel]->levelEnd()){

		}

		//Update the mouse flags
		MOUSE_EDGE_LEFT = MOUSE_EDGE_RIGHT = false;
	}
Exemplo n.º 6
0
void Layer::update(const int &delta)
{
    if ((m_updateInterval && m_updateTime.elapsed() >= m_updateInterval)
            || !m_updateInterval) {
        m_updateTime.restart();
        if (m_behavior) {
            m_behavior->setDelta(delta);
            m_behavior->setTarget(this);
            m_behavior->update(delta);
        }
    }

    updateEntities(delta);
}
Exemplo n.º 7
0
int TEST_updateEntities()
{
  cell grid[H][W];
  initGrid(grid);
  newBulb(grid,1,1);
  assert(grid[8][1].background->type==OFFSWITCH);
  updateEntities(grid);
  if(grid[8][1].background->type==ONSWITCH){
    printf("%25s %s\n",__func__, FAIL );
    return ERROR;
  }
  else{
    printf("%25s %s\n",__func__, PASS );
    return SUCCESS;
  }


}
Exemplo n.º 8
0
void updateAllEntities()
{
  int i;
  int entsUsed;
  int numberofEnts;

  numberofEnts=numents+10;
  entsUsed = 0;
  for (i = 0 ;i < MAXENTITIES  ;i++)
  {
    if(entsUsed >= numberofEnts) break;
    if (EntityList[i].used != 0)
    {
      entsUsed++;
      updateEntities(&EntityList[i]);
    }
  }
  entsUsed = 0;
  for (i = 0 ;i < MAXENTITIES  ;i++)
  {
    if(entsUsed >= numberofEnts) break;
    if (EntityList[i].used != 0)
    {
      entsUsed++;
      thinkEntities(&EntityList[i]);
    }
  }
  entsUsed = 0;
  for (i = 0 ;i < MAXENTITIES  ;i++)
  {
    if(entsUsed >= numberofEnts) break;
    if (EntityList[i].used != 0)
    {
      entsUsed++;
      touchEntities(&EntityList[i]);
    }
  }

}
Exemplo n.º 9
0
	void EntityManager::update(float deltaTime, sf::RenderWindow &window, int playerId)
	{
		updateEntities(deltaTime, window, playerId);
		removeEntities();
	}
Exemplo n.º 10
0
int ClientNetwork::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: packetReceived(); break;
        case 1: packetCorrupted(); break;
        case 2: pingUpdated((*reinterpret_cast< quint32(*)>(_a[1]))); break;
        case 3: chatReceived((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[4]))); break;
        case 4: serverInformationsChanged((*reinterpret_cast< ServerInformations(*)>(_a[1]))); break;
        case 5: clientIDChanged((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 6: nicknameChanged((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 7: error((*reinterpret_cast< ENUM_TYPE(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 8: clientVoted((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< CLID(*)>(_a[2]))); break;
        case 9: newGameMaster((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 10: serverName((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 11: motdChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 12: gameLaunched(); break;
        case 13: narrationChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 14: mapChanged((*reinterpret_cast< MapPtr(*)>(_a[1]))); break;
        case 15: mapFlare((*reinterpret_cast< QPoint(*)>(_a[1])),(*reinterpret_cast< CLID(*)>(_a[2]))); break;
        case 16: scriptToGMMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 17: scriptToOwnerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 18: scriptActionMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 19: scriptToPlayerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 20: scriptMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 21: scriptError((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 22: updateEntities((*reinterpret_cast< const QList<EntityInformations>(*)>(_a[1]))); break;
        case 23: updateEntity((*reinterpret_cast< const EntityInformations(*)>(_a[1]))); break;
        case 24: entityDeleted((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 25: scriptReceived((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 26: ressourcesUpdated((*reinterpret_cast< const QMap<QString,RSID>(*)>(_a[1]))); break;
        case 27: connectionEtablished(); break;
        case 28: connectionLost(); break;
        case 29: diceRolled((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2])),(*reinterpret_cast< quint16(*)>(_a[3]))); break;
        case 30: sanctionned((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 31: clientJoined((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 32: clientLeft((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 33: playSound((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 34: syncLibs((*reinterpret_cast< QList<SoundLibInformations>(*)>(_a[1]))); break;
        case 35: syncLanguagesList((*reinterpret_cast< QList<QPair<QString,QString> >(*)>(_a[1]))); break;
        case 36: syncDictionariesList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 37: syncScriptList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 38: updateCharacterList((*reinterpret_cast< const QStringList(*)>(_a[1]))); break;
        case 39: send((*reinterpret_cast< Packet*(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 40: send((*reinterpret_cast< Packet*(*)>(_a[1]))); break;
        case 41: send((*reinterpret_cast< Packet(*)>(_a[1]))); break;
        case 42: send((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const QByteArray(*)>(_a[2]))); break;
        case 43: ping(); break;
        case 44: { qint32 _r = getPing();
            if (_a[0]) *reinterpret_cast< qint32*>(_a[0]) = _r; }  break;
        case 45: { QString _r = serverIP();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 46: { quint16 _r = serverPort();
            if (_a[0]) *reinterpret_cast< quint16*>(_a[0]) = _r; }  break;
        case 47: flush(); break;
        case 48: connection(); break;
        case 49: disconnection(); break;
        case 50: { bool _r = setServer((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 51: connected(); break;
        case 52: disconnected(); break;
        case 53: dataReceived(); break;
        case 54: socketError((*reinterpret_cast< QAbstractSocket::SocketError(*)>(_a[1]))); break;
        case 55: operatePacket((*reinterpret_cast< Packet*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 56;
    }
    return _id;
}