Homework 3: Define the Asciimation Class
In this Step, we will fill in the definition for an Asciimation class. For now, it'll contain a single Sprite object that it'll draw to the screen. In the next assignment, we'll have more than one Sprite.
Your Task
The Asciimation class should have the following private data members:
- An array of characters of length
MOVIE_WIDTH * MOVIE_HEIGHTthat holds all of the currently displayed characters - A
Spriteobject that will be displayed (our one and only “actor”!)
Your Asciimation class should also have a parameterized constructor that takes in the name of a file with the content of a Sprite and a starting position (topLeftRow and topLeftColumn), then uses them to initialize the Sprite data member.
The Asciimation class also has two public static constants:
static constexpr int MOVIE_WIDTH = 80;
static constexpr int MOVIE_HEIGHT = 40;
These define the size of our animation display area.
Helpful Hints
Here are some hints for the
Asciimationclass.
Accessing a Static Member
You can access a class's static member variable using the class name and the scope-resolution operator; for example, ClassName::variableName.
Initializing the Sprite
Remember that the default constructor for the Sprite class is disabled! When (and how) should we initialize the Sprite data member so that not having a default constructor won't cause us problems?
Once you've finished this step, you should be able to compile and link everything again—but you will still get warnings about unused variables because you haven't implemented everything needed in the Asciimation class yet.
Use the Member-Initialization List
To receive full idioms points, your constructor must properly use the member-initialization list. You can read about this expectation in Section 4.1 of the CS 70 Idioms Page, and you can read more about member-initialization lists in the lessons and in Chapter 1.1 of the Unofficial CS70 textbook.
Name Your Data Members Correctly
You should name your Sprite data member sprite_ to be consistent with other parts of the starter code.
(When logged in, completion status appears here.)