🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #2795

Can anyone give me a piece of advise??

#2795
From: FreeMan
Date: Wed, 19 Mar 2003 15:23
73 lines
2904 bytes
Can anyone help me to correct this programe, so that i can make the
character move to right when i press right key and when i press left key the
character will go to left.... and when i press 'w' a so call 'bullet' will
come out...
can anyone help?


#include <conio.c>
#define SPACE 32
#define X 88
#define KEY_LEFT 100
#define KEY_RIGHT 97
#define POWE 120
int check (int iChar);
int power (int iChar);
int main()
{
    int iChar;
    iChar = getch();/* Look at the help about getch */
    check(iChar);
    power(iChar);

getch();
return 0;
}

int check (int iChar)
{
    int x_pos=14;
    do
    {
    while(iChar == KEY_LEFT)
    {
        iChar = getch();
        x_pos++;
        gotoxy(x_pos-1,78);/* Erase character = back the cursor one step,
write a space */
        putchar(SPACE);
        gotoxy(x_pos,78);/* move cursor one or two step to the left */
        putchar(X);/* write back character w putchar */
    }
    while(iChar == KEY_RIGHT)
    {
        iChar = getch();
        x_pos--;
        gotoxy(x_pos+1,78);/* Erase character = back the cursor one step,
write a space */
        putchar(SPACE);
        gotoxy(x_pos,78);/* move cursor one or two step to the left */
        putchar(X);/* write back character w putchar */
    }
    }while(iChar !='Q');
}

int power (int iChar)
{
        int i,delay,y_pos=78;
        while(iChar == POWE)
        {
        for (i = 0; i < 24; i++)      //repeat 80 times
        {
                 iChar = getch();
                 y_pos--;               //increase X position
                 gotoxy(15,y_pos);    //at the previous X position
                 putchar(SPACE);        //output blank space to erase
previous X
                 gotoxy(15, y_pos-1);      //at the new X position
                 putchar(X);           //output new X
                 for (delay = 0; delay < 500000; delay++);

         }
         }
}
Technical Details
Message-ID: <3e788b79@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,5851655210089ecf,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-03-19 07:40:53 PST
From: "FreeMan" <p_family60@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Can anyone give me a piece of advise??
Date: Wed, 19 Mar 2003 23:23:20 +0800
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 203.169.82.85
Message-ID: <3e788b79@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048087417 203.169.82.85 (19 Mar 2003 07:23:37 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail