Here’s my version of the Artillery game from the C++ Education course by Google for Education! Watch my brain lag!
TRIGGER WARNING: Video contains some flashes, probably from the render. SORRY!
I made these modifications from the original specs:
- Added a shot counter
- Altered death conditions. You don’t have to die!
- You might die from carelessness though.
- Restricted angles since values are only unique from 0-45 (tangent property)
- Restricted input to not accept values other than y/n/Y/N when asking to play again.
- Formatting, punctuation and wording
These are my most significant learnings from this exercise:
- REFERENCES REFERENCES REFERENCES. I think I only actually understood it here. Thank you, GeeksforGeeks! I used to use vectors, arrays, or pointers for returning multiple values but using references instead feels straight forward. I am a bit afraid I might be misusing it, however, because IT FEELS SO POWERFUL!
- Aggressive but sensible decomposition. I really tried to decompose the functions as much as possible and had to stop myself because my comments made ~3-line codes seem lengthy.
- Using Make with GCC. I was trying to cross-compile because I’m using Linux and I wanted my SO who’s working on Windows to get to test it. It looks like my output was still a Linux binary that I just specified to be an exe file… But hey! I compiled with Make! :sweat-smile: