Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string.h>
- #include <stdlib.h>
- #include <windows.h>
- #define X_Tam_Console 80
- #define Y_Tam_Console 31
- using namespace std;
- typedef unsigned int uint;
- void print_XY(char *str, int posX, int posY,int qLin,bool cls){
- if(cls)
- system("cls");
- for(int i = 0; i < posY; i++)cout<<endl;
- for(int i = 0; i < posX; i++)cout << " ";
- cout<<str;
- for(int i = 0; i < qLin; i++)cout<<endl;
- }
- int tamanho(char *str, int &Size){
- for(int i = 0; i < str[i]; i++)Size = i+1;
- return Size;
- }
- /*void drawObj(){
- }*/
- void drawQuad(char *str,char bord,char preench,int posX,int posY, int larg,int alt){
- larg *= 0.99;
- int i = 0;
- int x = 1,y = 1;
- // print_XY(0,posX,posY,1);
- system("cls");
- for(int a = 0; a <= alt; a++){
- for(int b = 0; b <= larg; b++){
- if(a == 0 || a == alt)cout<<bord;
- else {
- if(b == 0 || b == larg) cout<<bord;
- else {
- if(b >= posX && a == posY && str[i] != '\0'){
- cout<<str[i++];
- }
- else cout<<preench;
- }
- }
- }
- cout<<endl;
- }
- }
- void print_movXY(char *str,int movLinX, int movLinY,int veloc){
- int x = 1, y = 1, sent = 0,sent2 = 0,tam;
- char *strAux = str;
- movLinX -= tamanho(str, tam);
- for(;;){
- if(x < movLinX && !sent){
- x++;
- }
- else{
- if(x > 0){
- sent = 1;
- x--;
- }
- else sent = 0;
- }
- if(y < movLinY && !sent2){
- y++;
- }
- else{
- if(y > 0){
- sent2 = 1;
- y--;
- }
- else sent2 = 0;
- }
- print_XY(str,x,y,1,true);
- // drawQuad(str,'#',177,x,y,X_Tam_Console,Y_Tam_Console);
- Sleep(veloc);
- }
- }
- int main()
- {
- print_movXY("lucas",X_Tam_Console,Y_Tam_Console,200);
- // drawQuad("",'#',176,0,0,X_Tam_Console,Y_Tam_Console);
- //cout<<tamanho("lucas rabelo",tam)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement