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

From Chilipedia
Jump to: navigation, search
(Homework)
m (Text replacement - "http://www.planetchili.net/" to "https://www.planetchili.net/")
 
(3 intermediate revisions by one other user not shown)
Line 7: Line 7:
  
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
Coming soon!
+
* Intro [https://www.youtube.com/watch?v=U4IdBkegBuY&t=0m0s 0:00]
 +
* Mean average code example: local variables analysis in debugger [https://www.youtube.com/watch?v=U4IdBkegBuY&t=0m54s 0:54]
 +
* Arrays visualization in memory, arrays anatomy [https://www.youtube.com/watch?v=U4IdBkegBuY&t=2m37s 2:37]
 +
* Declaring an array in C++ [https://www.youtube.com/watch?v=U4IdBkegBuY&t=5m19s 5:19]
 +
* Array size must be known at compile time [https://www.youtube.com/watch?v=U4IdBkegBuY&t=7m20s 7:20]
 +
* What's so good about arrays: Using arrays in loops [https://www.youtube.com/watch?v=U4IdBkegBuY&t=8m23s 8:23]
 +
* Array size limit [https://www.youtube.com/watch?v=U4IdBkegBuY&t=11m22s 11:22]
 +
* Refactoring Poo Game: Using arrays [https://www.youtube.com/watch?v=U4IdBkegBuY&t=13m20s 13:20]
 +
* Useful logic pattern for determining if all elements "return true" [https://www.youtube.com/watch?v=U4IdBkegBuY&t=15m25s 15:25]
 +
* Constructing array of objects: default constructor [https://www.youtube.com/watch?v=U4IdBkegBuY&t=18m30s 18:30]
 +
* Note: There are special member functions in C++ [https://www.youtube.com/watch?v=U4IdBkegBuY&t=19m54s 19:54]
 +
* Initializing poos [https://www.youtube.com/watch?v=U4IdBkegBuY&t=21m39s 21:39]
 +
* Disadvantage of initializing poos this way (<code>Init()</code> funciton): breaks encapsulation [https://www.youtube.com/watch?v=U4IdBkegBuY&t=23m53s 23:53]
 +
* Making it a little better: [https://www.youtube.com/watch?v=U4IdBkegBuY&t=25m7s 25:07]
 +
* Another, bigger disadvantage of initializing poos using <code>Init()</code> funciton: <code>Init()</code> is separate from object construction, and thus could be easily desynchronized. [https://www.youtube.com/watch?v=U4IdBkegBuY&t=28m18s 28:18]
 +
* Solving above issue [https://www.youtube.com/watch?v=U4IdBkegBuY&t=29m7s 29:07]
 +
* Safety checks: Is it worth it? [https://www.youtube.com/watch?v=U4IdBkegBuY&t=30m28s 30:28]
 +
* In the future we will learn about vectors, a better solution for above problems [https://www.youtube.com/watch?v=U4IdBkegBuY&t=31m5s 31:05]
 +
* Homework [https://www.youtube.com/watch?v=U4IdBkegBuY&t=31m41s 31:41]
  
 
== Homework ==
 
== Homework ==
Line 17: Line 35:
 
== Downloads ==
 
== Downloads ==
  
The starting code for Tutorial 13 is [http://www.planetchili.net/downloads/T13-Poo.zip here].
+
* The starting code for Tutorial 13 is [https://www.planetchili.net/downloads/T13-Poo.zip here].
 +
* [https://planetchili.net/downloads/apworks/13/Beginner%20Tutorial%2013%20Code.zip Tutorial 13 Code]
 +
* [https://planetchili.net/downloads/apworks/13/Beginner%20Tutorial%2013%20HW%20Code.zip Tutorial 13 Homework Solution Code]
  
 
== See also ==
 
== See also ==

Latest revision as of 13:26, 5 May 2022

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