Assigned: 2020-04-06
Due Date: 2020-04-14 by 11:59PM U.S. Central Time
The rubric can be found here.
You will need to submit your GitHub repository to Gradescope.
Get your copy of the repository here: https://classroom.github.com/a/pygIQb9Z
This assignment will use the Cinder framework.
You can download the latest version Cinder
for your platform here. The latest version is v0.9.2.
Here is a basic tutorial on how to develop Cinder projects: https://libcinder.org/docs/guides/tour/hello_cinder_chapter1.html.
Here is some documentation: https://libcinder.org/docs/reference/index.html.
Cinder v0.9.2
was built with Visual Studio 2015 in mind.
Thus, in order to build Cinder on Windows, you'll need to downgrade your
Microsoft Build Tools to v140
or v141
.
Note that for the C++ TicTacToe assignment, you probably only installed
v142
. So, below is a short guide on how to do this:
Uninstall Visual Studio Build Tools 2019
if present on your machine by navigating to Control Panel > Programs > Programs and Features > Uninstall a Program
, and then uninstall Visual Studio Build Tools 2019
.
Go to: https://my.visualstudio.com/Downloads?q=visual%20studio%202015&wt.mc_id=o~msft~vscom~older-downloads.
You'll also be able to access this page by going to https://my.visualstudio.com/downloads and searching for 2015
.
Next, download Visual Studio Community 2015 with Update 3
for your architecture (probably x64
).
Run the installer and if prompted, select Modify
.
Now, you only need to select the Common Tools for Visual C++ 2015
option, then click Next
.
Note that this will take up around 8GB
on your machine.
Continue along with the installation. The installation process can take a while (~20 minutes).
After the installation is complete, do not need to click the "Launch" button.
Go back to CLion and make the default toolchain be a Visual Studio environment, pointing to C:\Program Files (x86)\Microsoft Visual Studio 14.0
. Confirm that there are no warnings.
That's it!
As an added bonus, you now have Visual Studio 2015
installed if you ever want to use it in the future after this class is over.
~/Cinder
throughout the instructions~/Cinder
folder in CLion and click the green build button.
This will build libcinder
. You only need to do this once per machine. This build might take a while.my-projects
in ~/Cinder
. Clone the snake
project into this folder. You can checkout your repository here: snake
project in CLion, set the target to cinder-snake
and click the run button.MacOS users: It’s possible that you may come across:
Error running 'cinder-snake': Cannot run program … cinder-snake.app/Contents/Resources"): error=13, Permission denied
In this case, try doing: Edit configurations -> Executable -> Select Other -> Find my-projects/snake/cmake-build-debug/Debug/cinder-snake/Contents/MacOS/cinder-snake
And click run once again.
View > Tool Windows > Database
.Database properties
button, which is between the Refresh and the Stop button.snake.db
are automatically selected, you can proceed to Step 4.
ii. If there are no database properties selected, navigate to Add > SQLite
.SQLite
. Click this link.snake-<your-netid>/assets/snake.db
.Test Connection
to verify that the driver is set up correctly. Click the OK
button in the cinder-snake
target and play the game to test out your database.cinder-snake
application has run, go back to the Database tab, click the Refresh
button. You should now be able to see the schema of the database under snake.db > schemas > main > leaderboard
. Also, you’ll be able to manually execute queries by clicking the Jump to Console
button at the top.There are 4 different flags for the program (which you can modify via Edit Configurations -> Program Arguments):
size
, default: 16
-- "the number of tiles in each row and column"tilesize
, default: 50
-- "the size of each tile" in square pixelsspeed
, default: 50
-- "the speed (delay) of the game", lower means fastername
, default: CS126SP20
-- "the name of the player", for database purposesEvery time the snake game is run, the following should be executed in order:
The logic and SQLite query for item 1 has already been provided to you.
The logic for item 2 and 3 have already been provided, but you will need to write the query for this.
For item 4, you’ll need to write the logic and the query. Don’t worry too much about the format of the text in the application: all that matters is that the current player’s high scores are visible somewhere.
The queries for the leaderboard can be found in src/leaderboard.cc
.
The code will likely crash after the game ends due to the SQLite queries being initially empty/incorrect.
You may find it helpful to use try/catch
statements in apps/snake_app.cc
or in src/leaderboard.cc
in order to catch these
exceptions, thus avoiding fatal unhandled exception
messages.
We are using the SqliteModernCpp
library to make SQLite queries from C++.
Take a look at the examples here: https://github.com/SqliteModernCpp/sqlite_modern_cpp/tree/dev.
There is great documentation on SQLite, which can be found here: https://www.sqlitetutorial.net/. Please try to play around with the local database that you have before asking questions on Piazza. The SQLite syntax is very intuitive.
In apps/snake_app.cc
and apps/snake_app.h
, you’ll find the main GUI code for snake. Implement each of these features, and make sure to test after you implement them:
T
seconds - where T = (1 / size_of_snake)
(Note: this is not every frame)If you want to use a CinderBlock for any of this, you can clone the CinderBlock into your ~/Cinder/blocks
directory, and then place the name of the directory of the cloned directory into the BLOCKS
argument in apps/CMakeLists.txt
. See more info here: https://www.libcinder.org/docs/guides/cmake/cmake.html#building-your-application-with-cmake. Note that the first part of this link isn’t relevant since CLion will invoke the necessary CMake commands for you when building.
You can receive extra credit for extending the Snake
application in any interesting way. The more significant and interesting the extension the more points you can receive; in general, each hour of additional work is a point of extra credit.
Snake
working with your database queries and at least 3
extensions, which includes the 2
required extensions from part 2.This is not a coding-heavy assignment; we expect most of your time to
be spent on getting your IDE set up with Cinder
. Spend the time now troubleshooting your build
environment, rather than later!
If you run into any build or linking errors, please post them to Piazza. It can be difficult to fix these problems on your own.
Here is a list of bugs that we would like to document:
Game Over :(
text starts to flicker
on MacOS and Windows.src/engine.cc:128
on the initial run. Try re-running the application.