Posts

Fish Movement

Image
#include<stdlib.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<ctype.h> void main () { int gd=DETECT,gm; int newx= 0 ,newy= 0 ,inc_y= 5 ; initgraph(&gd,&gm, " " ); cleardevice(); while (!kbhit()) { ellipse( 520 -newx, 200 , 30 , 330 , 90 , 30 ); circle( 450 -newx, 193 , 3 ); line( 430 -newx, 200 , 450 -newx, 200 ); line( 597 -newx, 185 , 630 -newx, 170 ); line( 597 -newx, 215 , 630 -newx, 227 ); line( 630 -newx, 170 , 630 -newx, 227 ); line( 597 -newx, 200 , 630 -newx, 200 ); line( 597 -newx, 192 , 630 -newx, 187 ); line( 597 -newx, 207 , 630 -newx, 213 ); line( 500 -newx, 190 , 540 -newx, 150 +newy); line( 530 -newx, 190 , 540 -newx, 150 +newy); if (newx>= 500 ) newx= 0 ; if (newy>= 82 ) inc_y=- 5 ; newx=newx+ 5 ; if (newy<= 0 ) inc_y= 5 ; newy=newy+inc_y; delay( 50 ); cleardevice(); } cleardevice(); } Hope, i

ELinks - Full-Featured Text WWW Browser

ELinks is an advanced and well-established feature-rich text mode web (HTTP/FTP/..) browser. ELinks can render both frames and tables, is highly customizable and can be extended via Lua or Guile scripts. It is quite portable and runs on a variety of platforms. ELinks is an Open Source project covered by the GNU General Public License. If you want to see ELinks in action check out the screenshots . ELinks is a program for browsing the web in text mode. The goal of the project has from the beginning been to provide a feature-rich text mode browser with an open patches/features inclusion policy and active development. One of these features is that ELinks includes Links-Lua which adds scripting capabilities to ELinks. Why text mode ? It may seem strange that anyone would develop a text mode browser in a world where the power of computers keep improving and most people favor graphical applications. Most graphical browsers are slow (especially to start up) and eat a lot of memory. For some

Flying Kite

Image
Program to implement a FLYING KITE using built-in functions available in the library. #include<stdio.h> #include<stdlib.h> #include<conio.h> #include<dos.h> #include<graphics.h> #include<ctype.h> #include<math.h> void main () { int gd=DETECT,gm; int color; int x= 10 ,y= 1 ,inc_x= 10 ,inc_y= 10 ; int poly[ 10 ]; initgraph(&gd,&gm, " " ); while (!kbhit()) { x += inc_x; if (x > 200 ) inc_x = - 5 ; if (x < 0 ) inc_x = 10 ; y += inc_y; if (y > 100 ) inc_y = - 10 ; if (y < 0 ) inc_y = 10 ; cleardevice(); setcolor(WHITE); setbkcolor(BLUE); poly[ 0 ]= 100 +x; poly[ 1 ]= 50 +y; poly[ 2 ]= 140 +x; poly[ 3 ]= 100 +y; poly[ 4 ]= 100 +x; poly[ 5 ]= 155 +y; poly[ 6 ]= 60 +x; poly[ 7 ]= 100 +y; poly[ 8 ]= 100 +x; poly[ 9 ]= 50 +y; drawpoly( 5 ,poly); setfillstyle(SOLID_FILL,RED); fillpoly( 5 ,poly); setlinestyle(SOLID_LINE, 1 , 3 ); line( 100 +x

Pendulum

Image
# include <graphics.h> # include <conio.h> # include <dos.h> # include <process.h> int cx= 300 ,cy= 100 ,r= 300 ; int x= 0 ,y,p; int path( int dtn) { int x1,y1; setcolor( 15 ); if (x>=y) { return 0 ; } cleardevice(); if (dtn== 1 ) { circle(cx+x,cy+y, 20 ); line(cx,cy,cx+x,cy+y); } else { circle(cx-x,cy+y, 20 ); line(cx,cy,cx-x,cy+y); } delay( 10 ); if (kbhit()) exit( 0 ); x++; if (p< 0 ) p+= 2 *x+ 1 ; else { y--; p+= 2 *(x-y)+ 1 ; } x1=x; y1=y; path(dtn); cleardevice(); if (dtn== 1 ) { circle(cx+x1,cy+y1, 20 ); line(cx,cy,cx+x1,cy+y1); } else { circle(cx-x1,cy+y1, 20 ); line(cx,cy,cx-x1,cy+y1); } delay( 10 ); if (kbhit()) exit( 0 ); return ( 0 ); } void

