コード例 #1
0
ファイル: main.cpp プロジェクト: jeanfbrito/box2dgame
int main()
{
    sf::RenderWindow window(sf::VideoMode(WIDTH,HEIGHT,32),"Application");
    window.setFramerateLimit(60);




    Level* level;
    std::vector<std::string> levelfiles;
    levelfiles.push_back("level1.txt");
    levelfiles.push_back("level2.txt");
    levelfiles.push_back("level3.txt");
    int currentLevel = 0;

    level = new Level("level1.txt", &window);

    while(window.isOpen())
    {
        level->update();
        level->handle();
        window.clear(sf::Color(200, 200, 200));
        level->draw();
        window.display();
        if(level->isCompleted())
        {
            delete level;
            level = new Level(levelfiles[++currentLevel], &window);
        }
    }

    return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: stevenlr/Kuiper-Race
static void draw(TransformPipeline& tp)
{
	glEnable(GL_CULL_FACE);
	glCullFace(GL_BACK);
	glFrontFace(GL_CCW);
	glEnable(GL_DEPTH_TEST);
	level.draw(tp);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: alexpogue/SpacePirates
int main(int argc, char ** argv) {
    try {
        // game engine subsystems
        Graphics graphics;
        Level level;
        Time time;

        // load level
        level.setLevel(graphics.load("levels/mountains.bmp"));
        level.setBackground(graphics.load("levels/summer_sky.bmp"));
        auto player1 = Ship();
        auto player2 = Ship(Player::Two);
        player1.setSpawn(Point(50, 250));
        player1.respawn();
        player2.setSpawn(Point(100, 250));
        player2.respawn();
        player1.setImage(graphics.load("ships/ship2.bmp"));
        player2.setImage(graphics.load("ships/ship3.bmp"));
        level.add(player1);
        level.add(player2);

        // rendering loop
        bool quit{ false };
        while(!quit) {
            // calculate framerate
            int frameTime = time.frame();
            int fps = (int)round(1000.f / frameTime);
            Input::Event e;
            do { // handle input
                e = Input::nextInput();
                if(e == Input::QUIT) quit = true;
                level.notify(e);
            } while(e != Input::NO_EVENT);
            graphics.clear();
            level.update(frameTime);
            level.draw(graphics);
            graphics.draw(std::to_string(fps) + " fps", Point(25, graphics.getHeight() - 20.f));
            graphics.present();
        }

    } catch(std::exception e) {
        return EXIT_FAILURE; // error return code
    }
    return EXIT_SUCCESS; // normal program exit
}
コード例 #4
0
ファイル: main.cpp プロジェクト: mentatzoe/CMPS164
void draw(Level lvl)
{
	//Clear color buffer
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//handleCamera();

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(FoV, WINDOW_WIDTH / WINDOW_HEIGHT, 0.1, 100);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Render Camera
	camera.render();

	glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
	glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColour);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColour);
	glLightfv(GL_LIGHT0, GL_SPECULAR, specularColour);

	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_emission);

	glPushMatrix();

	// Draw Level
	lvl.draw();

	glPopMatrix();
    
	// Draw HUD
    drawHUD(lvl);

	SDL_GL_SwapWindow(gWindow);
}
コード例 #5
0
ファイル: World.cpp プロジェクト: Show-vars/MegaGame
void World::drawLevel(float delta) {
    Level* level = this->level;
    level->draw((Screen*) gs);
}