Hey I'm new to C++, and I have a question.
I have gotten my hands on graph.h
I wanted to know how to be able to move objects using the arrow keys.
I have been able to move things in a vector with the conio.h getch() command, but it doesn't work in graphics...
Does anyone know how to do this?
For that You gotta Trap Keys.
Understand some concepts:
=============================
first of all all the data thats is typed goes to a keyboard buffer,through port 0x60.the data that forms the input through keyboard.
each time you press a key there are two things that are generated.
1)ASCII CODE
2)SCAN CODE
for each key there is an individual scan code.but ascii codes may be common.
here are few basic scan codes of the keys that you frequently require in your program.(all of these keys have ascii code=0)
1.)ALT-F 33
2)ESC 27
3)UP ARROW KEY 72
4)DOWN ARROW KEY 80
etc.
and here's the fucntion that you can use to help yourself out.(you willl be able to use this in graphics.,provided you have sufficient knowledge on how to define your own outtextxy(x,y,"XXXX") like functions.
int ascii,scan;
union REGS i,o;
getkey()
[
i.h.ah=0; /*SERVICE ROUTINE ZERO.*/
int86(21,&i,&o); //interrupt 21 inregs and outregs
ascii=o.h.al;
scan=o.h.ah;
}
the above stuff can be grasped easily i hope.
currently i am busy with my Z-DOS launch so i may may not be able to reply to your querries on time,but i will if i find some time.(which after a couple of days i hope i will;))
thanks.
bye!
also you can use the above stuff to make a GUI without a mouse.
But mouse makes it all more flexible.
are you familiar?
bye!
I haven't yet tried it but i'l ltake a look. Thanks!