![](tongue.gif)
ASCII Movement
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";
}
}
}
![](tongue.gif)
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]
erase the first
ie:
gotoxy(px, py);
putch('' '');
movement statements (IF''s)
gotoxy(px, py);
putch(''@'');
that''s it
Arkon
[QSoft Systems]
Good job Arkon.
Thank you very much!![](smile.gif)
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?
Thank you very much!
![](smile.gif)
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..
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.
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.
June 03, 2001 06:34 AM
#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
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
Popular Topics
Advertisement
Recommended Tutorials
Advertisement