Movement in c++ dos

This is a discussion on Movement in c++ dos within the Game Programming forums, part of the General Programming Boards category; Can i make characters move on a dos screen without: Code: include <iostream> using namespace std; int main() { cout ...

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Movement in c++ dos

    Can i make characters move on a dos screen without:

    Code:
    include <iostream>
    
    using namespace std;
    
    int main()
    {
    cout << "*************************\n";
    cout << "*           T                                 *\n";
    cout << "*                                              *\n";
    cout << "*************************\n";
    system("CLS");
    cout << "*************************\n";
    cout << "*                                              *\n";
    cout << "*           T                                  *\n";
    cout << "*************************\n";
    }
    This war, like the next war, is a war to end war.

  2. #2
    Registered User dizolve's Avatar
    Join Date
    Dec 2002
    Posts
    68
    Look up SetConsoleCursorPosition(), that should do what you need.

    &nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;___&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;/\&nbsp;\&nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;/\_&nbsp;\&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;\_\&nbsp;\/\_\&nbsp;&nbsp;____&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_ __\//\&nbsp;\&nbsp;&nbsp;&nbsp;&nbsp;__&nbsp;&nbsp;__&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;__&nbsp;&nbsp;&nbsp;
    &nbsp;/'_`&nbsp;\/\&nbsp;\/\_&nbsp;,`\&nbsp;&nbsp;/&nbsp;__`\\&nbsp;\&nbsp;\&nbsp;&nbsp;/\&nbsp;\/\&nbsp;\&nbsp;&nbsp;/'__`\&nbsp;
    /\&nbsp;\_\&nbsp;\&nbsp;\&nbsp;\/_/&nbsp;&nbsp;/_/\&nbsp;\_\&nbsp;\\_\&nbsp;\_\&nbsp;\&nbsp;\_/&nbsp;|/\&nbsp;&nbsp;__/&nbsp;
    \&nbsp;\___,_\&nbsp;\_\/\____\&nbsp;\____//\____\\&nbsp;\___/&nbsp;\&nbsp;\____\
    &nbsp;\/__,_&nbsp;/\/_/\/____/\/___/&nbsp;\/____/&nbsp;\/__/&nbsp;&nbsp;&nbsp;\/____/
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;I&nbsp;have&nbsp;a&nbsp;BAD&nbsp;figlet& nbsp;addiction.

  3. #3
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    I use conio.h (mostly because my Windows and DOS compilers both have it) and therefore use: gotoxy(x, y);

    Code:
    void drawchar(x, y, icon)
    {
      gotoxy(x, y);
      putch(icon);
    }
    My compiler also has color support in conio.h, but I know VC++ doesn't (I've already tried).

  4. #4
    Registered User
    Join Date
    Jan 2003
    Posts
    56

    Cool

    You shoot look at Dos Programming

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    It's Win32 Console not DOS,
    Blizzarddog plz tell us what compiler youre using

  6. #6
    Registered User
    Join Date
    Jan 2003
    Posts
    56

    Cool answer

    i have instalt a compiler but it doesn't workso i cot e other one but it's not working because it's c++ but it doeen't do it good

    compiler 1 : microsoft visual studio 6.0
    compiler 2 : dev-ccp

  7. #7
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Dev C++ with Gnu.
    What do i need to include for gotoxy(x, y)?
    This war, like the next war, is a war to end war.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    46
    hmm, conio isnt a standard ansi C function so it doesnt have to be there, but gotoxy is usually in conio. ALthough Ive noticed dev c++ is missing a few of those dos-like functions.

    why not try something like this:

    Code:
    unsigned char far *VidPtr=0xB8000000;
    
    int PutChar(int x, int y, unsigned char c)
    {
       *VidPtr[y*80+x]=c;
        return 0;
    }
    you can avoid having to deal with the blinking cursor, although I donno if this will work as a windows console program.
    Last edited by thedumbmutt; 01-14-2003 at 12:11 PM.
    mooooo@cooowwww.com

  9. #9
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    well if youa are using gotoxy you can do this..

    Every time you put a char on screen.. store x and y in a variable.. when displaying again clear the previous place..


    Or even sometin like this will work...
    Code:
    # include <iostream.h>
    # include <conio.h>
    
    int main()
    {
    clrscr();
    
    for(int i=0;i<20;i++)
    {
    gotoxy(i,10);
    cout<<"t";
    delay(100);
    
    gotoxy(i,10);
    cout<<" ";
    
    }
    
    
    retirn 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File systems?? (Winxp -> DOS)
    By Shadow in forum Tech Board
    Replies: 4
    Last Post: 01-06-2003, 09:08 PM
  2. winver, winminor, winmajor can it be found from dos?
    By ronin in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-02-2002, 11:32 AM
  3. real mode dos & win dos
    By scott27349 in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 08-19-2002, 07:15 AM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM
  5. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21