#include”dos.h”
#include”stdio.h”
#include”graphics.h”
#include”stdlib.h”
void main()
{
int x,y,b,px,py,c,p,s,cl;
int d=0,m;
union REGS i,o;
initgraph(&d,&m,"c:\tc");
i.x.ax=1;
int86(0x33,&i,&o);
i.x.ax=8;
i.x.cx=20;
i.x.dx=450;
int86(0x33,&i,&o);
printf("Brush style insert number from 0 to 5 : ");
scanf("%d",&p);
printf("Brush size insert number from 1 to 7 : ");
scanf("%d",&s);
printf("Brush color insert number from 1 to 16 : ");
scanf("%d",&cl);
clrscr();
cleardevice();
printf("\t\t**********DRAW IMAGE************");
while(!kbhit())
{
i.x.ax=3;
b=o.x.bx;
x=o.x.cx;
y=o.x.dx;
px=x;
py=y;
int86(0x33,&i,&o);
if(cl==16)
{
c=random(16);
}
else
{
c=cl;
}
setcolor(c);
if(b==1)
{
i.x.ax=3;
int86(0x33,&i,&o);
x=o.x.cx;
y=o.x.dx;
b=o.x.bx;
switch(p)
{
case 1:circle(px,py,s);break;
case 2:ellipse(px,py,0,270,s,s+2);break;
case 3:fillellipse(px,py,s+2,s);break;
case 4:rectangle(px,py,x,y);break;
case 5:sector(px,py,30,120,s,s);break;
default:line(px,py,x,y);
}
}
}
getch();
restorecrtmode();
closegraph();
}
11 comments:
Graphics,h not found ..Wat do i do?
same prob.. what is grpahics.h ???
can u please explain it
try writing header files as #include
if problem isnt solved download the graphics.h library from internet for your compiler
C graphics using graphics.h functions or WinBGIM (Windows 7) can be used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h in turbo c compiler you can make graphics programs, animations, projects and games. You can draw circles, lines, rectangles, bars and many other geometrical figures.
try writing header files as #include
if problem isnt solved download the graphics.h library from internet for your compiler
C graphics using graphics.h functions or WinBGIM (Windows 7) can be used to draw different shapes, display text in different fonts, change colors and many more. Using functions of graphics.h in turbo c compiler you can make graphics programs, animations, projects and games. You can draw circles, lines, rectangles, bars and many other geometrical figures.
/* graphics.h */
00002
00003 #ifndef __GRAPHICS_H
00004 #define __GRAPHICS_H
00005
00006 #include
00007 #include
00008 #include
00009 #include
00010
00011
00012 using namespace std;
00013
00014 #define colmult 256
00015
00016 static const int GRAPHICS_SURFACE_0 = 0;
00017 static const int GRAPHICS_SURFACE_1 = 1;
00018
00019 static const int TEXT_ALIGN_LEFT = 0;
00020 static const int TEXT_ALIGN_RIGHT = 1;
00021 static const int TEXT_ALIGN_CENTER = 2;
00022
00023 static const int cGRIDPOINTS = 0;
00024 static const int cBACKGROUND = 1;
00025 static const int cWIREPOINTCONNECTED1 = 2;
00026 static const int cWIREPOINTCONNECTED2 = 3;
00027 static const int cWIREPOINTDISCONNECTED1 = 4;
00028 static const int cWIREPOINTDISCONNECTED2 = 5;
00029 static const int cWIRESELECTED = 6;
00030 static const int cWIREUNSELECTED = 7;
00031 static const int cCOMPONENTSELECTED = 8;
00032 static const int cCOMPONENTINVALID = 9;
00033 static const int cCOMPONENT = 10;
00034 static const int cCOMPONENTSHADOW = 11;
00035 static const int cCOMPONENTEXECUTING = 12;
00036 static const int cCOMPONENTLABEL = 13;
00037 static const int cCOMPONENTLABELSELECTED = 14;
00038 static const int cPIN = 15;
00039 static const int cWIREPOINTINVALID = 16;
00040 static const int cCROSSHAIR = 17;
00041
00042
00043
00044 static GdkGC *GCS[18];
00045
00046 class Point{
00047 public:
00048 Point(int x, int y);
00049 Point(int x, int y, void *tag);
00050 Point(Point *p);
00051 int x;
00052 int y;
00053 void *tag;
00054 };
00055
00056
00057 void show_msg(const char *title, const char *c);
00058
00059 class Graphics{
00060
00061 public:
00062 Graphics(GtkWidget *drawingarea, int width, int height, int nbsurfaces);
00063 Graphics(GtkWidget *drawingarea, int nbsurfaces);
00064 ~Graphics();
00065
00066 void create_colors();
00067
00068 int width();
00069 int height();
00070
00071 void draw_line(int x1, int y1, int x2, int y2, int colorindex);
00072 void draw_rectangle(int x, int y, int width, int height, bool fill, int colorindex);
00073 void draw_pixmap(GdkPixmap *pixmap, int x, int y, int width, int height);
00074 void draw_pixmap(gchar **pixmap, int x, int y, int width, int height);
00075 void render(GdkPixbuf *pixbuf, int x, int y, int width, int height);
00076
00077
00078 void clear(int color_index);
00079 void put_pixel(int x, int y, int colorindex);
00080
00081 void draw_text(int x, int y, const char *text, int colorindex);
00082 void draw_text(int x, int y, const char *text, int colorindex, int alignment);
00083 void apply();
00084 void repaint();
00085
00086 void copy_surface(int surface);
00087 void set_draw_surface(int surface);
00088
00089 GdkPixmap *currentpixmap;
00090 vector pixmaps;
00091
00092 private:
00093
00094 GdkGC *make_gc(int red, int green, int blue);
00095
00096 GtkWidget *drawingarea;
00097 GdkColormap *colormap;
00098
00099 public:
00100 int _width;
00101 int _height;
00102
00103 };
00104
00105
00106 #endif
copy code remove the line number save file as graphics.h to your folder
If anyone hav a game project on any lang so plzz help me...batraaarti011@gmail.com
You must specify the address of bgi, try this:
initgraph(&gd, &gm, "C:\\TC\\BGI");
Not a single error shown.. But the program is not running?? Whenever i press ctrl+f9 it show the dialogue box for a second and than collapse.. Please help
Not a single error shown.. But the program is not running?? Whenever i press ctrl+f9 it show the dialogue box for a second and than collapse.. Please help
Post a Comment