Exemplo n.º 1
0
	void ZombieGame::loadTerrain() {
		auto entry = ZombieEntry(zombieEntry_.getDeepChildEntry("settings map").getString());
		entry = entry.getDeepChildEntry("map objects object");
		while (entry.hasData()) {
			std::string geom(entry.getChildEntry("geom").getString());
			if (entry.isAttributeEqual("type", "building")) {
				auto v = loadPolygon(geom);
				Building* b = buildings_.emplaceBack(v[0], v[1], v[2], v[3], wall_, wall_, wall_);
				engine_.add(b);
				b->setActive(true);
				b->setAwake(true);
			} else if (entry.isAttributeEqual("type", "water")) {
				auto triangle = loadPolygon(geom);
				water_.addTriangle(triangle[0], triangle[1], triangle[2]);
			} else if (entry.isAttributeEqual("type", "grass")) {
				auto triangle = loadPolygon(geom);
				terrain_.addGrass(triangle[0], triangle[1], triangle[2]);
			} else if (entry.isAttributeEqual("type", "tilepoint")) {
				terrain_.addRoad(entry);
			} else if (entry.isAttributeEqual("type", "tree")) {
				engine_.add(new Tree2D(loadPoint(geom), tree_));
			} else if (entry.isAttributeEqual("type", "spawningpoint")) {
				spawningPoints_.push_back(loadPoint(geom));
			} else if (entry.isAttributeEqual("type", "carSpawningpoint")) {
				//carSpawningPoints_.push_back(loadPoint(geom));
			}
			entry = entry.getSibling("object");
		}
	}
Exemplo n.º 2
0
CGMainWindow::CGMainWindow(QWidget *parent, Qt::WindowFlags flags)
    : QMainWindow(parent, flags) {
    resize(604, 614);

    // Create a menu
    QMenu *file = new QMenu("&File", this);
    file->addAction("Load polygon", this, SLOT(loadPolygon()), Qt::CTRL + Qt::Key_L);
    file->addAction("Duplicate active polygon", this, SLOT(duplicatePolygon()), Qt::CTRL + Qt::Key_D);
    file->addAction("Quit", qApp, SLOT(quit()), Qt::CTRL + Qt::Key_Q);
    menuBar()->addMenu(file);

    // Create a nice frame to put around the OpenGL widget
    QFrame *f = new QFrame(this);
    f->setFrameStyle(QFrame::Sunken | QFrame::Panel);
    f->setLineWidth(2);

    // Create our OpenGL widget
    ogl = new CGView(this, f);

    // Put the GL widget inside the frame
    QHBoxLayout *layout = new QHBoxLayout();
    layout->addWidget(ogl);
    layout->setMargin(0);
    f->setLayout(layout);

    setCentralWidget(f);

    statusBar()->showMessage("Ready", 1000);
}