コード例 #1
0
ファイル: Game.cpp プロジェクト: BarronFritz/FlappyBird
Game::Game(float ticks, const std::string& title, unsigned int width, unsigned int height)
        : m_bird(width / 2.f, height / 2.f),
          m_level({0, 0, (float)width, (float)height}),
          m_background({0, 0, (float)width, (float)height}) {
    m_highscore = 0;

    if (!m_font.loadFromFile("assets/marietta-seven.ttf")) {
        printf("Failed to load font\n");
    }
    m_scoreText.setFont(m_font);
    m_scoreText.setPosition(10, 10);
    m_scoreText.setString("Score: 0 / " + std::to_string(m_highscore));

    m_messageText.setFont(m_font);
    m_messageText.setPosition(width / 2.f, height / 2.f);
    m_messageText.setCharacterSize(12U);
    m_messageText.setString("Press Space Bar to Start");
    m_messageText.setOrigin(m_messageText.getGlobalBounds().width / 2.f,
                            m_messageText.getGlobalBounds().height / 2.f);

    m_tick = sf::seconds(1 / ticks);

    sf::VideoMode vMode(width, height);
    m_window.create(vMode, title);

    m_running = false;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: rojanneo/Asteroid_code
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	VideoMode vMode(800,600,32);
	RenderWindow win(vMode, "ASTEROIDS");
	win.SetFramerateLimit(120);
	//win.ShowMouseCursor(false);
	win.UseVerticalSync(false);

	int currentScreen = 0;
	Menu menu;

	Game game;

	Splash splash;
	

	while(currentScreen >= 0)
	{
		if (currentScreen == 0)
		{
			currentScreen = splash.Run(win, vMode);
			
		}
		if(currentScreen == 2)
		{
			currentScreen = menu.Run(win, vMode);
		}

		if(currentScreen == 1)
		{
			currentScreen = game.Run(win, vMode);
		}

	}

	return EXIT_SUCCESS;

	
}