CS 70

Adding More Sprites

A movie with a single sprite is pretty boring. In this part of the assignment, you'll create two additional sprites to add more excitement to your movie. The code changes in this part are very modest; the primary focus is on creativity and fun.

How a Sprite Is Made

Suppose we wanted a cow sprite that looks like

 _____________
< C++ is fun! >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

We can make such a sprite by first creating a text file in the spriteImages directory. Let's call it cow.txt. The contents of cow.txt would be exactly the text above.

Then we'd run the following command from the terminal:

python3 make-sprite.py -o spriteImages/cow.tsprite spriteImages/cow.txt
  • Goat speaking

    Meh. Do we need to read make-sprite.py to understand how it works?

  • LHS Cow speaking

    No, just run it and it will make the sprite file for you. Of course, if you're curious about how it works, feel free to read it!

  • Rabbit speaking

    Fun fact, the cow image above was created by a classic Unix program called cowsay which is installed on our server. You can type man cowsay to read about it and the other animals it supports, and type cowsay "Your text here" to see it in action.

Your Task

Add (At Least) Two New Sprites

Using the example above as a guide, add at least two new sprites for your movie. You can use any text art you like, but make sure the total area is less than 800 characters as that is our fixed upper limit for sprite size.

Your goal will be to have at least three sprites in your movie (e.g., the original one plus two new ones). You can, of course, create more than two new sprites if you like.

  • Dog speaking

    Can we use existing ASCII art we find online?

  • LHS Cow speaking

    Yes, as long as it fits within the size limit and is appropriate for all audiences.

  • Duck speaking

    Can we use color or emojis in our sprites?

  • LHS Cow speaking

    No, please stick to classic ASCII art without color or emojis.

Document the Origins of Your Sprites

In spriteImages/Provenance.md, document where you got your sprite images from. If you created them yourself, say so! If you found them online, provide a link to the source. If you modified an existing image, describe what you changed.

If possible, indicate the license under which the original image was released (e.g., public domain, Creative Commons, etc.). If it isn't clear what the license is, say so. (Since this is an educational exercise, reproducing copyrighted ASCII art is likely fine, especially since this is a transformative use, but it's good practice to think about these issues.)

Adjust numsprites.hpp

The file numsprites.hpp contains a constant, NUM_SPRITES, that tells the program how many sprites to expect. You will need to change this constant to match the number of sprites you plan to display.

Modify our-movie.cpp

Change the code in our-movie.cpp to load your new sprites and set their initial positions and velocities. You can use the existing code that loads the first sprite as a template for loading additional sprites. You are not requried to keep using the original sprite, but you can if you want to.

Run Your Movie

Once you've added your new sprites and modified the code, compile and run your movie to see your sprites in action. Make sure everything works as expected and that the sprites move around the screen as intended.

Helpful Hints

  • RHS Cow speaking

    Here are some hints for this part!

Stay Safe for Work

When creating your sprites, please ensure that the content is appropriate for all audiences. Avoid using any explicit or offensive material in your text art.

Positioning and Velocity

The initial position is provided in the constructor of the Sprite object, but the velocity must be set using the setVelocity member function after the sprite is created. You can set different velocities for each sprite to make the animation more dynamic.

Debugging Output Is (Still) Tricky

We mentioned this in the previous part, but it's worth repeating: because the Display class takes over the terminal window, any debugging output sent to the standard output (i.e., using std::cout) will likely mess up the display or not appear at all. There are ways to work around this issue—go back and read that section if you need help.

To Complete This Part of the Assignment

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)