TASK #1
TASK:
What is a Camera?
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #1
- Extend the map to 22 units wide by 33 units high.
TASK #2
TASK:
Create the Camera class.
HINT:
You will need to create a class that has
two instance variables: x-offset and y-offset.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #3
TASK:
Create camera’s update method.
HINT:
The Camera class will be using the update method to calculate the x and y offset
based on the position of the ship.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #4
TASK:
Create camera’s apply method.
HINT:
The apply method will be used to adjust the rects
of the objects that are taken in as a parameter. The objects' rects must be repositioned
relative to the ship by adding the camera's x and y offset.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #5
TASK:
Putting it all together.
HINT:
To get the camera working, you will need to create a Camera object. You will then need to
create a for loop that will iterate through the platforms in the platform_group. As the loop
is iterating, each platform's image will be blitted at it's rect after it's been passed to
the camera's apply method. Remember, that all objects need to go through the camera's apply
method, even the ship!
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #2
- Complete the first "Now Try" exercise.
- Complete the second "Now Try" exercise.
- Complete the third "Now Try" exercise.
TASK #6
TASK:
Review the Camera class.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #7
TASK:
Create a smart camera that doesn’t update x_offset when the ship goes to the far right side.
HINT:
You need to calculate what will be the value of the x_offset when the
inner window reaches the right side of the world. Then, you need to create a branch statement that will stop the
offset from increasing when the ship reaches that point on the x-axis.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #3
- Extend the smart camera algorithm to not recalculate the x offset when the ship goes off the left side of the screen.
TASK #8
TASK:
Create a smart camera that doesn’t update y_offset when the camera_entity is at the bottom of the screen.
HINT:
You need to calculate what will be the value of the y_offset when the
inner window is at the bottom of the world. Then, you need to create a branch statement that will stop the
offset from increasing when the ship is in that bottom portion of the screen.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #4
- Extend the smart camera algorithm to not recalculate the y offset when the camera_entity goes off the top of the screen.
TASK #9
TASK:
What is a Camera_Entity?
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #5
- Define the Camera_Entity class's constructor.
- Define the update method.
- Create a Camera_Entity object and add it to the game.
TASK #10
TASK:
Make the camera follow the camera_entity on the y-axis and the ship on the x-axis.
HINT:
You will need to change the Camera's update method to take
in two arguments: the ship and the camera_entity. The calculation of the y_offset must be done using
the y position of the camera_entity and the x position using the ship.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #11
TASK:
Cause the camera to move upwards a few seconds after the game starts to give the player a moment to get ready.
HINT:
To accomplish this, you will need to change the
starting position of the camera_entity.
CHECK UP:
Watch the video below to check that you completed the task.
TASK #12
TASK:
Add an instance variable to the Camera_entity class called 'is_moving', that will be set to True when the screen is moving and False otherwise.
HINT:
To accomplish this task, you will need to
add a few branch statements that will check if the camera_entity's y position is less than at height - WIN_H/2, at which point 'is_moving'
will be set to True. You also need to check if the camera_entity's y position is at
less than WIN_H/2, at which 'is_moving' must be set to False.
CHECK UP:
Watch the video below to check that you completed the task.
CHALLENGE EXERCISE #6
- Cause the ship to match the camera_entity's speed when 'is_moving' is True.
- Force the ship not fly off the top and bottom of the visible screen.
- Make the ship uncontrollable for the first two seconds.
Congratulations!
You have completed incorporating "The Camera"!
You have completed incorporating "The Camera"!