Animation

This is a discussion on Animation within the C Programming forums, part of the General Programming Boards category; Hi! Anyone knows how to write an animation program in BGI graphics? I want to write a program that a ...

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Animation

    Hi!

    Anyone knows how to write an animation program in BGI graphics? I want to write a program that a ball will bounce from the edges of the screen.

    Any ideas?
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    One thing you can do is maybe look at some pascal code http://www.geocities.com/SiliconVall.../pasl2007.html
    And then notice the calls to getimage and
    putimage.

  3. #3
    lonelyplanetwanderer
    Guest

    enjoy the ball...

    #include<graphics.h>
    #include<alloc.h>
    main()
    {
    int gd=DETECT,gm,area,x=50,y=50,ch,xdirn=1,ydirn=1;
    int maxx,maxy;
    char *buff;

    initgraph(&gd,&gm,"c:\\tc\\bgi");

    setcolor(YELLOW);
    setfillstyle(SOLID_FILL,BLUE);
    circle(100,100,50);
    floodfill(100,100,YELLOW);

    area=imagesize(50,50,150,150);
    buff=malloc(area);
    getimage(50,50,150,150,buff);

    maxx=getmaxx();
    maxy=getmaxy();
    rectangle(0,20,maxx,maxy);
    outtextxy(250,10,"Animation");

    while(1)
    {
    if(kbhit())
    {
    ch=getch();
    if(ch=='\r')
    {
    xdirn*=-1;
    ydirn*=-1;
    }
    else
    {
    if(ch==27)
    break;
    }
    }
    putimage(x,y,buff,XOR_PUT);
    delay(0);
    x=x+(xdirn*5);
    y=y+(ydirn*2);
    putimage(x,y,buff,XOR_PUT);

    if(x<maxx-50||x<0)
    {
    sound(50);
    delay(10);
    nosound();
    xdirn*=-1;
    }

    if(y>maxy-50||y<20)
    {
    sound(50);
    delay(10);
    nosound();
    ydirn*=-1;
    }
    }
    getch();
    closegraph();
    restorecrtmode();

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    22
    Then where i can get the
    graphics.h
    alloc.h ?
    ______________________
    Wut ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opengl walking leg animation
    By Bobby230 in forum C Programming
    Replies: 3
    Last Post: 03-05-2006, 03:41 PM
  2. Threads in MFC
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 12-28-2005, 06:03 PM
  3. Animation class not working
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 03-02-2005, 06:48 AM
  4. animation timing
    By Eber Kain in forum Game Programming
    Replies: 2
    Last Post: 06-29-2004, 07:32 PM
  5. 3D animation (difficult?)
    By maes in forum Game Programming
    Replies: 3
    Last Post: 09-08-2003, 11:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21