예제 #1
0
파일: Pong.cpp 프로젝트: catlin0123/Pong
/**************************************************************************//**
* @author Paul Blasi
*
* @par Description:
* Updates the state of the CollisionManager and all of the movable objects
*
* @param[in] frame -  the frame count since the last pause/start of the game
*
*****************************************************************************/
void Animate(int frame)
{
    if (!PAUSED)
    {
		if (frame % 10 == 0)
		{
			UpdatePaddles();
		}

        COLLISION_MAN.CheckAndExecuteCollisions();
        LEFT_PLAYER.Update();
        RIGHT_PLAYER.Update();
        BALL.Update();

        glutTimerFunc(30, Animate, frame + 1);
    }

    glutPostRedisplay();
}
예제 #2
0
int main()
{
	window.create(sf::VideoMode(800, 600), "Breakfree");
	window.setVerticalSyncEnabled(true);
	//, sf::Style::Close|sf::Style::Titlebar);
	
	if (!font.loadFromFile("Nirmala.ttf"))
		return EXIT_FAILURE;

	Levels lv;
	Paddle pad;
	InputManager input;
	
	while (window.isOpen())
	{
		switch (level)
		{
		case 0:
			lv.loadLv0();
			break;
		}
		while (playing)
		{
			input.ExecuteEvents(window);
			
			pad.Update();
			

			window.clear(); // ------draw graphics here-------

			sf::Text text("Score: " + std::to_string(score), font, 20);
			text.setPosition(660, 220);
			window.draw(text);

			lv.Draw(window);

			window.draw(pad.sprite);
			window.draw(pad.ball);

			window.display(); // -----------------------
		}
	}

	return 0;
}