Advertisement
Guest User

Assignment 7 Text Anim ( Cody )

a guest
Oct 24th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <chrono>
  4. #include <stdlib.h>
  5. #include <thread>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. string srep(string str, int rep){
  11.     int i2 = 0;
  12.     string newStr = "";
  13.     for (i2 = 0; i2 < rep; i2 = i2 + 1) {
  14.         newStr = newStr + str;
  15.     }
  16.     return newStr;
  17. }
  18.  
  19.  
  20. void main() {
  21.     /*
  22.     string text = "***   ***   ***   ***";
  23.  
  24.     while ( true ) {
  25.  
  26.         int i = 0;
  27.  
  28.         for (i = 0; i < 20; i = i + 1) {
  29.             cout << srep(" ", i) + text << endl;
  30.             this_thread::sleep_for(std::chrono::milliseconds(50));
  31.         }
  32.  
  33.         for (i = 20; i > 0; i = i - 1) {
  34.             cout << srep(" ", i) + text << endl;
  35.             this_thread::sleep_for(std::chrono::milliseconds(50));
  36.         }
  37.     }
  38.     */
  39.    
  40.     vector<string> pattern(2);
  41.  
  42.     pattern[0] = "          o                   o o                 o   o               o     o               o   o                o   o               o     o               o   o                 o o                   o          ";
  43.     pattern[1] = "          o                   o o                 o   o               o     o               o   o                  o                  o   o               o     o               o   o                 o o         ";
  44.  
  45.     size_t limit = 21;
  46.  
  47.     while (true) {
  48.  
  49.         size_t i = 0;
  50.  
  51.         for (i = 0; i < pattern[1].size(); i = i + limit) { // + 20 instead of limit makes a cool lightning bolt thing
  52.             cout << pattern[1].substr(i, limit) << endl;
  53.             this_thread::sleep_for(std::chrono::milliseconds(25));
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement