diff --git a/Week 2/README.md b/Week 2/README.md index 94aea69..7876aa6 100644 --- a/Week 2/README.md +++ b/Week 2/README.md @@ -269,6 +269,7 @@ We have one cube in the scene. Let's add more! We can do this by creating more i > Create 2 new instances of cubes and call the _Draw_ function for each of them. I will call mine cube2 and cube3 (so that I have 3 instances of the Cube class in my scene). Check the example below when you have done this. +
Example Code @@ -287,7 +288,7 @@ void drawScene() ```
- +
Running the project shows us the same scene... But we have 3 cubes now and should see 3 cubes. Why is this the case? @@ -299,6 +300,7 @@ To fix this, the Cube class will have to hold a position value so each instance We have already included the right library code (_#include _) so we can go straight to adding a variable to the Cube class. Do this now and give it a sensible name. (Check my example below when you are happy.) +
Example Code @@ -317,7 +319,7 @@ public: }; ```
- +
We need a way to give _position_ a value because at the moment it will be a default (0, 0, 0) value and is also not used anywhere. @@ -327,6 +329,7 @@ We can create a new constructor that, given a _vec3_ value, gives that instance > Create a new constructor that takes in a _vec3_ value and then assigns that value to the _position_ variable. When you are happy, make sure your code does the same as the example below. +
Example Code @@ -347,12 +350,13 @@ Cube::Cube(glm::vec3 pos) ```
- +
The final code change to the Cube class we will do is in the _Draw_ function. (If you ran the project now, there would still be no change). We will change the _glTranslatef_ line so it uses the value of the _position_ variable instead of the current "hard coded" value of _0, 0, 0_. > Change the _glTranslatef_ line so it uses the position variable. Check this against the example below. +
Example Code @@ -368,7 +372,7 @@ void Cube::Draw() ```
- +
Now we just need to use the new constructor for the instances we create in the _main/Source.cpp_.