delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/12/05:03:26

From: Jay Slanker <slanker505 AT usa DOT net>
Newsgroups: rec.games.programmer,alt.msdos.programmer,comp.os.msdos.djgpp
Subject: Text Mode Program: Help Please..
Date: Sun, 07 Sep 1997 15:59:33 -0500
Organization: AT&T WorldNet Services
Lines: 67
Message-ID: <5uv4i5$t3u@bgtnsc02.worldnet.att.net>
NNTP-Posting-Host: 207.146.213.36
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am just trying to make a simple text mode, move around demo.  Having a
Zero move around the screen when you press 8(up), 6(right), 4(left), and
5(down).  It compiles ok, but then when run, if you press any of the
above keys it repeptitively prints the zero key until you end it(press
escape). Please if anyone see's the problem in the following code,
e-mail me at: slanker505 AT usa DOT net.  Thanks in advance.  Reply by e-mail
please..

/* Begin Code
*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>

main(){
                int x_loc,y_loc;   /* X and Y location of the zero */
                char your_character,control; /* the zero and the
variable to get the keypress */
                your_character=48; /* Ascii code for zero 0    */
                x_loc=10; /* Starting X location */
                y_loc=10; /* Starting Y location */
                clrscr();  /* Clear the screen */
                gotoxy(x_loc,y_loc);
                printf("%c",your_character);
           do{

                if(kbhit())
                          control=getch();

                     if(control=='8'){
                                                clrscr();
                                                --x_loc;
                                                gotoxy(x_loc,y_loc);

printf("%c",your_character);
                                   }

                     if(control=='4'){
                                                clrscr();
                                                --y_loc;
                                                gotoxy(x_loc,y_loc);

printf("%c",your_character);
                                   }

                     if(control=='6'){
                                                clrscr();
                                                ++y_loc;
                                                gotoxy(x_loc,y_loc);

printf("%c",your_character);
                                   }

                     if(control=='5'){          clrscr();
                                                ++x_loc;
                                                gotoxy(x_loc,y_loc);

printf("%c",your_character);
                                     }
                } while(control!=27);

                clrscr();
                return 0;

      }


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019