Answer To: Program 4 – Fireworks! Due: Refer to the Canvas assignment. Background The purpose of this program...
Vaibhav answered on Nov 05 2021
Fireworks.cpp
#include
#include
using namespace std;
/**
* @brief Initialize the empty buffer with whitespace char.
*
* @param buffer
*/
void initializeBuffer(char **buffer) {
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 60; j++) {
buffer[i][j] = ' ';
}
}
}
void copyTrace(int x, int y, char **buffer) {
char drawChar;
int i, j;
if (y == 30) {
drawChar = '|';
for (i = x, j = y; i < 20 && j < 60; i++) {
buffer[i][j] = drawChar;
}
} else if (y < 30) {
drawChar = '\\';
for (i = x, j = y; i < 20 && j < 60; i++, j++) {
buffer[i][j] = drawChar;
}
} else {
drawChar = '/';
for (i = x, j = y; i < 20 && j < 60; i++, j--) {
buffer[i][j] = drawChar;
}
}
}
void copyFireworkArt1(int startRow, int startCol, char **buffer) {
/* ~@~@~
~*~@~*~@~*~
~*~@$#$@~*~
~*~@~*~@~*~
~@~@~
*/
char pattern[5][11] = {
{' ', ' ', ' ', '~', '@', '~', '@', '~', ' ', ' ', ' '},
{'~', '*', '~', '@', '~', '*', '~', '@', '~', '*', '~'},
{'~', '*', '~', '@', '$', '#', '$', '@', '~', '*', '~'},
{'~', '*', '~', '@', '~', '*', '~', '@', '~', '*', '~'},
{' ', ' ', ' ', '~', '@', '~', '@', '~', ' ', ' ', ' '}};
int i, j;
int k, l;
for (i = startRow, k = 0; i < startRow + 5; i++, k++) {
for (j = startCol, l = 0; j < startCol + 11; j++, l++) {
if (i < 20 && j < 60) {
buffer[i][j] = pattern[k][l];
}
}
}
}
void copyFireworkArt2(int startRow, int startCol, char **buffer) {
/*
.* *.
*..*
* */
char...