this is a small game using mouse

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 4
Reputation: nguyen duy khoi is an unknown quantity at this point 
Solved Threads: 0
nguyen duy khoi nguyen duy khoi is offline Offline
Newbie Poster

this is a small game using mouse

 
0
  #1
May 3rd, 2006
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:
  1. #include"stdio.h"
  2. #include"dos.h"
  3. #include"conio.h"
  4. #include"stdlib.h"
  5. #define INT_MOUSE 0x33
  6. #define MOUSE_INIT 0x00
  7. #define MOUSE_SHOW 0x01
  8. #define MOUSE_GET_POSITION 0x03
  9. #define MOUSE_Y_LIMIT 0x08
  10. #define INT_VIDEO 0x10
  11. #define CURSOR_SET 0X01
  12. #define CURSOR_GET 0X03
  13. #define BELL 7
  14. #define PERIOD 25
  15. unsigned long int tg_giay_100(void);
  16. void main()
  17. {
  18. int mouse_status;
  19. char ch;
  20. unsigned long int t_bd,t_ht;
  21. int cat_x,cat_y,mouse_x,mouse_y;
  22. int raw_mouse_x,raw_mouse_y;
  23. int cursor_size;
  24. int old_mouse_x,old_mouse_y;
  25. _AX=MOUSE_INIT;
  26. geninterrupt(INT_MOUSE);
  27. mouse_status=_AX;
  28. if ( mouse_status!=-1 )
  29. {
  30. fprintf(stderr,"no mouse device\n");exit(1);
  31. }
  32. _AX=MOUSE_Y_LIMIT;_CX=5*8;_DX=25*8;
  33. geninterrupt(INT_MOUSE);
  34. clrscr();
  35. puts(" press q to quit");
  36. _AH=CURSOR_GET;
  37. geninterrupt(INT_VIDEO);
  38. cursor_size=_CX;
  39. _AH=CURSOR_SET;
  40. _CX=0x0f0f;
  41. geninterrupt(INT_VIDEO);
  42. old_mouse_x=old_mouse_y=-1;
  43. cat_x=random(80)+1;cat_y=random(24)+1;
  44. gotoxy(cat_x,cat_y);putch('C');
  45. t_bd=tg_giay_100();
  46. while ( 1 )
  47. {
  48. if ( kbhit() )
  49. {
  50. ch=getch();
  51. if ( ch=='q' )
  52. break;
  53. else putch(BELL);
  54. }
  55. _AX=MOUSE_GET_POSITION;
  56. geninterrupt(INT_MOUSE);
  57. raw_mouse_x=_CX;raw_mouse_y=_DX;
  58. mouse_x=raw_mouse_x/8+1;mouse_y=raw_mouse_y/8+1;
  59. if ( (mouse_x!=old_mouse_x)||(mouse_y!=old_mouse_y) )
  60. {
  61. if ( old_mouse_x!=-1 )
  62. {
  63. gotoxy(old_mouse_x,old_mouse_y);
  64. putch(' ');
  65. }
  66. gotoxy(mouse_x,mouse_y);putch('M');
  67. old_mouse_x=mouse_x;
  68. old_mouse_y=mouse_y;
  69. }
  70. if ( mouse_x==cat_x&&mouse_y==cat_y )
  71. {
  72. gotoxy(50,1);
  73. cputs("quit");
  74. break;
  75. }
  76. t_ht=tg_giay_100();
  77. if ( t_ht-t_bd>PERIOD )
  78. {
  79. gotoxy(cat_x,cat_y);putch(' ');
  80. cat_x=random(80)+1;
  81. cat_y=random(21)+5;
  82. gotoxy(cat_x,cat_y);putch('C');
  83. t_bd=t_ht;
  84. }
  85. }
  86. _AH=CURSOR_SET;
  87. _CX=cursor_size;
  88. geninterrupt(INT_VIDEO);
  89. }
  90. unsigned long int tg_giay_100(void)
  91. {
  92. static struct time ti;
  93. unsigned long int t;
  94. gettime(&ti);
  95. t=((ti.ti_hour*60+ti.ti_min)*60+ti.ti_sec)*100+ti.ti_hund;
  96. return t;
  97. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,348
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1462
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: this is a small game using mouse

 
0
  #2
May 4th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC