Beginner C++ Game Programming Tutorial 13

From Chilipedia
Jump to: navigation, search

In this lesson we learn about the bomb-ass data structure known as the array, the granddaddy of them all. We also learn about boring shit like the automatically-generated default constructor (BOOOOORIIIIING! NEEEEEERRRD!).

Concepts Taught

  • Arrays
  • Default Constructor
  • Using asserts

Video Timestamp Index

  • Intro 0:00
  • Mean average code example: local variables analysis in debugger 0:54
  • Arrays visualization in memory, arrays anatomy 2:37
  • Declaring an array in C++ 5:19
  • Array size must be known at compile time 7:20
  • What's so good about arrays: Using arrays in loops 8:23
  • Array size limit 11:22
  • Refactoring Poo Game: Using arrays 13:20
  • Useful logic pattern for determining if all elements "return true" 15:25
  • Constructing array of objects: default constructor 18:30
  • Note: There are special member functions in C++ 19:54
  • Initializing poos 21:39
  • Disadvantage of initializing poos this way (Init() funciton): breaks encapsulation 23:53
  • Making it a little better: 25:07
  • Another, bigger disadvantage of initializing poos using Init() funciton: Init() is separate from object construction, and thus could be easily desynchronized. 28:18
  • Solving above issue 29:07
  • Safety checks: Is it worth it? 30:28
  • In the future we will learn about vectors, a better solution for above problems 31:05
  • Homework 31:41

Homework

  1. Make it so that touching the poo is game over and the goal is to reach a square.
  2. Make the square's color pulsate and make a meter that keeps track of how many times the goal was reached.

The solution is given in this video.

Downloads

See also