Move the text 1 effets de textes turbo c++2 borland

Description

Permet de faire des effets : deplacer le texte de droite vers la gauche et inversement dans toutes les directions haut bas diagonal plus effet de couleurs.

Source / Exemple :


// PROGRAMME ECRIT EN C AVEC TURBO C++ BORLAND SOUS DOS 

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <dos.h>
#include <string.h> 

void afficher_menu(int ligne,int col);

void texte_vers_bas (char *texte,int ligne_depart,int ligne_fin,int col);
void texte_vers_haut (char *texte,int ligne_depart,int ligne_fin,int col);

void texte_gauche_vers_droite (char *texte,int ligne,int col_depart,int col_fin);
void texte_droite_vers_gauche (char *texte,int ligne,int col_depart,int col_fin);

void texte_diago_haut_gauche_bas_droit (char *texte,int ligne_depart,int ligne_fin,int col);
void    texte_diago_haut_droit_bas_gauche (char *texte,int ligne_depart,int ligne_fin,int col);

void texte_diago_bas_gauche_haut_droit (char *texte,int ligne_depart,int ligne_fin,int col);
void texte_diago_bas_droit_haut_gauche (char *texte,int ligne_depart,int ligne_fin,int col);

void box(int gau, int haut, int droi, int bas,int coul_cadre,int coul_fond);

char *texte = " FICHIER  EDITION   RECHERCHER   COMPILER";

char ecran_precedent[80];

int i;
int main(void)
{
char votre_choix;
static int i;
textbackground (CYAN);                   // fond d'ecran vert
clrscr();                                           // effacer l'ecran

// dessiner un cadre blanc avec un fond rouge
	box(18,4,67,23,WHITE,RED);
					  // colonne gauche  18   ligne haut = 5
					  // colonne droite  67   ligne bas = 23

    // afficher le menu a la ligne 8   colonne 22
    afficher_menu(8,22);                             

    // sauvegarder en memoire l'ecran actuel
    gettext(1,1,80,25,ecran_precedent);          

while(1) {          // TAPER ESC POUR SORTIR

    votre_choix = getch();

    do {
        switch (votre_choix) {
        case '1':

         // texte   ligne depart = 1   ligne fin = 25  col = 15
          texte_vers_bas (texte,1,25,15);     
         break;

        case '2':

        // texte     ligne depart = 25  ligne fin = 1        col = 15
         texte_vers_haut (texte,25 , 1 ,15);
         break;

        case '3':

        // texte    ligne depart = 5    col depart = 1 col fin = 80
         texte_gauche_vers_droite (texte,5, 1,80);
         break;

        case '4':
         // texte    ligne depart = 4    col depart =79 col fin = 1
         texte_droite_vers_gauche(texte,4 ,79,1);
         break;

        case '5':
        // texte        ligne_depart = 1     ligne_fin = 25  col = 1;
        texte_diago_haut_gauche_bas_droit(texte,1,25,1);
        break;

        case '6':
        // texte        ligne_depart = 1     ligne_fin = 24  col = 78;
        texte_diago_haut_droit_bas_gauche (texte,1,24,78);
        break;

        case '7':
        // texte        ligne_depart =25     ligne_fin = 1      col = 1;
        texte_diago_bas_gauche_haut_droit (texte,25,1,1);
        break;

       case '8':
       // texte        ligne_depart =23     ligne_fin =    2    col = 75;
         texte_diago_bas_droit_haut_gauche (texte,23,2 ,75);
         break;

        case '9':
         // afficher le menu de depart  ligne = 5   col = 2
         // le programme determine la ligne et la colonne 
          // aleatoirement

        afficher_menu(rand() % (11)+2 , rand() % (36)+1);
        delay(500);          // attendre avant d'effacer l'ecran

        // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);     
        break;

        case 27:              // fin du programme ESC
        exit(0);
        break;

        default:
        i++;            // increment i pour n'afficher qu'une seule fois 
        if (i==1) {      // le message d'erreur

        // dessiner un cadre blanc      fond noir
        box(18,7 ,67,13,WHITE,BLACK); 
        textbackground(BLACK);           
        gotoxy(22,10);
        cprintf(" ERREUR :    ENTREZ UN CHIFFRE ENTRE 1 ET 9 ");
        }

        break;
    }

    } while (!kbhit());
i =0;
}

// return 0;
} // FIN MAIN

void afficher_menu(int ligne,int col) {

char *menu[] = {
" 1 Descendre le texte...................",
" 2 Monter le texte......................",
" 3 Aller de gauche a droite.............",
" 4 Aller de droite a gauche.............",
" 5 Diagonale haut gauche vers bas droit.",
" 6 Diagonale haut droit vers bas gauche.",
" 7 Diagonale bas gauche vers haut droit.",
" 8 Diagonale bas droit vers haut gauche.",
" 9 Afficher le menu principal...........",
"ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ.",
" ESC FIN DU PROGRAMME...................",
NULL
};
int i, j;

     // dessiner le cadre
    box(col,ligne,col+strlen(menu[7])+1 ,ligne+12,RED,CYAN );    

    // texte en blanc       fond du texte en vert claire
    textcolor(WHITE);   textbackground(11);

    for (i = 0; menu[i] != NULL; ++i) {

     // couleurs aleatoire           fond vert
      textcolor( rand() % 15 );   textbackground(CYAN);

    for (j = 0; j < strlen(menu[i]); j++){          

     // faire venir le texte de gauche a droite

     gotoxy(col+1,1+ligne+i);
     cprintf("%1s", (strlen(menu[i])+menu[i]) -j);

     delay(3);          // ralentir l'affichage
    }

        gotoxy(col+1,1+ligne+i);
        textcolor(WHITE);
        cprintf("%s", menu[i]);
    }
        gotoxy(col+5,ligne-1);
        // texte jaune      fond vert
        textcolor(YELLOW);      textbackground(CYAN);
        cprintf("ENTREZ UN CHIFFRE ENTRE 1 ET 9 ");

return ;
}

