Advertisement
LucasBorges97

Printf_Das_Quebrada

Apr 27th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.21 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <windows.h>
  6.  
  7. #define X_Tam_Console 80
  8. #define Y_Tam_Console 31
  9.  
  10. using namespace std;
  11.  
  12. typedef unsigned int uint;
  13.  
  14. void print_XY(char *str, int posX, int posY,int qLin,bool cls){
  15.     if(cls)
  16.     system("cls");
  17.     for(int i = 0; i < posY; i++)cout<<endl;
  18.     for(int i = 0; i < posX; i++)cout << " ";
  19.     cout<<str;
  20.     for(int i = 0; i < qLin; i++)cout<<endl;
  21.  
  22. }
  23.  
  24.  
  25. int tamanho(char *str, int &Size){
  26.    for(int i = 0; i < str[i]; i++)Size = i+1;
  27.    return Size;
  28. }
  29.  
  30. /*void drawObj(){
  31.  
  32. }*/
  33.  
  34. void drawQuad(char *str,char bord,char preench,int posX,int posY, int larg,int alt){
  35.     larg *= 0.99;
  36.     int i = 0;
  37.     int x = 1,y = 1;
  38.   // print_XY(0,posX,posY,1);
  39.  
  40.  
  41.  
  42.         system("cls");
  43.        for(int a = 0; a <= alt; a++){
  44.  
  45.      for(int b = 0; b <= larg; b++){
  46.  
  47.          if(a == 0 || a == alt)cout<<bord;
  48.          else {
  49.             if(b == 0 || b == larg) cout<<bord;
  50.             else {
  51.                    if(b >= posX && a == posY && str[i] != '\0'){
  52.                         cout<<str[i++];
  53.                      }
  54.                     else cout<<preench;
  55.                    }
  56.                 }
  57.              }
  58.        cout<<endl;
  59.        }
  60.  
  61.  
  62. }
  63.  
  64. void print_movXY(char *str,int movLinX, int movLinY,int veloc){
  65.       int x = 1, y = 1, sent = 0,sent2 = 0,tam;
  66.       char *strAux = str;
  67.       movLinX -= tamanho(str, tam);
  68.       for(;;){
  69.  
  70.           if(x < movLinX && !sent){
  71.             x++;
  72.           }
  73.           else{
  74.  
  75.  
  76.           if(x > 0){
  77.                 sent = 1;
  78.                 x--;
  79.  
  80.           }
  81.           else sent = 0;
  82.           }
  83.  
  84.           if(y < movLinY && !sent2){
  85.             y++;
  86.           }
  87.           else{
  88.  
  89.           if(y > 0){
  90.                 sent2 = 1;
  91.                 y--;
  92.           }
  93.           else sent2 = 0;
  94.           }
  95.          print_XY(str,x,y,1,true);
  96.        // drawQuad(str,'#',177,x,y,X_Tam_Console,Y_Tam_Console);
  97.  
  98.           Sleep(veloc);
  99.  
  100.       }
  101. }
  102.  
  103.  
  104. int main()
  105. {
  106.    print_movXY("lucas",X_Tam_Console,Y_Tam_Console,200);
  107.  
  108.   // drawQuad("",'#',176,0,0,X_Tam_Console,Y_Tam_Console);
  109.    //cout<<tamanho("lucas rabelo",tam)<<endl;
  110.     return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement