本文整理汇总了C++中MainMenu::drawScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ MainMenu::drawScreen方法的具体用法?C++ MainMenu::drawScreen怎么用?C++ MainMenu::drawScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainMenu
的用法示例。
在下文中一共展示了MainMenu::drawScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void) {
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
sf::RenderWindow window(sf::VideoMode (600,400), "ComboPuzzle");
window.setFramerateLimit(150);
sf::RenderStates state;
sf:: Color lightblue(230,230,250,0);
TimedResourceHolder timed_resources;
sf::FloatRect reset_bounds = timed_resources.reset_button.getGlobalBounds();
sf::FloatRect menu_bounds = timed_resources.menu_button.getGlobalBounds();
sf::Clock clock;
sf:: Time time;
Blocktree mainTree;
MainMenu mainmenu;
while (window.isOpen()) //Main Loop, while the game is running this loop is occuring
{
sf::Event event;
while(mainmenu.gamestatus != 1 && window.isOpen()){ //This loop is the main menu loop. Mainmenu.gamestatus represents what gets rendered.
while(window.pollEvent(event)){ //This sub-loop only occurs when gamestatus != 1, i.e. we haven't clicked start.
if (event.type == sf::Event::Closed )
window.close();
if (event.type == sf::Event::MouseButtonPressed)
mainmenu.clickOccur(window);
}
window.clear(lightblue);
mainmenu.drawScreen(window);
mainTree.drop_clock.restart();
mainTree.timerClock.restart();
window.display();
}
// everything below is timed puzzle game
time = clock.restart();
timed_resources.changeScore(mainTree.score);
while(window.pollEvent(event)) //checks to see if any event has occured. various functions are executed depending on the event below.
{
if (event.type == sf::Event::Closed )
window.close();
if(event.type == sf::Event::MouseButtonPressed && mainTree.is_game_over() != true)
if(sf::Keyboard::isKeyPressed(sf::Keyboard::R) || sf::Keyboard::isKeyPressed(sf::Keyboard::C)){ //executes clickOccur_clear which checks the rows/columns and erases them.
if(mainTree.clickOccur_clear(window,reset_bounds, menu_bounds, mainmenu)){
timed_resources.changeComboUpdate(mainTree.combo_count-1);
timed_resources.changeScoreUpdate(mainTree.last_score);
}
}
else {
if(sf::Mouse::isButtonPressed(sf::Mouse::Left)){
int id_to_swap = mainTree.clickOccur_swap(window,reset_bounds, menu_bounds, mainmenu); // this branch is for swapping.
int id_to_swap2;
while (sf::Mouse::isButtonPressed(sf::Mouse::Left)){
time = clock.restart();
timed_resources.changeScore(mainTree.score);
timed_resources.changeDropTime(mainTree.updateGame_blocks(time)); // a compact version of the larger loop with rendering and updating
window.clear(lightblue); // occurs when the mouse is held down.
mainTree.drawTree(window, state);
timed_resources.drawAll(window,state,mainTree);
id_to_swap2 = mainTree.clickOccur_swap(window,reset_bounds, menu_bounds, mainmenu);
if (mainTree.is_game_over() == true)
goto ifGameEnds;
if(id_to_swap == -2 || id_to_swap2 == -2){
clock.restart();
}
else if (id_to_swap >-1 && id_to_swap2 >-1)
mainTree.draw_select(id_to_swap,id_to_swap2,window,state); // the blocks that are being clicked on render their selected sprites
timed_resources.changeComboUpdate(mainTree.combo_count-1);
window.display();
if (mainmenu.gamestatus == 0) break;
}
if(mainTree.swap_colours(id_to_swap,id_to_swap2) == 0) //colour swap occurs once the mouse button has been let go of
timed_resources.gamestatus_changeString("Invalid Swap!");
else timed_resources.gamestatus_changeString("");
timed_resources.changeComboUpdate(mainTree.combo_count-1);
}
}
if (event.type == sf::Event::MouseButtonPressed && mainTree.is_game_over() == true){
if(mainTree.gameover_reset(window,reset_bounds,menu_bounds,mainmenu));
timed_resources.gamestatus_changeString("");
}
}
ifGameEnds:
//.........这里部分代码省略.........