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

From Chilipedia
Jump to: navigation, search
(Homework)
(Downloads)
(6 intermediate revisions by 3 users not shown)
Line 4: Line 4:
 
* References
 
* References
 
* Passing by reference
 
* Passing by reference
* <code>const</code> correctness (redux)
+
* <code>[[const]]</code> correctness (redux)
  
 
== Const Correctness ==
 
== Const Correctness ==
The use of <code>const</code> as as a means of communication by code and as method to prevent you and other people from shooting you (your code / themselves) in the dick is something that Chili finds cromulent. For some info on how <code>const</code> makes your code less shitty, check [https://isocpp.org/wiki/faq/const-correctness#const-and-type-safety this]. If you're still not sold (I happen to like being a human dumpster fire, thank you very much Chili), here is a video showing how using <code>const</code> can make your code a fuck of a lot faster: [https://www.youtube.com/watch?v=zBkNBP00wJE&feature=youtu.be&t=1455 cool beans].
+
The use of <code>const</code> as a means of communication by code and as method to prevent you and other people from shooting you (your code / themselves) in the dick is something that Chili finds cromulent. For some info on how <code>const</code> makes your code less shitty, check [https://isocpp.org/wiki/faq/const-correctness#const-and-type-safety this]. If you're still not sold (I happen to like being a human dumpster fire, thank you very much Chili), here is a video showing how using <code>const</code> can make your code a fuck of a lot faster: [https://www.youtube.com/watch?v=zBkNBP00wJE&feature=youtu.be&t=1455 cool beans].
  
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
Coming soon!
+
* Intro [https://www.youtube.com/watch?v=VzXco2FqpT8&t=0m0s 0:00]
 +
* Drawing rect function [https://www.youtube.com/watch?v=VzXco2FqpT8&t=0m41s 0:41]
 +
* Creating a Color object [https://www.youtube.com/watch?v=VzXco2FqpT8&t=4m32s 4:32]
 +
* Controlling the rectangle with the mouse [https://www.youtube.com/watch?v=VzXco2FqpT8&t=6m46s 6:46]
 +
* Extending DrawRect function to account for the "flip over" on the x and y, when x1 or y1 < x0 or y0 [https://www.youtube.com/watch?v=VzXco2FqpT8&t=8m23s 8:23]
 +
* Test and swap x0,y0 and x1,y1 [https://www.youtube.com/watch?v=VzXco2FqpT8&t=10m19s 10:19]
 +
* Shit don't work, references to the rescue! [https://www.youtube.com/watch?v=VzXco2FqpT8&t=10m19s 12:16]
 +
* Making Test and swap work! [https://www.youtube.com/watch?v=VzXco2FqpT8&t=17m45s 17:45]
 +
* Refactoring DrawRect [https://www.youtube.com/watch?v=VzXco2FqpT8&t=20m36s 20:36]
 +
* Poo game: Moving poo drawing code from Game class into Poo class [https://www.youtube.com/watch?v=VzXco2FqpT8&t=21m35s 21:35]
 +
* Process Consumption refactoring (args): passing Dude object by reference [https://www.youtube.com/watch?v=VzXco2FqpT8&t=25m48s 25:48]
 +
* Const correctness: passing by const reference [https://www.youtube.com/watch?v=VzXco2FqpT8&t=28m25s 28:25]
 +
* Const correctness: Making member functions const [https://www.youtube.com/watch?v=VzXco2FqpT8&t=30m40s 30:40]
 +
* Recap [https://www.youtube.com/watch?v=VzXco2FqpT8&t=32m1s 32:01]
 +
* Homework [https://www.youtube.com/watch?v=VzXco2FqpT8&t=34m5s 34:05]
  
 
== Homework ==
 
== Homework ==
Line 16: Line 30:
 
# Make a second <code>DrawRect</code> function that takes a single point (top left corner) and the dimensions as parameters.
 
# Make a second <code>DrawRect</code> function that takes a single point (top left corner) and the dimensions as parameters.
  
The solution is given in a [https://youtu.be/MOhF8Z2jW0k this] video.
+
The solution is given in [https://youtu.be/MOhF8Z2jW0k this] video.
  
 
== Downloads ==
 
== Downloads ==
  
* [http://www.planetchili.net/downloads/T11-Poo.zip Poo Code]
+
* [http://www.planetchili.net/downloads/T11-Poo.zip Poo Starting Code]
* [http://www.planetchili.net/downloads/T11-Rect.zip Rect Code]
+
* [http://www.planetchili.net/downloads/T11-Rect.zip Rect Starting Code]
 +
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Poo%20Code.zip Beginner Tutorial 11 Poo Code]
 +
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Rect%20Code.zip Beginner Tutorial 11 Rect Code]
 +
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Poo%20HW%20Code.zip Beginner Tutorial 11 Poo HW Code]
 +
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Rect%20HW%20Code.zip Beginner Tutorial 11 Rect HW Code]
  
 
== See also ==
 
== See also ==

Revision as of 13:04, 12 October 2019

References are sweet because they let us control our shit from far away. Remember the days when we had to actually get up to change the channel on the TV? Remember TV? Fuck that shit! Also, const correctness is for big dick gangstas that don't give any fucks.

Concepts Taught

  • References
  • Passing by reference
  • const correctness (redux)

Const Correctness

The use of const as a means of communication by code and as method to prevent you and other people from shooting you (your code / themselves) in the dick is something that Chili finds cromulent. For some info on how const makes your code less shitty, check this. If you're still not sold (I happen to like being a human dumpster fire, thank you very much Chili), here is a video showing how using const can make your code a fuck of a lot faster: cool beans.

Video Timestamp Index

  • Intro 0:00
  • Drawing rect function 0:41
  • Creating a Color object 4:32
  • Controlling the rectangle with the mouse 6:46
  • Extending DrawRect function to account for the "flip over" on the x and y, when x1 or y1 < x0 or y0 8:23
  • Test and swap x0,y0 and x1,y1 10:19
  • Shit don't work, references to the rescue! 12:16
  • Making Test and swap work! 17:45
  • Refactoring DrawRect 20:36
  • Poo game: Moving poo drawing code from Game class into Poo class 21:35
  • Process Consumption refactoring (args): passing Dude object by reference 25:48
  • Const correctness: passing by const reference 28:25
  • Const correctness: Making member functions const 30:40
  • Recap 32:01
  • Homework 34:05

Homework

  1. Move the drawing code for Dude from Game into the Dude class.
  2. Make a second DrawRect function that takes a single point (top left corner) and the dimensions as parameters.

The solution is given in this video.

Downloads

See also