예제 #1
0
void MainWindow::resizeEvent(QResizeEvent *)
{
    Ui::view->scene()->setSceneRect(rect());

    resizeConsole();
    resizeScriptEdit();
}
예제 #2
0
파일: game.cpp 프로젝트: mdriess/Snake
void Game::playGame()
{
    resizeConsole(x_max+1,y_max+1);//game size
    screen.clear();
    drawBoundary();

    while(!dead)
    {
        displayScore();

        if(!paused)
        {
            snake.clear(screen);
            snake.move();
            snake.draw(screen);

            food.draw(screen);

            Sleep(100-speed);


            if(snake.hit(x_min,x_max,y_min,y_max))
            {
                dead = true;
            }
            else if(snake.getHead().equals(food))
            {
                snake.grow();
                generateFood();
                harder();
            }
        }

        if(kbhit())
        {
            getKeys();
        }

    }
    //endgame();
    updateUser();
}
예제 #3
0
void MainWindow::toggleConsole()
{
    QPropertyAnimation *a = new QPropertyAnimation(Ui::console, "geometry");
    connect(a, SIGNAL(finished()), SLOT(resizeConsole()));
    a->setEasingCurve(QEasingCurve::InOutSine);
    a->setDuration(500);
    a->setStartValue(Ui::console->rect());

    if(consoleVisible)
    {
        a->setEndValue(QRect(0, 0, width(), 0));
        Ui::console->clearFocus();
    }
    else
    {
        a->setEndValue(QRect(0, 0, width(), height()/3));
        Ui::console->setFocus();
    }

    a->start();

    consoleVisible = !consoleVisible;
}
예제 #4
0
파일: game.cpp 프로젝트: mdriess/Snake
void Game::updateUser()
{
    user.setScore(score);
    resizeConsole();
    usermenu(screen,user);
}