Code::Blocks Forums

User forums => Help => Topic started by: Code_Blocker on March 23, 2014, 11:45:49 am

Title: ~ Help with graphics ~
Post by: Code_Blocker on March 23, 2014, 11:45:49 am
 ??? I am new to C++ and wish to learn basic graphics.

Please Help

1. Where are the header files located ? ( folder ? )
2. Is there a way to include graphics.h ? ( where can I DL the file and how do I install to use it ? )

Thank U all.

Question:

How may I Build & Run the following code. Error message posted above code. "Animated Circles In C++"


-------------- Build: Debug in Ball (compiler: GNU GCC Compiler)---------------

x86_64-w64-mingw32-g++.exe -Wall -fexceptions -g  -c C:\Code-jk\Ball\main.cpp -o obj\Debug\main.o
C:\Code-jk\Ball\main.cpp:4:21: fatal error: graphics.h: No such file or directory
 #include<graphics.h>
                     ^
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))


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


void main()
{

int x,y,i;
   int g=DETECT,d;
       initgraph(&g,&d,"\tc\bgi");
       cleardevice();
       x=getmaxx()/2;
       y=getmaxy()/2;
       settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
       setbkcolor(rand());
       setcolor(4);
       outtextxy(30,100,"Press");
       outtextxy(30,130,"any");
       outtextxy(30,160,"key");
       outtextxy(30,190, "to");
       outtextxy(30,220,"Quit");
       while (!kbhit())
       {
       setcolor(rand());
       for (int i=0;i<50;i++)
       circle(x,y,i );
       setcolor(rand());
       for (int j=70;j<120;j++)
       circle(x,y,j);
       setcolor(rand());
       for (int k=140;k<190;k++)
       circle(x,y,k);
       setcolor(rand());
       for (int l=210;l<230;l++)
       circle(x,y,l);
       delay(200);
       }
       getch();
       closegraph();
}
Title: Re: ~ Help with graphics ~
Post by: stahta01 on March 23, 2014, 11:55:28 am
Please read this sites rules. http://forums.codeblocks.org/index.php/topic,9996.0.html (http://forums.codeblocks.org/index.php/topic,9996.0.html)
If you do NOT follow them; your posts may be deleted or you banned from the site!

Quote
1. This is NOT a general programming board. "How do I write a program that....", "Can anybody teach me how to", "I have this homework", "My program doesn't run and I don't have the slightest idea of why because I'm a C++ newcomer", "What is a compiler", "What does gcc do" is the kind of questions that is FORBIDDEN to ask.

Please also read the first (General) section of FAQs http://wiki.codeblocks.org/index.php?title=FAQ (http://wiki.codeblocks.org/index.php?title=FAQ)

Tim S.
Title: Re: ~ Help with graphics ~
Post by: oBFusCATed on March 23, 2014, 11:56:44 am
You're using the wrong book to teach you graphics! The dos days are over, so you should find a better book/tutorial.

You can try to search for tutorials about SDL, OpenGL, DirectX or something similar to do graphics with.
Title: Re: ~ Help with graphics ~
Post by: Code_Blocker on March 23, 2014, 03:22:30 pm
I hope to be able to set up Code::BLOCK to use <graphics.h> then as I progress I can explore the other Technics.

May I get the instructions to just be able to set up Code::Block to recognize <graphics.h> for now thanks. :)
Title: Re: ~ Help with graphics ~
Post by: oBFusCATed on March 23, 2014, 03:57:56 pm
Sorry can't be done... Please come to 21st century... DOS is something from the past leave it there.

Also PMing people is considered rude, do it one more time and I'll make sure you get banned!