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

From Chilipedia
Jump to: navigation, search
(Downloads)
m (Text replacement - "http://www.planetchili.net/" to "https://www.planetchili.net/")
 
(4 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
* <code>#include <header></code>
 
* <code>#include <header></code>
 
* Using <code>std::mt19973</code> and <code>std::uniform_int_distribution<int></code> to generate random numbers
 
* Using <code>std::mt19973</code> and <code>std::uniform_int_distribution<int></code> to generate random numbers
 +
 +
== Errata ==
 +
At [https://youtu.be/7yqV2hyv9Cc?list=PLqCJpWy5FohcehaXlCIt8sVBHBFFRVWsx&t=650 10:50] in the video, there is a note saying that <code>isEaten = IsColliding( ... );</code> would have also been a valid approach, but this is incorrect. With direct assignment, once the condition becomes false, the <code>isEaten</code> flag gets reset (which is not the desired behavior). With the <code>if</code> statement, once the flag is set it remains <code>true</code> regardless of what <code>IsColliding( ... )</code> returns on subsequent frames.
  
 
== Video Timestamp Index ==
 
== Video Timestamp Index ==
Coming soon!
+
* Intro [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=0m0s 0:00]
 +
* Basic game plan [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=0m30s 0:30]
 +
* Setting up member variables for entities: dude and poo [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=0m50s 0:50]
 +
* Dude and poo graphics [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=2m20s 2:20]
 +
* Creating Draw functions for Dude and Poo [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=4m8s 4:08]
 +
* Quick note on sprite coordinate origins [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=5m20s 5:20]
 +
* Screen clamping functions [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=6m20s 6:20]
 +
* Movement code for Dude [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=8m9s 8:09]
 +
* Collision test code [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=9m3s 9:03]
 +
* Win condition and Gameover screen [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=11m54s 11:54]
 +
* Title Screen [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=13m20s 13:20]
 +
* Randomizing poo positions [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=15m7s 15:07]
 +
* A little bit on constructors [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=16m11s 16:11]
 +
* Creating random number generator object [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=16m50s 16:50]
 +
* Specifying a range for random numbers [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=18m23s 18:23]
 +
* Random device: The importance of a seed [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=20m55s 20:55]
 +
* Why we don't use random device as a random number generator [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=22m9s 22:09]
 +
* Summing up what we have learned [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=23m4s 23:04]
 +
* An important message from the power rangers [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=23m50s 23:50]
 +
* Homework [https://www.youtube.com/watch?v=7yqV2hyv9Cc&t=26m33s 26:33]
  
 
== Homework ==
 
== Homework ==
Line 17: Line 39:
 
== Image to PutPixel Tools ==
 
== Image to PutPixel Tools ==
  
* [http://www.planetchili.net/forum/viewtopic.php?f=3&t=925#p1011 fukbmp] - a barebones tool by Chili
+
* [https://www.planetchili.net/forum/viewtopic.php?f=3&t=925#p1011 fukbmp] - a barebones tool by Chili
* [http://www.planetchili.net/forum/viewtopic.php?f=3&t=991 Custom Sprites 1.5] - a nicer tool by LuX
+
* [https://www.planetchili.net/forum/viewtopic.php?f=3&t=991 Custom Sprites 1.5] - a nicer tool by LuX
 
* [http://forum.planetchili.net/viewtopic.php?f=3&t=3612 Tristan's PutPixel Puker] - another sexy tool by Tristan
 
* [http://forum.planetchili.net/viewtopic.php?f=3&t=3612 Tristan's PutPixel Puker] - another sexy tool by Tristan
  
 
== Downloads ==
 
== Downloads ==
  
* [http://www.planetchili.net/downloads/Chili%20DirectX%20Framework.zip Framework Download]
+
* [https://www.planetchili.net/downloads/Chili%20DirectX%20Framework.zip Framework Download]
* [http://www.planetchili.net/downloads/T8-Goodies.zip PutPixel Sprites]
+
* [https://www.planetchili.net/downloads/T8-Goodies.zip PutPixel Sprites]
* [https://wiki.planetchili.net/ Tutorial 8 Code] (WORK IN PROGRESS)
+
* [https://planetchili.net/downloads/apworks/8/Beginner%20Tutorial%208%20Code.zip Tutorial 8 Code]
* [https://wiki.planetchili.net/ Tutorial 8 Homework Solution Code] (WORK IN PROGRESS)
+
* [https://planetchili.net/downloads/apworks/8/Beginner%20Tutorial%208%20HW%20Code.zip Tutorial 8 Homework Solution Code]
  
 
== See also ==
 
== See also ==

Latest revision as of 13:26, 5 May 2022

We make our first game. So goddamn sweet. Not shitty at all.

Concepts Taught

  • += and -= operators
  • Writing code in a constructor
  • #include <header>
  • Using std::mt19973 and std::uniform_int_distribution<int> to generate random numbers

Errata

At 10:50 in the video, there is a note saying that isEaten = IsColliding( ... ); would have also been a valid approach, but this is incorrect. With direct assignment, once the condition becomes false, the isEaten flag gets reset (which is not the desired behavior). With the if statement, once the flag is set it remains true regardless of what IsColliding( ... ) returns on subsequent frames.

Video Timestamp Index

  • Intro 0:00
  • Basic game plan 0:30
  • Setting up member variables for entities: dude and poo 0:50
  • Dude and poo graphics 2:20
  • Creating Draw functions for Dude and Poo 4:08
  • Quick note on sprite coordinate origins 5:20
  • Screen clamping functions 6:20
  • Movement code for Dude 8:09
  • Collision test code 9:03
  • Win condition and Gameover screen 11:54
  • Title Screen 13:20
  • Randomizing poo positions 15:07
  • A little bit on constructors 16:11
  • Creating random number generator object 16:50
  • Specifying a range for random numbers 18:23
  • Random device: The importance of a seed 20:55
  • Why we don't use random device as a random number generator 22:09
  • Summing up what we have learned 23:04
  • An important message from the power rangers 23:50
  • Homework 26:33

Homework

Make the poos move around the screen and rebound when they hit the edges.

The solution is given in this video.

Image to PutPixel Tools

Downloads

See also