Thread: LoadingBar (Animated Graphics C)

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    54

    Thumbs up LoadingBar (Animated Graphics C)

    Hello,

    Here im sharing my code for loading bar. Well working and easy to explain code, using loops to make it animated.
    See once..........



    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    #include<dos.h>
    void main(void)
    {clrscr();
    ///program to loading bar By Shansajid/////
         int gd=DETECT,gm, a,color,overlap=1;
         initgraph(&gd, &gm, "C:\\tc\\bgi");
    
        setcolor(RED);
    
        rectangle(90,385,510,405);
        setcolor(WHITE);
        for(a=100; a<=500; a++)
        {
        rectangle(130,402,a,388);
        delay(15);
            if(overlap=1)
            {
                 setcolor(BLUE);
                 settextstyle(2,HORIZ_DIR,5);
                 outtextxy(210,387,"Loading Please wait...");
                 overlap=0;
                 setcolor(WHITE);
            }
        }
    
        getch();
         closegraph();
    
    
    
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > if(overlap=1)
    What does this do?

    > overlap=0;
    And this?

    It seems to me that the assignment in the if statement makes sure all this code happens every time.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Well working and easy to explain code
    ROFLMAO. Clueless Turbo C developer FTL.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I like the enthusiasm, but there's no relationship between what you're seeing on the progress bar, and what is being completed. A tool needs work, or it's a paperweight rusting away somewhere, and this tool is not connected to any work - just a reasonable guess on the progress that might be expected, in a given amount of time.

    But I like the enthusiasm! Nurture and persist with that, and you don't know how big your future in programming, might be.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    54
    Quote Originally Posted by Salem View Post
    > if(overlap=1)
    What does this do?

    > overlap=0;
    And this?

    It seems to me that the assignment in the if statement makes sure all this code happens every time.
    Run program before removing overlap variable and its all uses, you will see the overlapping text inside the progress bar "loading please wait" will be hidden behind the color of progress bar.
    overlap variable is only a solution of this problem.

  6. #6
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    I don't think you quite understood the comment.
    8 Common Programming Mistakes - Cprogramming.com
    Read #4.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Animated Avatar
    By abachler in forum A Brief History of Cprogramming.com
    Replies: 25
    Last Post: 04-16-2008, 02:42 PM
  2. How do you get animated Avatars ?
    By abh!shek in forum A Brief History of Cprogramming.com
    Replies: 62
    Last Post: 02-07-2008, 12:40 PM
  3. Animated
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 05-12-2007, 09:21 PM
  4. Animated gifs
    By Joe100 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-17-2003, 06:41 PM
  5. Animated Game
    By momegao in forum C++ Programming
    Replies: 0
    Last Post: 05-02-2003, 06:55 PM