void MainWindow::resizeEvent(QResizeEvent *) { Ui::view->scene()->setSceneRect(rect()); resizeConsole(); resizeScriptEdit(); }
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(); }
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; }
void Game::updateUser() { user.setScore(score); resizeConsole(); usermenu(screen,user); }