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

From Chilipedia
Jump to: navigation, search
(Downloads)
m (Text replacement - "http://www.planetchili.net/" to "https://www.planetchili.net/")
 
(One intermediate revision by one other user not shown)
Line 34: Line 34:
 
== Downloads ==
 
== Downloads ==
  
* [http://www.planetchili.net/downloads/T11-Poo.zip Poo Starting Code]
+
* [https://www.planetchili.net/downloads/T11-Poo.zip Poo Starting Code]
* [http://www.planetchili.net/downloads/T11-Rect.zip Rect Starting Code]
+
* [https://www.planetchili.net/downloads/T11-Rect.zip Rect Starting Code]
* [http://www.planetchili.net/downloads/T11-Poo.zip Beginner Tutorial 11 Poo Code (WORK IN PROGRESS)]
+
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Poo%20Code.zip Beginner Tutorial 11 Poo Code]
* [http://www.planetchili.net/downloads/T11-Rect.zip Beginner Tutorial 11 Rect Code (WORK IN PROGRESS)]
+
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Rect%20Code.zip Beginner Tutorial 11 Rect Code]
* [http://www.planetchili.net/downloads/T11-Poo.zip Beginner Tutorial 11 Poo HW Code (WORK IN PROGRESS)]
+
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Poo%20HW%20Code.zip Beginner Tutorial 11 Poo HW Code]
* [http://www.planetchili.net/downloads/T11-Rect.zip Beginner Tutorial 11 Rect HW Code (WORK IN PROGRESS)]
+
* [https://planetchili.net/downloads/apworks/11/Beginner%20Tutorial%2011%20Rect%20HW%20Code.zip Beginner Tutorial 11 Rect HW Code]
  
 
== See also ==
 
== See also ==

Latest revision as of 13:26, 5 May 2022

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