Difference between revisions of "Beginner C++ Game Programming Tutorial 4"

From Chilipedia
Jump to: navigation, search
(Homework)
Line 4: Line 4:
 
* Animation and double buffering
 
* Animation and double buffering
 
* Difference between .h and .cpp files
 
* Difference between .h and .cpp files
 +
* Difference between a <code>class</code> and an object
 
* Adding member variables to a <code>class</code>
 
* Adding member variables to a <code>class</code>
 
* Variable scope
 
* Variable scope
Line 9: Line 10:
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
 
* Intro [https://youtu.be/xWLcp_yOpww 0:00]
 
* Intro [https://youtu.be/xWLcp_yOpww 0:00]
* Homework solution [https://youtu.be/xWLcp_yOpww?t=0m29s 0:29]
+
* Keyboard Ghosting [https://youtu.be/xWLcp_yOpww?t=0m29s 0:29]
* Sprite origin (base position) [https://youtu.be/xWLcp_yOpww?t=1m30s 1:30]
+
* Animation and double buffering [https://youtu.be/xWLcp_yOpww?t=1m15s 1:15]
* Order of statement execution [https://youtu.be/xWLcp_yOpww?t=5m10s 5:10]
+
* Animation sequence in the Framework [https://youtu.be/xWLcp_yOpww?t=4m54s 4:54]
* Branching (conditional flow control) [https://youtu.be/xWLcp_yOpww?t=6m40s 6:40]
+
* Variable scope (lifetime) [https://youtu.be/xWLcp_yOpww?t=7m28s 7:28]
* <code>if</code> statement / <code>bool</code> type [https://youtu.be/xWLcp_yOpww?t=7m52s 7:52]
+
* Difference between object and <code>class</code> [https://youtu.be/xWLcp_yOpww?t=9m15s 9:15]
* Keyboard input / objects inside other objects [https://youtu.be/xWLcp_yOpww?t=12m06s 12:06]
+
* Difference between .h and .cpp source files [https://youtu.be/xWLcp_yOpww?t=10m25s 10:25]
* Function return values [https://youtu.be/xWLcp_yOpww?t=15m55s 15:55]
+
* Adding member variable to a <code>class</code> [https://youtu.be/xWLcp_yOpww?t=11m15s 11:15]
* Virtual key codes [https://youtu.be/xWLcp_yOpww?t=17m27s 17:27]
+
* Variable scope name hiding [https://youtu.be/xWLcp_yOpww?t=11m42s 11:42]
* <code>if</code> ... <code>else</code> statement [https://youtu.be/xWLcp_yOpww?t=19m33s 19:33]
+
* Member access for members of same <code>class</code> [https://youtu.be/xWLcp_yOpww?t=13m12s 13:12]
* <code>if</code> ... <code>else if</code> chaining [https://youtu.be/xWLcp_yOpww?t=20m35s 20:35]
+
* Homework [https://youtu.be/xWLcp_yOpww?t=13m54s 13:54]
* Nesting <code>if</code> statements [https://youtu.be/xWLcp_yOpww?t=22m05s 22:05]
+
* Homework assignment [https://youtu.be/xWLcp_yOpww?t=23m48s 23:48]
+
  
 
== Homework ==
 
== Homework ==

Revision as of 21:19, 14 August 2016

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/classes, 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
  • Difference between a class and an object
  • Adding member variables to a class
  • Variable scope

Video Timestamp Index

  • Intro 0:00
  • Keyboard Ghosting 0:29
  • Animation and double buffering 1:15
  • Animation sequence in the Framework 4:54
  • Variable scope (lifetime) 7:28
  • Difference between object and class 9:15
  • Difference between .h and .cpp source files 10:25
  • Adding member variable to a class 11:15
  • Variable scope name hiding 11:42
  • Member access for members of same class 13:12
  • Homework 13:54

Homework

This lesson has three homework problems. Feel free to attempt any or all of them.

  1. 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 in Game::ComposeFrame().
  2. 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.
  3. 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.

See also