Advertisement

ASCII Movement

Started by June 02, 2001 10:36 AM
4 comments, last by mc3712 23 years, 8 months ago
I''m making Very Simple ASCII movement system. My compiler is DJGPP. I don''t know why the movement goes very weird if I try to erase the trace. Could someone test this code (also without the comments): Sorry for not so good English. #include #include int main() {   int x=10, x2=0, y=10, y2=0;   int move=0;   getch();   clrscr();   gotoxy(x,y);   cout << "@\b";   while(1)   {    move=getch();         if (move==''8'')         {          y2=y;          y--;          gotoxy(x,y);                 cout << "@\b";             //   gotoxy(x,y2); //TraceEraser 0.1a       //   cout << " \b";         }         if (move==''2'')         {          y2=y;          y++;          gotoxy(x,y);          cout << "@\b";      //    gotoxy(x,y2);      //    cout << " \b";         }         if (move==''4'')         {          x2=x;          x--;          gotoxy(x,y);          cout << "@\b";      //    gotoxy(x2,y);      //    cout << " \b";         }         if (move==''6'')         {          x2=x;          x++;          gotoxy(x,y);          cout << "@\b";      //    gotoxy(x2,y);      //    cout << " \b";         }    } }
before you draw your player
erase the first

ie:

gotoxy(px, py);
putch('' '');
movement statements (IF''s)
gotoxy(px, py);
putch(''@'');

that''s it


Arkon
[QSoft Systems]
Advertisement
Good job Arkon.
Thank you very much!

btw. two questions more:

1)How can I go back one step with putch(),
like I do with "\b" in cout.
Because the blinking cursor is one step to the right.

2)Does anyone know how to make that blinking cursor disappear?
1) Use a gotoxy to the position.
2) I know there is a way to do it, but I forget where I''ve seen it..
Hi!

Re: dissapearing of the cursor...

You have to put there some assembler instructions:

(sorry for the pascal syntax only... i''m not coding in c, but
you should be able to port it to c easily)

procedure hidecur; assembler; //Hides the cursor
asm
mov ah, 01h;
mov ch, 20h;
mov cl, 00h;
int 10h;
end;

procedure showcur; assembler; //Shows the cursor
asm
mov ah, 01h;
mov ch, 06h;
mov cl, 07h;
int 10h;
end;

m.
#include

void _setcursortype(int _type);

_NOCURSOR : No cursor is displayed.
_SOLIDCURSOR : A solid block is displayed.
_NORMALCURSOR : Normal underline cursor is displayed.

havent tried it, but should work.
check in the djgpp libc reference

good luck

This topic is closed to new replies.

Advertisement