1. Homepage
  2. Programming
  3. A5: Qt Simon Game

A5: Qt Simon Game

Engage in a Conversation
QTC++Simon GameUSThe University of Utah

A5: Qt Simon Game

Pairs

This is an optional partner assignment. Use the repo invite and if a pair, add the partner to the team for the repo. If you have a partner, you must work together on the project and not just divide up the work or alternate work times. CourseNana.COM

Using Qt

(https://wiki.qt.io/Install_Qt_5_on_Ubuntu) CourseNana.COM

Refer to the Qt install instructions on Canvas to set up Qt on your machine. If you open Qt Creator and start a new project, choose a Widget app. This gives a baseline of functionality. You will need to add to the app using a mixture of the WYSIWYG Designer and custom C++ code. CourseNana.COM

Goals

You are to make a simple Simon game. CourseNana.COM

In our version, there will be just two colors/buttons. The basic gameplay is that the program shows us a sequence of buttons that light up, then our job is to repeat the sequence by pushing the buttons. If you successfully repeat the sequence, the computer plays the same sequence but adds a new value to the end. If you do not repeat it properly, the game is over. CourseNana.COM

Model-View Structure

In your application, the game logic should be pulled into its own class, the interface should be the MainWindow class (you can rename it to something else) and the view and the model should only communicate through signals and slots. CourseNana.COM

More specifically, you can construct the view with a constructor that uses a model parameter and make connections there. The view class should not store or directly reference a model object (except through whatever magic happens in a connect function) and the model class should not store or directly reference a view. CourseNana.COM

The model class should still be in the Qt hierarchy in order to use the signal/slot mechanism. Your model class must at least inherit from QObject! The job of the model is to hold the data and game logic. The job of the view is to display things and handle user input. CourseNana.COM

Some Useful Qt Things

The main tricky thing is making buttons flash. The tricky aspect is that there needs to be a delay in turning a button on then off. Some things that you might find helpful are: QTimer: QTimer has a static method singleShot which calls a slot after a specified delay. You should not think of the timer as a clock. The timer is a way to schedule signals to happen in the future. You should not use C-style pauses (wait(), etc.) that lock execution until some time is past. That will also freeze the application. Use timers to schedule when some next event will occur. Here is a tutorial CourseNana.COM

https://www.bogotobogo.com/Qt/Qt5_QTimer.php (https://www.bogotobogo.com/Qt/Qt5_QTimer.php) CourseNana.COM

one caution is that this tutorial uses an older macro-style connect call rather than the method pointers we have used.  Update to the modern style. Some background is at https://wiki.qt.io/New_Signal_Slot_Syntax (https://wiki.qt.io/New_Signal_Slot_Syntax) CourseNana.COM

StyleSheets: You can set a style sheet on a button to change its color. For example, a fairly painful way of setting the regular color of a button and the color when it is pressed is ui->redButton->setStyleSheet( QString("QPushButton {background-color: rgb(200,50,50);} QPushBut ton:pressed {background-color: rgb(255,150,150);}")); CourseNana.COM

You can enable buttons or disable them with setEnabled(true/false) If you declare a signal in the header of a class which inherits from QObject, you can emit that signal in your code. You do not need to implement that signal - it is declared in the header and just emitted in code. Signals can pass information along with the signal. CourseNana.COM

Requirements

The game should have CourseNana.COM

  1. A start button. The start button should be disabled when the game is in progress and enabled when no game is in progress. You may start a game off with an initial list of moves if starting at 1 move seems too easy.
  2. Two buttons, Red and Blue. They should display the computer moves when it is not the player's turn and should let the player press them (with visual feedback) when it is the player's turn. The buttons should be disabled when it is not the player's turn.
  3. The basic gameplay is for the computer to display the sequence of moves with appropriate delay, and then the human tries to repeat the sequence.
  4. Each time the computer plays again, it should add a new move to the end of the current sequence of moves.
  5. A progress bar shows the percentage of moves the player has completed when it is the player's turn. Be careful to end at 100% when all the moves have been matched by the player. A pause before starting the computer turn will help you see this.
  6. Some kind of a "you lose" message when the player makes a mistake. You can decide what form this should take.
  7. The game should speed up as more moves are added.
  8. Something creative and nice added beyond these basic requirements.  It should be something that would cause us to say "oh, that is nice" or "haha, that is weird and fun". Here are some things that are not nice: some kind of high score that persists for one session, making 4 colors instead of 2, starting at something like 3 moves instead of one. This doesn't need to be a lot of code. Think of something to add some twist to the game play, to liven up the display, something odd or funny, or something that requires learning something new in Qt.

Keep your .cpp,  .h, .ui, and .pro files on GitHub. We will clone that. CourseNana.COM

Make a short video (Zoom recording, use your phone, etc.) showing key functionality of your game. Watch your file size, if it is 100s of MB you are doing something wrong. CourseNana.COM

Submit to Gradescope the files from the repo and a movie file (it can be in the repo) or link to a movie file. If you have a partner, add the partner when submitting Gradescope. Add some names in comments on the files to help track this. CourseNana.COM

This tool needs to be loaded in a new browser window CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
QT代写,C++代写,Simon Game代写,US代写,The University of Utah代写,QT代编,C++代编,Simon Game代编,US代编,The University of Utah代编,QT代考,C++代考,Simon Game代考,US代考,The University of Utah代考,QThelp,C++help,Simon Gamehelp,UShelp,The University of Utahhelp,QT作业代写,C++作业代写,Simon Game作业代写,US作业代写,The University of Utah作业代写,QT编程代写,C++编程代写,Simon Game编程代写,US编程代写,The University of Utah编程代写,QTprogramming help,C++programming help,Simon Gameprogramming help,USprogramming help,The University of Utahprogramming help,QTassignment help,C++assignment help,Simon Gameassignment help,USassignment help,The University of Utahassignment help,QTsolution,C++solution,Simon Gamesolution,USsolution,The University of Utahsolution,