Difference between revisions of "Intermediate C++ Game Programming Tutorial 5"
(→Source Code) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
* Allocating and freeing memory for objects/variables with <code>new</code> and <code>delete</code> | * Allocating and freeing memory for objects/variables with <code>new</code> and <code>delete</code> | ||
* Allocating and freeing memory for arrays with <code>new []</code> and <code>delete []</code> | * Allocating and freeing memory for arrays with <code>new []</code> and <code>delete []</code> | ||
+ | |||
+ | == Notes == | ||
+ | Although not mentioned explicitly in the video, it is important to note that with an 'array' that is allocated dynamically via something like <code>pArray = new char[69];</code>, the symbol <code>pArray</code> is not an array in the C/C++ sense of the word. It is merely a pointer that points to a block of memory that we are treating as an array. So don't expect <code>sizeof( pArray )</code> to give you the size of the memory block in bytes, and don't expect range-based for loops to work with this 'array' (or <code>std::begin</code>/<code>std::end</code> for that matter). | ||
== Video Timestamp Index == | == Video Timestamp Index == | ||
− | [https:// | + | [https://youtu.be/h6abznwr0EE Tutorial 5] |
+ | |||
+ | == Heap / Virtual Memory Red Pill == | ||
+ | Chili has once again graced us with a most magnificent bomb of the knowledge variety. This Red Pill installment discusses virtual memory, memory paging and page allocation, virtual address translation, heap allocation and management, and other crazy bullshit. There is a theoretical discussion and there are practical demonstrations/experiments with code. Fun for the whole family! | ||
+ | |||
+ | [https://youtu.be/IMC0y7ZC4YE Red Pill (Virtual Memory / Memory Paging / Heap Allocation)] | ||
+ | |||
== Source Code == | == Source Code == | ||
[https://github.com/planetchili/intlo GitHub Repo for tutorial]<br /> | [https://github.com/planetchili/intlo GitHub Repo for tutorial]<br /> | ||
[https://github.com/planetchili/Memesweeper GitHub Repo for homework (Memesweeper)] | [https://github.com/planetchili/Memesweeper GitHub Repo for homework (Memesweeper)] | ||
+ | |||
+ | == Downloads == | ||
+ | [http://www.gutenberg.org/files/2600/2600-0.txt War and Peace]<br /> | ||
+ | [http://www.gutenberg.org/ebooks/5348.txt.utf-8 Ragged Dick] | ||
== Homework == | == Homework == | ||
Line 18: | Line 31: | ||
A menu system and UI has already been implemented for you, all you need to do is figure out how to handle the output from the menu, and then modify the game engine to use dynamic allocation and to reset the field after every game. | A menu system and UI has already been implemented for you, all you need to do is figure out how to handle the output from the menu, and then modify the game engine to use dynamic allocation and to reset the field after every game. | ||
+ | Homework solution is [https://youtu.be/YfJ4amLbpBs here] | ||
== See also == | == See also == | ||
* [[Intermediate C++ Game Programming Tutorial 6|Next in series (Tutorial 6)]] | * [[Intermediate C++ Game Programming Tutorial 6|Next in series (Tutorial 6)]] | ||
* [[Intermediate C++ Game Programming Series]] | * [[Intermediate C++ Game Programming Series]] |
Latest revision as of 22:54, 19 December 2017
In this video we learn about dynamic memory allocation / heap allocation / free store allocation / whatever the fuck you wanna call it. What is this shit you ask? Watch the goddamn video! I gotta pack.
Contents
Topics Covered
- The three storage classes: automatic, static, and dynamic
- Allocating and freeing memory for objects/variables with
new
anddelete
- Allocating and freeing memory for arrays with
new []
anddelete []
Notes
Although not mentioned explicitly in the video, it is important to note that with an 'array' that is allocated dynamically via something like pArray = new char[69];
, the symbol pArray
is not an array in the C/C++ sense of the word. It is merely a pointer that points to a block of memory that we are treating as an array. So don't expect sizeof( pArray )
to give you the size of the memory block in bytes, and don't expect range-based for loops to work with this 'array' (or std::begin
/std::end
for that matter).
Video Timestamp Index
Heap / Virtual Memory Red Pill
Chili has once again graced us with a most magnificent bomb of the knowledge variety. This Red Pill installment discusses virtual memory, memory paging and page allocation, virtual address translation, heap allocation and management, and other crazy bullshit. There is a theoretical discussion and there are practical demonstrations/experiments with code. Fun for the whole family!
Red Pill (Virtual Memory / Memory Paging / Heap Allocation)
Source Code
GitHub Repo for tutorial
GitHub Repo for homework (Memesweeper)
Downloads
Homework
Modify Memesweeper so that the array for the field is dynamically allocated depending on play field selection by the user at the beginning of the game. After a game over, the game should be able to return to the menu so that the user can play again without restarting the application.
A menu system and UI has already been implemented for you, all you need to do is figure out how to handle the output from the menu, and then modify the game engine to use dynamic allocation and to reset the field after every game.
Homework solution is here