I need help with my project pleaseee!! it is due tomorrow and I have no idea what to do please help!
You're to write a program that randomly fills the entire screen with a character, like an asterisk, with certain foreground/background colors. After you've filled the whole screen with the character, you'll shift foreground/background colors and do it again and again, shifting foreground/background colors for a hypnotic effect! The program will do this endlessly in an infinite loop until the user either stops it with a Ctrl+c keystroke or just forgets to breathe and expires.
You’ll need to research how to generate random numbers using the rand function. If you're able to generate a series of random numbers, those numbers can be used to derive random row/column coordinates, which means you'd be able to draw a character to arbitrary positions on the screen until it's eventually filled up. We also considered how you could keep track of which row/column positions had already been used so that you don't keep writing characters to the same locations, by using a 2D array of bools. If you look in your Project directory you'll find a starter kit called ScatterStarterKit.tar.gz which contains the following files:
cmatrix.h -- This header file contains the declaration for the CMatrix class. The purpose of this class is to fill the screen with a character at random locations. If you look at the class declaration, you'll see that it only has two data members: one to store the total number of rows, and another to save the total number of columns. These data members are initialized by the class constructor, which receives those values in the parameter list.
Once the CMatrix object has been initialized, it's ready to have its CMatrix::Fill member function called. This function takes as input a character to draw, and a sleep interval to control the speed with which they're drawn. A loop is entered to draw the character to random locations on the screen until all available positions have been used and the screen is completely filled. (Hmm... how will it keep track of available screen locations? How will it know when the screen has been completely filled?)
cscreen.h -- This header file contains the declaration for the CScreen class. This class has two data members -- one that stores the character to display, and another which saves the sleep interval that can be used as an argument to the usleep function. These data members will get their values from an external file called config.dat, which is read by the class constructor. The constructor will also be responsible for performing any initialization needed by the curses library, which can be handled easily enough by calling the InitCurses member function, which can set up the initialization and colors. The CScreen class only has one other member function, Scatter, which is responsible for the random drawing of characters. As it changes the foreground/background colors, it will use a local CMatrix object to fill the screen with the display character.
main.cpp -- Obviously, this is the main module that drives the whole program. It creates an instance of the CScreen class, passing the name of the configuration file to its constructor. Then calls that object's Scatter function, which takes it from there to randomly fill the screen.
config.dat -- This is the configuration file that the program reads before it begins. If you open it up with a text editor, you'll see that it contains two items: the character to display, and the sleep interval to use when the usleep function is called. Look in the main module and you'll see the name of this file is passed to the CScreen constructor; if you look in the private section of that class, you'll see how the class stores the items in config.dat in its private data members.
scatter -- This is a sample executable, so run the program and see what it does. Try modifying the items in config.dat and see how your changes affect the behavior of the program.