Beginner C++ Game Programming Tutorial 4
From Chilipedia
In this tutorial explore the ideas animation in computer graphics and we make the reticle move freely around the screen. Along the way we learn how to add member variables to objects/class
es, we learn about .h (header) and .cpp files, we learn about the cruel mortal coil of variables (scope), and I make a joke in very bad taste. All par for the course!
Concepts Taught
- Animation and double buffering
- Difference between .h and .cpp files
- Adding member variables to a
class
- Variable scope
Video Timestamp Index
- Intro 0:00
- Homework solution 0:29
- Sprite origin (base position) 1:30
- Order of statement execution 5:10
- Branching (conditional flow control) 6:40
-
if
statement /bool
type 7:52 - Keyboard input / objects inside other objects 12:06
- Function return values 15:55
- Virtual key codes 17:27
-
if
...else
statement 19:33 -
if
...else if
chaining 20:35 - Nesting
if
statements 22:05 - Homework assignment 23:48
Homework
This lesson has three homework problems. Feel free to attempt any or all of them.
- Separate the game logic code from the drawing code. The game logic code should go in the
Game::UpdateModel()
member function, and the drawing code should remain inGame::ComposeFrame()
. - Change the behavior of the reticle so that it moves at a velocity that is controlled with the arrow keys. This means that the arrow keys don't control direction of movement, but that they control the acceleration.
- Make it so that the acceleration of the reticle is more controllable. How this is accomplished is left up to you. Full marks for using only concepts introduced so far ;)
The solutions will be given in a future video whose link will be posted here.