Ascii character table and game programming. With C source.
Submitted By:
caglar
Rating:





(
Rate It)
// How you can use ASCII with arrow keys
// Written by Caglar Ulkuderner
// You can also use it whole other keys
// Check chtoas.c
#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();
}
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);
}