Skip to content
Permalink
Browse files
Update README.md
  • Loading branch information
ab8809 committed Sep 9, 2019
1 parent 93352eb commit 5159ba952dd3809db8834ed96e0ebe4966a8eea1
Showing 1 changed file with 6 additions and 3 deletions.
@@ -77,7 +77,7 @@ We can do this by making a new class that we will use for the base class of the
> Create a new class using 1 of the 3 methods discussed last week and call it _GameObject_. Make sure it holds the position variable, has both a default constructor and a constructor that takes in a _vec3_ position and has a _Draw_ function.
<br/>
<details>
<summary> GameObject Example </summary>
@@ -127,7 +127,7 @@ void GameObject::Draw()
> Why did we use protected instead of private? Did you check for your Week 2 homework?
</details>
<br/>
Once this is made, we need to alter the _Cube_ class to allow it to inherit from the _GameObject_ class in the following ways:
@@ -137,7 +137,7 @@ Once this is made, we need to alter the _Cube_ class to allow it to inherit from
> Do the above alterations to the _Cube_ class. Make sure to try this all yourself before you check against the example below.
<br/>
<details>
<summary> Cube with inheritance </summary>
@@ -164,6 +164,7 @@ Cube::Cube(glm::vec3 pos): GameObject(pos)
```
</details>
<br/>
Running the project should still show the cubes in the scene. Now the base class is down we can use Polymorphism to further improve our code design.
@@ -183,6 +184,7 @@ Instead of just creating instances of the type of the current class such as _Cub
> How would you write this pointer line? Have a go before looking at the answer below.
<br/>
<details>
<summary> Cube with inheritance </summary>
@@ -197,6 +199,7 @@ GameObject* cubePtr2 = new Cube(glm::vec3(1, 0, 0));
```
</details>
<br/>
> Why is this useful? Find out next week! (A hint: It's useful for storing different inherited class types together.)

0 comments on commit 5159ba9

Please sign in to comment.