예제 #1
0
/*!
 * paste only one object type so handlePaste can control the order of creation
 */
static GraphObjectList handlePasteType(GraphDraw *draw, const Poco::JSON::Array::Ptr &graphObjects, const std::string &type)
{
    GraphObjectList newObjects;
    for (size_t objIndex = 0; objIndex < graphObjects->size(); objIndex++)
    {
        const auto jGraphObj = graphObjects->getObject(objIndex);
        const auto what = jGraphObj->getValue<std::string>("what");
        GraphObject *obj = nullptr;
        if (what != type) continue;
        if (what == "Block") obj = new GraphBlock(draw);
        if (what == "Breaker") obj = new GraphBreaker(draw);
        if (what == "Connection") obj = new GraphConnection(draw);
        if (what == "Widget") obj = new GraphWidget(draw);
        if (obj == nullptr) continue;
        try {obj->deserialize(jGraphObj);}
        catch (const Pothos::NotFoundException &)
        {
            delete obj;
            continue;
        }
        obj->setSelected(true);
        newObjects.push_back(obj);
    }
    return newObjects;
}
예제 #2
0
Vector<GraphRequest *> AppRequests::getRequests(int type) {
    Vector<GraphRequest *> all = getRequests();
    Vector<GraphRequest *> ret;
    for (GraphRequest *r : all) {
        GraphObject *data = r->getDataObject();
        if (data && data->getInt(AppRequestsDataTypeKey) == type) {
            ret.pushBack(r);
        }
    }
    return ret;
}
예제 #3
0
void GameController::displayGamePlay()
{
	glEnable(GL_DEPTH_TEST); // must be done each time before displaying graphics or gets disabled for some reason
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);

	for (int i = NUM_LAYERS - 1; i >= 0; --i)
	{
		std::set<GraphObject*> &graphObjects = GraphObject::getGraphObjects(i);

		for (auto it = graphObjects.begin(); it != graphObjects.end(); it++)
		{
			GraphObject* cur = *it;
			if (cur->isVisible())
			{
				cur->animate();

				double x, y, gx, gy, gz;
				cur->getAnimationLocation(x, y);
				convertToGlutCoords(x, y, gx, gy, gz);

				SpriteManager::Angle angle;
				switch (cur->getDirection())
				{
				case GraphObject::up:
					angle = SpriteManager::face_up;
					break;
				case GraphObject::down:
					angle = SpriteManager::face_down;
					break;
				case GraphObject::left:
					angle = SpriteManager::face_left;
					break;
				case GraphObject::right:
				case GraphObject::none:
				default:
					angle = SpriteManager::face_right;
					break;
				}

				int imageID = cur->getID();

				// the specialized Dirt plotting is an optimization to deal with the background Dirt, which requires a lot of horsepower to plot
				if (imageID == IID_DIRT)
					drawDirt(gx, gy, gz, cur->getSize());
				else
					m_spriteManager.plotSprite(imageID, cur->getAnimationNumber() % m_spriteManager.getNumFrames(imageID), gx, gy, gz, angle, cur->getSize());
			}
		}
	}

	drawScoreAndLives(m_gameStatText);

	glutSwapBuffers();
}
void GameController::displayGamePlay()
{
	glEnable(GL_DEPTH_TEST); // must be done each time before displaying graphics or gets disabled for some reason
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);
	
	std::set<GraphObject*>& graphObjects = GraphObject::getGraphObjects();
	for (std::set<GraphObject*>::iterator it = graphObjects.begin(); it != graphObjects.end(); it++)
	{
		GraphObject* cur = *it;
		if (cur->isVisible())
		{
			cur->animate();
			DrawMapType::const_iterator p = m_drawMap.find(cur->getID());
			if (p != m_drawMap.end())
				(*p->second)(cur);  // draw routine for the current object
		}
	}
	
	drawScoreAndLives(m_gameStatText);
	
	glutSwapBuffers();
}
예제 #5
0
void GameController::displayGamePlay()
{
	glEnable(GL_DEPTH_TEST); // must be done each time before displaying graphics or gets disabled for some reason
	glLoadIdentity();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);
	
	std::set<GraphObject*>& graphObjects = GraphObject::getGraphObjects();
	for (auto it = graphObjects.begin(); it != graphObjects.end(); it++)
	{
		GraphObject* cur = *it;
		if (cur->isVisible())
		{
			cur->animate();

			double x, y, gx, gy, gz;
			cur->getAnimationLocation(x,y);
			convertToGlutCoords(x,y, gx, gy, gz);
			
			SpriteManager::Angles angle;
			switch (cur->getDirection())
			{
				case GraphObject::up:
					angle = SpriteManager::face_up;
					break;
				case GraphObject::down:
					angle = SpriteManager::face_down;
					break;
				case GraphObject::left:
					angle = SpriteManager::face_left;
					break;
				default:
				case GraphObject::right:
				case GraphObject::none:
					angle = SpriteManager::face_right;
					break;
			}

			int imageID = cur->getID();
			int frame = cur->getAnimationNumber() % m_spriteManager.getNumFrames(imageID);
			m_spriteManager.plotSprite(imageID, frame, gx, gy, gz, angle);
		}
	}
	
	drawScoreAndLives(m_gameStatText);
	
	glutSwapBuffers();
}