Difference between revisions of "Beginner C++ Game Programming Tutorial 4"
From Chilipedia
(Created page with "We learn how to control the flow of execution using <code>if</code> statements, we learn about a new variable type called <code>bool</code>, and we learn...") |
|||
Line 1: | Line 1: | ||
− | + | 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/<code>class</code>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 == | == Concepts Taught == | ||
− | * | + | * Animation and double buffering |
− | * | + | * Difference between .h and .cpp files |
− | * | + | * Adding member variables to a <code>class</code> |
− | + | * Variable scope | |
== Video Timestamp Index == | == Video Timestamp Index == | ||
Line 23: | Line 23: | ||
== Homework == | == 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 <code>Game::UpdateModel()</code> member function, and the drawing code should remain in <code>Game::ComposeFrame()</code>. | ||
+ | # 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 solution video whose link will be posted here. | ||
== See also == | == See also == | ||
− | * [[Beginner C++ Game Programming Tutorial | + | * [[Beginner C++ Game Programming Tutorial 5|Next in series (Tutorial 5)]] |
* [[Beginner C++ Game Programming Series]] | * [[Beginner C++ Game Programming Series]] |
Revision as of 20:53, 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/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 solution video whose link will be posted here.