void texte_vers_bas (char *texte,int ligne_depart,int ligne_fin,int col) {
    int i;

    for (i = 0;ligne_depart + i < ligne_fin; i++) {

        // texte en blanc       fond du texte en blue
        textcolor(WHITE);       textbackground(9);

        gotoxy(col,ligne_depart+i);
        cprintf("%s", texte);
        delay(50);          // ralentir le mouvement

         // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);

    }
return ;
}

void texte_vers_haut (char *texte,int ligne_depart,int ligne_fin,int col) {
    int i;

    for (i = 0;ligne_depart - i > ligne_fin; i++) {

        // texte en blanc       fond du texte en rouge
        textcolor(WHITE);       textbackground(RED);

        gotoxy(col,ligne_depart-i);
        cprintf("%s", texte);
        delay(50);              // ralentir le mouvement

        // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);     
    }
return ;
}

void texte_gauche_vers_droite (char *texte,int ligne,int col_depart,int col_fin) {

    int i;

    for (i = 0;col_depart + i < col_fin - strlen(texte); i++) {

        // texte en blanc       fond du texte en noir
        textcolor(WHITE);       textbackground(BLACK);

        gotoxy(col_depart+i,ligne);
        cprintf("%s", texte);
        delay(50);          // ralentir un peu l'effet

        // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);     
    }

return ;
}

void texte_droite_vers_gauche (char *texte,int ligne,int col_depart,int col_fin){

    int i;

    for (i = 0;col_depart-strlen(texte)-i > col_fin; i++) {

             // texte en bleu claire         fond du texte en vert
             textcolor(LIGHTBLUE);      textbackground(CYAN);

             gotoxy(col_depart - strlen(texte)-i,ligne);
             cprintf("%s", texte);
             delay(50);         // ralentir un peu l'effet

           // afficher l'ecran precedent
             puttext(1,1,80,25,ecran_precedent);            
    }

return ;
}

void texte_diago_haut_gauche_bas_droit (char *texte,int ligne_depart,int ligne_fin,int col) {
    int i;

    for (i = 0;ligne_depart + i < ligne_fin; i++) {

        // texte en noir    fond du texte en vert
        textcolor(BLACK);   textbackground(CYAN);

        gotoxy(col+i,ligne_depart+i);
        cprintf("%s", texte);
        delay(50);                  // ralentir le mouvement

        // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);     
    }
return ;

}

void    texte_diago_haut_droit_bas_gauche (char *texte,int ligne_depart,int ligne_fin,int col){
    int i;

    for (i = 0;ligne_depart + i < ligne_fin; i++) {

                 // texte en jaune      fond du texte en vert
                textcolor(YELLOW);  textbackground(RED);

                gotoxy(col-strlen(texte)-i,ligne_depart+i);
                cprintf("%s", texte);
                delay(50);                 // ralentir le mouvement

                // afficher l'ecran precedent
                puttext(1,1,80,25,ecran_precedent);     
    }
return ;

}

void texte_diago_bas_gauche_haut_droit (char *texte,int ligne_depart,int ligne_fin,int col) {

    int i;

    for (i = 0;ligne_depart - i > ligne_fin; i++) {

             // texte en VERT       fond du texte en bleu
              textcolor(WHITE);   textbackground(GREEN);

                    gotoxy(col+i,ligne_depart-i);
                    cprintf("%s", texte);
                    delay(50);              // ralentir    le mouvement
                 // afficher l'ecran precedent
                    puttext(1,1,80,25,ecran_precedent);                    
    }
return ;

}

void texte_diago_bas_droit_haut_gauche (char *texte,int ligne_depart,int ligne_fin,int col) {
    int i;

    for (i = 0;ligne_depart - i > ligne_fin; i++) {

        // texte en VERT    fond du texte en bleu
        textcolor(WHITE);   textbackground(YELLOW);

        gotoxy(col-strlen(texte)-i,ligne_depart-i);
        cprintf("%s", texte);
        delay(50);        // ralentir le mouvement

       // afficher l'ecran precedent
        puttext(1,1,80,25,ecran_precedent);    
    }
return ;

}

void box(int gau, int haut, int droi, int bas,int coul_cadre,int coul_fond) {

int i,j;

     textcolor(coul_fond);

for (i = 0; i+haut < bas;i++) {    // remplir le cadre d'une couleur

    for (j =0;j+gau<droi    ;j++) {
          gotoxy(gau+j+1,haut+1+i);     cprintf("Û");
    }
}

    textcolor(coul_cadre);

for (i =0;i+haut<bas;i++) {

    gotoxy(gau,haut+i);         cprintf("³");    // trait vertical gauche
    gotoxy(droi,haut+i);         cprintf("³");    // trait vertical droit
}

for (i =0;i+gau<droi;i++) {
    gotoxy(gau+i,haut);          cprintf("Ä");    // trait horizontal du haut
    gotoxy(gau+i,bas);           cprintf("Ä");    // trait horizontal du bas
}
    // coin superieur gauche
    gotoxy(gau,haut);             cprintf("Ú");     // coin superieur gauche
    gotoxy(droi,haut);             cprintf("¿");     // coin superieur droit

    gotoxy(gau,bas);              cprintf("À");      // coin inferieur gauche
    gotoxy(droi,bas);              cprintf("Ù");      // coin inferieur droit

return ;
}

Conclusion :


PROGRAMME ECRIT EN C AVEC TURBO C++ BORLAND SOUS DOS

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.