Scroll Sign
Write a program that displays (in the console) an image made of characters and animates it like a scroll sign (shifting left out of view and shifting back in again from the right side).
Have it display a drawing of "GO" made of zeros and spaces.
000000 000000
00 00 00
00 000 00 00
00 00 00 00
000000 000000
Add some spaces after each line, so that it will be separated from the image scrolling in from the right.
After shifting left once, it will look like this:
00000 000000 0
0 00 00 0
0 000 00 00 0
0 00 00 00 0
00000 000000 0
Display the shifted image a few lines below the previous one (your console display scrolls to the lowest text).
Requirements
- Store the image in a multidimensional array of chars.
- Make a function called "displayImage" that displays the image after receiving the array as a parameter.
- Make another function called "shiftLeft" that shifts the image's position by updating the image array.
- The animation should last 30 cycles, each lasting 0.1 seconds (100 milliseconds).
- Use this line of code to delay for 0.1 seconds:
try {Thread.sleep(100);} catch (InterruptedException e) {break;};
Hints
Array containing "GO" image
char [][] goImg = {
{'0','0','0','0','0','0',' ','0','0','0','0','0','0',' ',' ',' '},
{'0','0',' ',' ',' ',' ',' ','0','0',' ',' ','0','0',' ',' ',' '},
{'0','0',' ','0','0','0',' ','0','0',' ',' ','0','0',' ',' ',' '},
{'0','0',' ',' ','0','0',' ','0','0',' ',' ','0','0',' ',' ',' '},
{'0','0','0','0','0','0',' ','0','0','0','0','0','0',' ',' ',' '}
};
Animation loop code
for (int i = 0; i < 33; i++) {
System.out.print("\n\n\n");
displayImage(goImg);
shiftLeft(goImg);
try {Thread.sleep(100);} catch (InterruptedException e) {break;};
}