Thread: Please Help me

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0

    Please Help me


    I need a code in C++

    its a project

    where i show 2 balls moving on the screen

    basically i need to show some basic graphics using c++

    im a novice

    if some one could help me with a code

    pls... it would really help me
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,393
    Rep Power
    1871
    How about starting with just one ball that doesn't move?

    Or even just a simple line, if you're not up to drawing shapes.

    Show us what you know, and then we guide you.

    > im a novice
    And?
    We all were novices at some point, but 99% of the people who are good at s/w didn't get there by waiting for other people to give them code.
    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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    7
    Rep Power
    0
    buddy you need to give the requirement in a bit more detail..then only i can help you.
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,179
    Rep Power
    2222
    Originally Posted by ravihariani
    basically i need to show some basic graphics using c++
    C++ doesn't have graphics.

    Operating systems and development environments provide support for graphics that you can call from C++, but those calls and how you use them will be different for each development environment and OS.

    By not providing information about what OS and what development environment you're using, you have rendered your request for code absolutely impossible.

    Besides, if we just gave you code, then you wouldn't learn anything.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0

    Hey


    #include <stdio.h>
    #include <dos.h>
    #include <graphics.h>
    #include <conio.h>

    #define MAGFY 20

    class Bline
    {
    private:
    int CEN_X,CEN_Y,radius,X,Y,i,j;
    public:
    void line1(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4);

    };

    void Bline::line1(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
    {
    CEN_X = (x1+x2)/2 + (x3-x2)/2;
    CEN_Y = (y1+y2)/2 + (y3-y2)/2;
    //radius = (x1+x2)/2;
    for(;!kbhit();)
    {
    delay(300);
    cleardevice();
    //1st box
    line(x1,y1,x2,y2);
    line(x1,y1-20,x2,y2-20); //
    line(x3,y3,x4,y4);
    line(x3,y3-20,x4,y4-20); //
    line(x1,y1,x4,y4);
    line(x1,y1-20,x4,y4-20); //
    line(x2,y2,x3,y3);
    line(x2,y2-20,x3,y3-20); //

    //2nd box
    line(x1,y1,x1,y1-20);
    line(x2,y2,x2,y2-20);
    line(x3,y3,x3,y3-20);
    line(x4,y4,x4,y4-20);

    //some point which will be moving around 3Dbox
    //line(x2+40,y2-20,x2+40,y2-20);
    //rectangle(x2,y2,x4,y4);

    //1st Quadrant
    if(x1>CEN_X && y1<CEN_Y) x1--,y1--;
    if(x1==CEN_X && y1<CEN_Y) x1--,y1++;
    if(x1<CEN_X && y1<CEN_Y) x1--,y1++;
    if(x1<CEN_X && y1==CEN_Y) x1++,y1++;
    if(x1<CEN_X && y1>CEN_Y) x1++,y1++;
    if(x1==CEN_X && y1>CEN_Y) x1++,y1--;
    if(x1>CEN_X && y1>CEN_Y) x1++,y1--;
    if(x1>CEN_X && y1==CEN_Y) x1--,y1--;

    //2nd Quadrant
    if(x2>CEN_X && y2<CEN_Y) x2--,y2--;
    if(x2==CEN_X && y2<CEN_Y) x2--,y2++;
    if(x2<CEN_X && y2<CEN_Y) x2--,y2++;
    if(x2<CEN_X && y2==CEN_Y) x2++,y2++;
    if(x2<CEN_X && y2>CEN_Y) x2++,y2++;
    if(x2==CEN_X && y2>CEN_Y) x2++,y2--;
    if(x2>CEN_X && y2>CEN_Y) x2++,y2--;
    if(x2>CEN_X && y2==CEN_Y) x2--,y2--;

    //3rd Quadrant
    if(x3>CEN_X && y3<CEN_Y) x3--,y3--;
    if(x3==CEN_X && y3<CEN_Y) x3--,y3++;
    if(x3<CEN_X && y3<CEN_Y) x3--,y3++;
    if(x3<CEN_X && y3==CEN_Y) x3++,y3++;
    if(x3<CEN_X && y3>CEN_Y) x3++,y3++;
    if(x3==CEN_X && y3>CEN_Y) x3++,y3--;
    if(x3>CEN_X && y3>CEN_Y) x3++,y3--;
    if(x3>CEN_X && y3==CEN_Y) x3--,y3--;

    //4th Quadrant
    if(x4>CEN_X && y4<CEN_Y) x4--,y4--;
    if(x4==CEN_X && y4<CEN_Y) x4--,y4++;
    if(x4<CEN_X && y4<CEN_Y) x4--,y4++;
    if(x4<CEN_X && y4==CEN_Y) x4++,y4++;
    if(x4<CEN_X && y4>CEN_Y) x4++,y4++;
    if(x4==CEN_X && y4>CEN_Y) x4++,y4--;
    if(x4>CEN_X && y4>CEN_Y) x4++,y4--;
    if(x4>CEN_X && y4==CEN_Y) x4--,y4--;
    }
    }
    int main()
    {
    int GD=DETECT,GM;

    Bline line1;
    initgraph(&GD,&GM,"c:\tc\bgi");

    //according to your own computer (TC\BIN) Directory


    line1.line1(5*MAGFY,7*MAGFY,1*MAGFY,3*MAGFY,3*MAGFY,1*MAGFY,7*MAGFY,5*MAGFY);

    getch();
    restorecrtmode();
    closegraph();
    return 0;
    }
    ____________________________________

    now my tc directory is C:\Turbo\TC\Bin

    Could u pls verify this code on ur end n see whether u can see the output ? its real urgent ...pls
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0

    Pls


    Pls, debug or make the required changes in it...

    i do wanna understand better but right nw , a lot depends upon this code working ....


    pls guys....
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0
    i wanna learn but if i dont submit the above code within 24 hrs in proper working, i would probably lose an opportunity of a lifetime ...

    i too dream to know c++ better as time passes n also help other novices then...

    but i need u guys to somehow help me make this code work...

    pls
  14. #8
  15. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,549
    Rep Power
    2337
    Nice copy/paste job.

    Enjoy your failure. You deserve it.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    5
    Rep Power
    0
    i kno its copy paste... but what do i do... i have less than 24 hrs before i need to submit this!

    i really need ur help on any sort of animation graphics... no matter hw basic...

    pls i need a program... i cannot afford to lose this opportunity ... \

    i dunno hw t explain
  18. #10
  19. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,179
    Rep Power
    2222
    The big problem is that Turbo C is ancient. Nobody uses it anymore and hardly anybody still has a copy. I certainly can't try to compile your program, let along debug it. I simply do not have an ancient enough set-up. The whole world has moved on in the past twenty years. So should you.

IMN logo majestic logo threadwatch logo seochat tools logo