#include <dos.h>
#include <math.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <graphics.h>
struct body
{
int x,y;
body *next;
};
int main()
{
int GraphDriver = DETECT; /* Request auto-detection */
int GraphMode;
int ErrorCode;
initgraph( &GraphDriver, &GraphMode, "" );
ErrorCode = graphresult(); /* Read result of initialization*/
if( ErrorCode != grOk ) /* Error occured during init */
{
printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
exit( 1 );
}
body *start;
body *curr;
curr = NULL;
start = NULL;
int dx = 10;
int dy = 0;
char znak = 0;
start = new body;
start -> x = 320;
start -> y = 240;
start -> next = NULL;
do
{
if(kbhit())
{
znak = getch();
switch(znak)
{
case 'w':
dy = -10;
dx = 0;
break;
case 's':
dy = 10;
dx = 0;
break;
case 'a':
dy = 0;
dx = -10;
break;
case 'd':
dy = 0;
dx = 10;
break;
case ' ':
curr = start;
while(curr -> next != NULL)
{
curr = curr -> next;
}
curr -> next = new body;
//curr = curr -> next;
curr -> next = NULL;
break;
}
}
start -> x += dx;
start -> y += dy;
delay(150);
circle(start -> x,start -> y,5);
do
{
curr = start;
int tmpx, tmpy;
tmpx = curr -> x;
tmpy = curr -> y;
}while(curr -> next != NULL);
}while(znak!=27);
while(!kbhit()); //czeka na naciśnięcie klawisza
closegraph(); /* Return the system to text mode */
return(0);
}
Replies to Untitled
Title |
Name |
Language |
UNIX |
When |
Re: Untitled |
Commodious Meerkat |
text |
1496039797 |
6 Years ago. |
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}