YCP Logo Lab 23: Animation

Due: Friday, October 31st by 11:59 PM

Getting Started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download CS200_Lab23.zip. Import it into Visual Studio (File->Import...).

Add your code to the source file called Animate.c.

Your Task

In this lab, you will implement a simple bouncing ball animation using the console window.

Here is the main function of the program, which you will not need to change:

int main(void)
        // NOTE: you don't need to change anything in the main() function

        struct Scene scene;

        scene = create_scene();

        while (1) {
                // clear the off-screen display buffer

                // render the scene into the display buffer

                // copy the display buffer to the display

                // pause

                // update the scene
                scene = update_scene(scene);

The idea is simple:

  • the struct Scene data type represents the scene to be displayed (the location and current direction of the animated character)
  • the create_scene function creates an initial Scene and returns it
  • the render_scene function takes the current Scene and, using the cons_move_cursor, cons_change_color, and cons_printw functions, renders the current scene into an off-screen display buffer. (Note: cons_printw works just like printf, except that it prints text into an off-screen display buffer, rather than printing directly into the window. This eliminates display flickering.)
  • the cons_update_scene function takes the current Scene and returns an updated Scene in which one or more elements of the Scene move to different locations

Your task is to implement these four functions so that the program shows a "bouncing ball" animation, where a text character moves diagonally and bounces off the sides of the screen:


The general idea is that the struct Scene type should contain fields that record the position and direction of the animated character. For example, in my bouncing ball implementation, my struct Scene type is defined this way:

struct Scene {
        int x, y;
        int dx, dy;

The x and y fields record the current column and row of the ball, and the dx and dy fields record the current direction (1 for forward, -1 for backward) for the x and y directions.


When you are done, choose Tools->Submit to submit your completed lab to the server. You will need to enter your Marmoset username and password.

If the Tools->Submit option does not work, create a zip file containing the files in your project, and upload it to the submission server as lab23. The server URL is