bubble.cpp
上传用户:junwei_58
上传日期:2007-05-15
资源大小:79k
文件大小:2k
源码类别:

其他智力游戏

开发平台:

Visual C++

  1. #define BUBBLE_CPP
  2. #include "game.h"
  3. int problem;
  4. char *problemStr[5]={
  5. " ",//no problem for zero
  6. "I'm sorry! This version does not have the function.",
  7. " "," "," ",
  8. };
  9. #include "bubble.c"
  10. void main(){
  11. Image titleI;
  12. int m,n,p=0;
  13. int r1,r2,c;
  14. time_t t;
  15. srand((unsigned) time(&t));
  16. if(!loadtop10())return;
  17. installTimer();
  18. installKeyFunc();
  19. inGame=KEYNEW;
  20. printf("Welcome to Bubble nn");
  21. printf("Left and Right to turn the snake's directionnUp to speed upn");
  22. printf("Enjoy yourself!nAny key to start...");
  23. getch_Key();
  24. //*
  25. //initalize data and symbles:
  26. ob=new object;
  27. players=0;// at first only 1 player joined in
  28. musicON=1;
  29. soundON=1;
  30. initVBEMode(0x103);
  31. setPalette();
  32. titleI.width=80;  titleI.height=16;
  33. titleI.bytesperpixel=bytesperpixel;
  34. char buf[1440];
  35. titleI.imgbuf=buf;
  36. char title2[]="Bubble";
  37. setcolor(TEXTCOLOR);
  38. setbkcolor(BKGROUNDCOLOR);
  39. //Imgctextxy(titleI,0,0,title,0);
  40. Imgtextxy(titleI,0,0,title2,0);
  41. textxy(300,240,"PRESS ANY KEY TO START",0);
  42. // putimage(300,200,titleI,COPY_PUT);
  43. while(wait_Key()){
  44. r1 = (rand() % 70);
  45. r2 = (rand() % 16);
  46. c=(int)Imggetpixel(titleI,r1,r2);
  47. if((p%13000)==0){
  48. n=(rand()%16)*10;
  49. m=(rand()%16)*10;
  50. }
  51. p++;
  52. if(c==TEXTCOLOR){
  53. r1*=2;
  54. r2*=2;
  55. r1+=rand()%2;
  56. c=rand()%10+n;// 32 ~ 63
  57. setpixel(r1+334,r2+200,c);
  58. c=rand()%10+m;
  59. setpixel(r1+331,r2+197,c);
  60. delay(1);
  61. }
  62. }
  63. smoothout();
  64. setcolor(BORDERCOLOR);
  65. clrScr(BKGROUNDCOLOR);
  66. MainMenu.key();// display menu and start game;*/
  67. //normal exit:
  68. savetop10();
  69. exitgame();
  70. }
  71. void thegameloop(){
  72. ready_GO();
  73. rectant(XMAGIN,YMAGIN,BALLSIZE*TABLEWIDTH+BALLSIZE/2+1,BALLSIZE*(TABLEHEIGHT-1));
  74. lineH(XMAGIN-30,YMAGIN+BALLSIZE*15,30);
  75. lineH(XMAGIN+BALLSIZE*TABLEWIDTH+BALLSIZE/2,YMAGIN+BALLSIZE*15,30);
  76. ob->start();
  77. if(players==1||players==2)ob2->start();
  78. gameover=0;
  79. seekActions();
  80. checktop10(ob->getscore(),0);
  81. if(players==1||players==2){
  82. checktop10(ob2->getscore(),1);
  83. }
  84. }