Moving Wheel

Image
#include<stdio.h> #include<conio.h> #include<graphics.h> #include<math.h> #include<dos.h> int l = 1 ; void ddaline ( int x1, int y1, int x2, int y2) { int s,dx,dy,m; float xi,yi,x,y; dx = x2 - x1; dy = y2 - y1; if (abs(dx) > abs(dy)) s = abs(dx); else s = abs(dy); xi = dx / ( float )s; yi = dy / ( float )s; x = x1; y = y1; putpixel(x1 + 0.5 ,y1 + 0.5 , 15 ); for (m = 0 ;m < s;m ++ ) { x += xi; y += yi; putpixel(x + 0.5 ,y + 0.5 , 15 ); } } void plotpoints1 ( int x, int y, int cx, int cy) { putpixel(cx + x,cy + y, 15 ); putpixel(cx - x,cy - y, 15 ); putpixel(cx - y,cy + x, 15 ); putpixel(cx + y,cy - x, 15 ); if (l % 20 == 0 ) { ddaline(cx - x,cy - y,cx + x,cy + y); ddaline(cx - y,cy + x,cx + y,cy - x); } l ++ ; } void plotpoints2 ( int x, int y, int cx, int cy) { putpixel(cx - x,cy + y, 15 ); putpixel(cx + x,cy - y, 15 ); putpixel(cx +

Fill a bucket with water from a pipe.

# include <conio.h> # include <dos.h> # include <graphics.h> void main() { int gd=DETECT,gm=DETECT,i,j; initgraph(&gd,&gm, "" ); ellipse( 300 , 200 , 0 , 360 , 50 , 25 ); ellipse( 300 , 300 , 0 , 360 , 50 , 25 ); line( 250 , 200 , 250 , 300 ); line( 350 , 200 , 350 , 300 ); ellipse( 300 , 100 , 180 , 360 , 5 , 2 ); line( 295 , 100 , 295 , 80 ); line( 305 , 100 , 305 , 86 ); arc( 300 , 80 , 90 , 180 , 5 ); putpixel( 306 , 85 , 15 ); putpixel( 307 , 84 , 15 ); line( 308 , 84 , 630 , 84 ); line( 300 , 75 , 303 , 75 ); line( 314 , 75 , 630 , 75 ); putpixel( 304 , 74 , 15 ); putpixel( 305 , 73 , 15 ); line( 306 , 72 , 306 , 65 ); line( 311 , 72 , 311 , 65 ); putpixel( 312 , 73 , 15 ); putpixel( 313 , 74 , 15 ); pieslice( 309 , 62 , 0 , 360 , 5 ); setfillstyle(SOLID_FILL,BLUE); setcolor(BLUE); for (i= 0 ;i< 7 ;i++) {

To start with graphics programming

Image
Turbo C has a good collection of graphics libraries. If you know the basics of C, you can easily learn graphics programming. To start programming, let us write a small program that displays a circle on the screen. /* simple.c example 1.0 */ #include<graphics.h> #include<conio.h> void main() { int gd=DETECT, gm; initgraph(&gd, &gm, "c:\\tc\\bgi " ); circle(200,100,150); getch(); closegraph(); } To run this program, you need graphics.h header file, graphics.lib library file and Graphics driver (BGI file) in the program folder. These files are part of Turbo C package. In all our programs we used 640x480 VGA monitor. So all the programs are according to that specification. You need to make necessary changes to your programs according to your screen resolution. For VGA monitor, graphics driver used is EGAVGA.BGI. Here, initgraph() function initializes the graphics mode and clears the screen. We will study the difference betwee