Code Correctness
Throughout this course, we also want you to focus on your code quality in addition to the functionality of your code. For the complete list of code quality items we’ll look at throughout the quarter, please consult the code quality document. If we see code quality issues during code reviews, we will ask your group to resubmit the project with those issues fixed.
We will take off points if your code has memory leaks, so be sure to check for them before you submit your code!
Goals and Deliverables
This week, you will render text onto your screen!
Text
Task 1.
Now, it’s time to implement text! We have also given you a TrueType (.ttf) file and another image in the assets folder.
You will be writing code in timer.c so that when you compile your C program, the following sequence occurs:
We expect your game to contain (at least) the following:
- At the top of the screen, a counter with a label increments every second.
- Every 3 seconds, the image on the screen should switch to the other image.
Before you start, make sure that your team has copied over the engine files that were
implemented last week to this repo! However, be careful not to overwrite any new code that your teammates
might’ve written this week (since the engine project requires modifying body.c and scene.c). As a rule of thumb,
it’s a good idea to run git pull before you start working.
Here are a few hints for how to implement timer.c:
- For your last week’s game, your state object should have kept track of one
SDL_Texture *variable to render the CS 3 logo. What should we keep track of in this week’s implementation? - You must convert the time to a
char *to render it as text. You might find thesprintffunction helpful. - To keep track of time, a function in
sdl_wrapper.cwill be helpful (you also used it for project01). - By defining code relevant to image rendering in
sdl_wrapper.hand implementing them insdl_wrapper.c, we followed the principles of modularization. You’ll have to do something similar this week to render text. - Lastly, make sure you are disposing of everything properly in
emscripten_free.
Feel free to play around with different fonts and images! As long as you meet the above guidelines, you are free to use different assets.
For some help, take a look at the wiki page on SDL2 text and some resources our website!
To compile timer.c you still want to use the same command make game. Once you navigate to the link printed
to the shell (the last line before “Serving HTTP on …”), click the compiled timer.game.html file.
Once you are done, push your code to GitLab.
Once all your group members have finished, work with them to complete the extension (more information in the main project page).