K
kim
The c program is an example and should be correct.
I tried to compile the c file with MS studio 6.0. But failed with the
several err and warning messages. Does anyone know how to make it work?
Thanks.
Here is the c file:
/*file name way.c*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void put (int x,int y) {
textcolor(CYAN);
gotoxy(x,y);
cprintf(".");
sound(440);
delay(3);
nosound();
}
void snd (void){ // it was just an idea
sound(100);
delay(2);
nosound();
}
void main()
{
int x=1,y=2,ctr=0;
_setcursortype(_NOCURSOR); //just for eye comfort
clrscr();
gotoxy(1,1);
textcolor(WHITE);
cprintf("ESC to exit, use arrowkeys to control"); //directive
window(1,2,80,25); // setting moving area
put(x,y); // puting smiling face
while(ctr!=1)
switch(getch()){
//you can use kbhit here but i wrote just ex.
case 77: // write
if(x>=1 && x<79){
gotoxy(x,y);
cprintf(" ");
x++;
}
put(x,y);
snd();
break;
case 75: // left
if(x>1 && x<=80){
gotoxy(x,y);
cprintf(" ");
x--;
}
put(x,y);
snd();
break;
case 72: // up
if(y<=25 && y>2){
gotoxy(x,y);
cprintf(" ");
y--;
}
put(x,y);
snd();
break;
case 80: // down
if (y<24 && y>=2){
gotoxy(x,y);
cprintf(" ");
y++;
}
put(x,y);
snd();
break;
case 27: // quit
ctr=1;
break;
}
textcolor(7); //turn back to normal color
return(0);
}
I tried to compile the c file with MS studio 6.0. But failed with the
several err and warning messages. Does anyone know how to make it work?
Thanks.
Here is the c file:
/*file name way.c*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void put (int x,int y) {
textcolor(CYAN);
gotoxy(x,y);
cprintf(".");
sound(440);
delay(3);
nosound();
}
void snd (void){ // it was just an idea
sound(100);
delay(2);
nosound();
}
void main()
{
int x=1,y=2,ctr=0;
_setcursortype(_NOCURSOR); //just for eye comfort
clrscr();
gotoxy(1,1);
textcolor(WHITE);
cprintf("ESC to exit, use arrowkeys to control"); //directive
window(1,2,80,25); // setting moving area
put(x,y); // puting smiling face
while(ctr!=1)
switch(getch()){
//you can use kbhit here but i wrote just ex.
case 77: // write
if(x>=1 && x<79){
gotoxy(x,y);
cprintf(" ");
x++;
}
put(x,y);
snd();
break;
case 75: // left
if(x>1 && x<=80){
gotoxy(x,y);
cprintf(" ");
x--;
}
put(x,y);
snd();
break;
case 72: // up
if(y<=25 && y>2){
gotoxy(x,y);
cprintf(" ");
y--;
}
put(x,y);
snd();
break;
case 80: // down
if (y<24 && y>=2){
gotoxy(x,y);
cprintf(" ");
y++;
}
put(x,y);
snd();
break;
case 27: // quit
ctr=1;
break;
}
textcolor(7); //turn back to normal color
return(0);
}