Movement in c++ dos [Archive] - C Board

PDA

View Full Version : Movement in c++ dos


Blizzarddog
01-12-2003, 07:32 PM
Can i make characters move on a dos screen without:


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";
}

dizolve
01-12-2003, 08:15 PM
Look up SetConsoleCursorPosition(), that should do what you need.

Frobozz
01-13-2003, 12:03 AM
I use conio.h (mostly because my Windows and DOS compilers both have it) and therefore use: gotoxy(x, y);


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).

gamer
01-13-2003, 01:10 AM
You shoot look at Dos Programming
:cool:

Travis Dane
01-13-2003, 05:48 AM
It's Win32 Console not DOS,
Blizzarddog plz tell us what compiler youre using

gamer
01-14-2003, 09:53 AM
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

Blizzarddog
01-14-2003, 10:32 AM
Dev C++ with Gnu.
What do i need to include for gotoxy(x, y)?

thedumbmutt
01-14-2003, 12:08 PM
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:


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.

vasanth
01-15-2003, 10:19 AM
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...


# 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;
}