| | |
this is a small game using mouse
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 4
Reputation:
Solved Threads: 0
this is the small game using mouse device, I write it in turbo C++, it is a example about using asembler in Turbo C++, but when I write it in Visual C++ 6.0, It haves many error, I think it is a big difficult. Could you help me solve this problem, thank you very much:cheesy:
C++ Syntax (Toggle Plain Text)
#include"stdio.h" #include"dos.h" #include"conio.h" #include"stdlib.h" #define INT_MOUSE 0x33 #define MOUSE_INIT 0x00 #define MOUSE_SHOW 0x01 #define MOUSE_GET_POSITION 0x03 #define MOUSE_Y_LIMIT 0x08 #define INT_VIDEO 0x10 #define CURSOR_SET 0X01 #define CURSOR_GET 0X03 #define BELL 7 #define PERIOD 25 unsigned long int tg_giay_100(void); void main() { int mouse_status; char ch; unsigned long int t_bd,t_ht; int cat_x,cat_y,mouse_x,mouse_y; int raw_mouse_x,raw_mouse_y; int cursor_size; int old_mouse_x,old_mouse_y; _AX=MOUSE_INIT; geninterrupt(INT_MOUSE); mouse_status=_AX; if ( mouse_status!=-1 ) { fprintf(stderr,"no mouse device\n");exit(1); } _AX=MOUSE_Y_LIMIT;_CX=5*8;_DX=25*8; geninterrupt(INT_MOUSE); clrscr(); puts(" press q to quit"); _AH=CURSOR_GET; geninterrupt(INT_VIDEO); cursor_size=_CX; _AH=CURSOR_SET; _CX=0x0f0f; geninterrupt(INT_VIDEO); old_mouse_x=old_mouse_y=-1; cat_x=random(80)+1;cat_y=random(24)+1; gotoxy(cat_x,cat_y);putch('C'); t_bd=tg_giay_100(); while ( 1 ) { if ( kbhit() ) { ch=getch(); if ( ch=='q' ) break; else putch(BELL); } _AX=MOUSE_GET_POSITION; geninterrupt(INT_MOUSE); raw_mouse_x=_CX;raw_mouse_y=_DX; mouse_x=raw_mouse_x/8+1;mouse_y=raw_mouse_y/8+1; if ( (mouse_x!=old_mouse_x)||(mouse_y!=old_mouse_y) ) { if ( old_mouse_x!=-1 ) { gotoxy(old_mouse_x,old_mouse_y); putch(' '); } gotoxy(mouse_x,mouse_y);putch('M'); old_mouse_x=mouse_x; old_mouse_y=mouse_y; } if ( mouse_x==cat_x&&mouse_y==cat_y ) { gotoxy(50,1); cputs("quit"); break; } t_ht=tg_giay_100(); if ( t_ht-t_bd>PERIOD ) { gotoxy(cat_x,cat_y);putch(' '); cat_x=random(80)+1; cat_y=random(21)+5; gotoxy(cat_x,cat_y);putch('C'); t_bd=t_ht; } } _AH=CURSOR_SET; _CX=cursor_size; geninterrupt(INT_VIDEO); } unsigned long int tg_giay_100(void) { static struct time ti; unsigned long int t; gettime(&ti); t=((ti.ti_hour*60+ti.ti_min)*60+ti.ti_sec)*100+ti.ti_hund; return t; }
That's one of the many many dangers of writing programs in Turbo C/C++ -- it ain't portable to other operating systems or other compilers! You need to do a total, 100% rewrite of that program if you want to compile it with any modern 32-bit compiler because none of them -- not one -- supports those old, ancient, obsolete Turbo C functions. You have one of two choices: (1) stick with Turbo C and put of with all its limitations, or (2) completly rewrite the program.
![]() |
Similar Threads
- C++ game? (C++)
- HP Pavilion DVdv2000 not booting..kinda (Troubleshooting Dead Machines)
- school project: simple C++ game (need help with keyboard input) (C++)
- Introducing Mousejockey (Community Introductions)
- Possible Trojan? (Viruses, Spyware and other Nasties)
- No Connectivity Through Network (Networking Hardware Configuration)
- 10 line text file (Java)
- CPU is fully used up by a single process, HELP (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: please help urgent!!!
- Next Thread: Challenging yet simple C++ help needed
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






