All pastes #547860 Raw Edit

Unnamed

public c v1 · immutable
·published 2007-06-07 15:01 UTC
rendered paste body
#include <graphics.h>#include <stdlib.h>#include <stdio.h>#include <conio.h>#include <dos.h>#include <string.h>struct segment {int dir, x, y;};struct segment segments[2520];void definedir(){if (key == 80)		{		segments[0].dir = up;		}if (key == 72)		{		segments[0].dir = down;		}if (key == 77)		{		segments[0].dir = right;		}if (key == 75)		{		segments[0].dir = left;		}}void movehead(){if (segments[0].dir == up)		{		segments[0].x;		segments[0].y+10;		}if (segments[0].dir == down)		{		segments[0].x;		segments[0].y-10;		{if (segments[0].dir == right)		{		segments[0].x+10;		segments[0].y;		}if (segments[0].dir == left)		{		segments[0].x-10;		segments[0].y;		}}void main (void){int gdriver = DETECT, gmode, errorcode;initgraph (&gdriver, &gmode, "C:\\BC\\BGI");errorcode = graphresult();if (errorcode != grOk)	{	clrscr ();	printf ("Graphics error: %s\n", grapherrormsg (errorcode));	printf ("Press any key to halt");	getch ();	exit (1);	}//////////////////////////////////////////////////////////////////int x1, y1, l, m;randomize();rectangle (13, 13, 627, 397);/*l = random (62);m = random (39);if (l == 0) l+10;if (l == 62) l-10;if (m == 0) m+10;if (m == 39) m-10;x1 = l*10;y1 = m*10;*/int key;segments[0].x = 310;segments[0].y = 200;setcolor (7);circle (segments[0].x, segments[0].y, 5);int up, down, left, right, length, score = 0;while (key!=27){if (kbhit()) key = getch();definedir();delay (150);movehead();setcolor(7);circle (segments[0].x, segments[0].y, 5);}getch();closegraph();}}}