Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to print white lowercase \'o\'s on a black background across

ID: 3783897 • Letter: W

Question

Write a C++ program to print white lowercase 'o's on a black background across the middle of the screen. Next, have a captial 'O' move from left to right, and back, on top of the lower-case 'o's using each of the colors specified by the ANSI escape sequences. After you've "bounced" a white 'O', go to the next line and end your program. You may assume a screen size of 80x25 (80 chars across by 25 lines).

Basic animation is a simple 3-step process: Draw something. Pause so the eye can see it. Erase the old and go to #1. To do this, you'll need a pause function. Since we have not discussed this you'll need to use the following code in your program:

The capital O starts at the left and moves to the right one lower-case o at a time and then back to the left, changing colors every time it reaches the starting point of the leftmost lower-case o. Please keep in mind that this is expected to run properly in a Linux environment. Also, this is an introductory C++ class and cannot used advanced libraries. The animation must be done using loops. Thank you.

Here is an example:

ANSI Escape Codes:

All sequences begin with the ESC char (ASCII value 27):

Text colors:

Foreground = F + 30
Background = B + 40

"[2J" Clear Screen "[R;Cf" Move cursor to row R and column C "[F;Bm" Set colors (see below) Eile Edit View Ierminal Tabs Help 00000000000000000000000000000000000000000000000000000000000000000000000000000000

Explanation / Answer

use Term::ANSIColor;

print color('bold blue');

print "This text is bold blue. ";

print color('reset');

print "This text is normal. ";

print colored("Yellow on magenta.", 'yellow on_magenta'), " ";

print "This text is normal. ";

print colored(['yellow on_magenta'], 'Yellow on magenta.', " ");

print colored(['red on_bright_yellow'], 'Red on bright yellow.', " ");

print colored(['bright_red on_black'], 'Bright red on black.', " ");

print " ";

# Map escape sequences back to color names.

use Term::ANSIColor 1.04 qw(uncolor);

my $names = uncolor('01;31');

print join(q{ }, @{$names}), " ";

# Strip all color escape sequences.

use Term::ANSIColor 2.01 qw(colorstrip);

print colorstrip("e[1mThis is bolde[0m"), " ";

# Determine whether a color is valid.

use Term::ANSIColor 2.02 qw(colorvalid);

my $valid = colorvalid('blue bold', 'on_magenta');

print "Color string is ", $valid ? "valid " : "invalid ";

# Create new aliases for colors.

use Term::ANSIColor 4.00 qw(coloralias);

coloralias('alert', 'red');

print "Alert is ", coloralias('alert'), " ";

print colored("This is in red.", 'alert'), " ";

use Term::ANSIColor qw(:constants);

print BOLD, BLUE, "This text is in bold blue. ", RESET;

use Term::ANSIColor qw(:constants);

{

    local $Term::ANSIColor::AUTORESET = 1;

    print BOLD BLUE "This text is in bold blue. ";

    print "This text is normal. ";

}

use Term::ANSIColor 2.00 qw(:pushpop);

print PUSHCOLOR RED ON_GREEN "This text is red on green. ";

print PUSHCOLOR BRIGHT_BLUE "This text is bright blue on green. ";

print RESET BRIGHT_BLUE "This text is just bright blue. ";

print POPCOLOR "Back to red on green. ";

print LOCALCOLOR GREEN ON_BLUE "This text is green on blue. ";

print "This text is red on green. ";

{

    local $Term::ANSIColor::AUTOLOCAL = 1;

    print ON_BLUE "This text is red on blue. ";

    print "This text is red on green. ";

}

print POPCOLOR "Back to whatever we started as. ";

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote