⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javatuixiangzi.txt

📁 Java代码做的推箱子小游戏
💻 TXT
📖 第 1 页 / 共 2 页
字号:
         TextOut(hdc,311,14,itoa(g_chspeed,buff,10),-1);
         TextOut(hdc,310,55,itoa(sumofstep,buff,10),-1);
   //TextOut(hdc,340,114,buff,-1);
    sprintf(buff,"Time %02d:%02d:%02d", dtime.hour, dtime.min, dtime.sec);
   TextOut(hdc,300,125,buff,-1);
   //TextOut(hdc,320,134,itoa(N,buff,10),-1);
   if (g_minstep==(UINT)(-1))
   {
    TextOut(hdc,362,55,"N/A",-1);
   }
   else
   {
    TextOut(hdc,362,55,itoa(g_minstep,buff,10),-1);
   }
   
   EndPaint(hwnd, &ps);

   if (jumptheSpeed())
   {
    if (sumofstep<g_minstep)
     {
      if ((fp=fopen(PLAY_RECORD_PATH,"r+"))==NULL)
      {
       printf_0("file open fail!\n");
       return FALSE;
      }
      fseek(fp,(g_chspeed-1)*sizeof(Playrecord),SEEK_SET);
      if (fwrite(&sumofstep,sizeof(int),1,fp)==0)
      {
       printf_0("save record failed!");
      }
      if (fwrite(&dtime,sizeof(Datetime),1,fp)==0)
      {
       printf_0("save record failed!");
      }
      fclose(fp);

     }
    if (FREE_MODE_FLAG==FALSE &&(g_chspeed+1)>g_chspeedpassmax)
     {
      //FREE_MODE_FLAG==FALSE;
      //GAME_START_FLAG=FALSE;
      //EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON),FALSE); 
      //EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON),FALSE); 
      g_chspeedpassmax=g_chspeed+1;
      if ((fp=fopen(PASSMODE_PATH,"wb"))==NULL)
      {
       printf_0("open file failed!");
       return FALSE;
      }
      if (fwrite(&g_chspeedpassmax,sizeof(int),1,fp)==NULL)
      {
       printf_0("save record failed!");
      }
      fclose(fp);

     }
              if (FREE_MODE_FLAG==FALSE && g_chspeed<84)
     {   
      
         rec=MessageBox( NULL,"恭喜过关了!是否进入下一关?","提示 ",MB_YESNO|MB_ICONQUESTION);
      if (rec==6)
      {     
       g_chspeed++;
       initGame();
       memset(&dtime,0,sizeof(Datetime));
       sumofstep=0;
       PostMessage(hwnd,WM_PAINT,NULL,NULL);
       KillTimer(hwnd,1043);
       GAME_START_FLAG=FALSE;
       EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON ),TRUE); 
       EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON ),TRUE); 
      

      }
      else
      {
        g_gameWd->dwNextwdID=GAME_LIST_WND_ID;
        SendMessage(g_gameWd->pMainwd->hMainWnd, WM_CLOSE, 1, 0);
        return FALSE;
         
      }

     }

    // return TRUE;

    if (FREE_MODE_FLAG==FALSE && g_chspeed==84)
    {
      rec=MessageBox( NULL,"恭喜您,已全部通关了!是否返回第一关?","提示",MB_YESNO|MB_ICONQUESTION);
                  if (rec==6)
      {
       g_chspeed=1;
       initGame();
       memset(&dtime,0,sizeof(Datetime));
       sumofstep=0;
           PostMessage(hwnd,WM_PAINT,NULL,NULL);
       KillTimer(hwnd,1043);
       GAME_START_FLAG=FALSE;
       EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON ),TRUE); 
       EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON ),TRUE); 
         

      }
     else
      {
        g_gameWd->dwNextwdID=GAME_LIST_WND_ID;
        SendMessage(g_gameWd->pMainwd->hMainWnd, WM_CLOSE, 1, 0);
        return FALSE;

         
      }
    }

    if (FREE_MODE_FLAG==TRUE && g_chspeed<84 )
    {
     rec=MessageBox( NULL,"恭喜过关了!是否进入下一关?","提示",MB_YESNO|MB_ICONQUESTION);
      if (rec==6)
      {     
       g_chspeed++;
       initGame();
       memset(&dtime,0,sizeof(Datetime));
       sumofstep=0;
       PostMessage(hwnd,WM_PAINT,NULL,NULL);
       KillTimer(hwnd,1043);
       GAME_START_FLAG=FALSE;
       EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON ),TRUE); 
       EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON ),TRUE); 
      
      } 
      else
      {
        g_gameWd->dwNextwdID=GAME_LIST_WND_ID;
        SendMessage(g_gameWd->pMainwd->hMainWnd, WM_CLOSE, 1, 0);
        return FALSE;

      }
      
    }
    return TRUE;

    if (FREE_MODE_FLAG==TRUE && g_chspeed==84)
    {
     rec=MessageBox(NULL,"恭喜您,已全部通关了!是否返回第一关?","提示",MB_YESNO|MB_ICONQUESTION);
     if (rec==6)
     {
      g_chspeed=1;
      initGame();
      memset(&dtime,0,sizeof(Datetime));
      sumofstep=0;
      PostMessage(hwnd,WM_PAINT,NULL,NULL);
      EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON ),TRUE); 
      EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON ),TRUE); 
     }
     else
      {
        g_gameWd->dwNextwdID=GAME_LIST_WND_ID;
        SendMessage(g_gameWd->pMainwd->hMainWnd, WM_CLOSE, 1, 0);
        return FALSE;

      }

    }
    //return TRUE;

   } 
   
   return TRUE;
    case WM_COMMAND:
   switch(LOWORD(wParam))
   {
     case ID_REGRET_BUTTON:
         if(HIWORD(wParam) == BN_CLICKED)
      {              
                   SendMessage(hwnd, WM_    return TRUE;

   case VK_PRIOR:
            if (GAME_START_FLAG==FALSE)
            {
     if (g_chspeed==1 && g_chspeedpassmax==84)
      {
       g_chspeed=84;
       initGame();
       memset(&dtime,0,sizeof(Datetime));
       sumofstep=0;
       fstep=0;
      
       PostMessage(hwnd,WM_PAINT,(WPARAM)NULL,(LPARAM)NULL);
     //   KillTimer(hwnd,1043);
       return TRUE;
      }
      if (g_chspeed>1)
      {
       g_chspeed--;
       memset(&dtime,0,sizeof(Datetime));
       sumofstep=0;
       fstep=0;
       initGame();
       PostMessage(hwnd,WM_PAINT,(WPARAM)NULL,(LPARAM)NULL);
    //    KillTimer(hwnd,1043);
       return TRUE;
      }
    
     
     return FALSE;
            }
   default:
    return TRUE;
   }

   if (GAME_START_FLAG==FALSE)
    {
     memset(&dtime,0,sizeof(Datetime));
     GAME_START_FLAG=TRUE;
     SetTimer(hwnd,1043,1000,NULL);
     SetTimer(hwnd,1044,100,NULL);
     EnableWindow(GetDlgItem( hwnd, ID_PRESTEP_BUTTON ),FALSE); 
     EnableWindow(GetDlgItem( hwnd, ID_NEXTSTEP_BUTTON ),FALSE); 
    }

   if (g_manstate==MAN_QUIET)
    {
     g_manstate=MAN_MOVE;
     SendMessage(hwnd,WM_PAINT,0,0);
     timercount=0;
    }

   if (g_manstate==MAN_THINK)
    {
     g_manstate=MAN_MOVE;
     SendMessage(hwnd,WM_PAINT,0,0);
     timercount=0;
    }

   if (g_manstate==MAN_MOVE && timercount>=1200)
    {
     g_manstate==MAN_THINK;
     SendMessage(hwnd,WM_PAINT,0,0);
     timercount=0;

    }

   if (timercount<5 && g_manstate==MAN_MOVE)
    {
     g_manstate==MAN_QUIET;
     timercount=0;
    }

    if(getMap(manf_p) == N_AIM ||getMap(manf_p) == N_space) 
    {
     sumofstep++;
     Savedata();
     moveMan(deltax, deltay);
    }      
    else if((getMap(manf_p) == N_BOX_OK||getMap(manf_p) == N_BOX)
               &&(getMap(manff_p) == N_space || getMap(manff_p) == N_AIM))
    {
     sumofstep++;
     Savedata();
     moveBox(manf_p, manff_p);
     moveMan(deltax, deltay);
    }

     PostMessage(hwnd,WM_PAINT,NULL,NULL);
    return TRUE;
  
case WM_LBUTTONDOWN:
    LButtonDown_Flag=TRUE;
    return TRUE;
     case WM_LBUTTONUP:
      if (GAME_START_FLAG==FALSE)
    {
     memset(&dtime,0,sizeof(Datetime));
//     GAME_START_FLAG=TRUE;
//     SetTimer(hwnd,1043,1000,NULL);
    }
  
    if (LButtonDown_Flag==TRUE)
    {
     LButtonDown_Flag=FALSE;
     CursorPoint.x=LOWORD(lParam);
     CursorPoint.y=HIWORD(lParam);
     CursorPointNum.x=(CursorPoint.x-startpointx)/manwidth ;
     CursorPointNum.y=(CursorPoint.y-startpointy)/manwidth ;
     deltax=man_p.x-CursorPointNum.x;
     deltay=man_p.y-CursorPointNum.y;
         if (deltax == 0 && deltay == 1)
      {
       PostMessage(hwnd,WM_KEYDOWN,VK_UP,0L);
      }
      else if (deltax == 0 && deltay == -1)
      {
        PostMessage(hwnd,WM_KEYDOWN,VK_DOWN,0L);
      }

      else if (deltax == 1 && deltay == 0)
      {
        PostMessage(hwnd,WM_KEYDOWN,VK_LEFT,0L);
      }
     else if (deltax == -1 && deltay == 0)
      {
        PostMessage(hwnd,WM_KEYDOWN,VK_RIGHT,0L);
      }
         
      return TRUE;
    }
    return TRUE;
       case VK_RETURN:
       g_gameWd->dwNextwdID=GAME_START_WND_ID;
          SendMessage(g_gameWd->pMainwd->hMainWnd, WM_CLOSE, 1, 0);
     return 0;
     
    case WM_DESTROY:
  
     if (FREE_MODE_FLAG==TRUE)
     {
      if ((fp=fopen(FREEMODE_PATH,"wb"))==NULL) //wb or wb+
      {
       printf_0("open file failed!");
       return FALSE;
      }
      else
      {
       fwrite(&g_chspeed,sizeof(int),1,fp);
       fclose(fp);
      }
     }

    g_gameWd->dwNextwdID = GAME_LIST_WND_ID;
    KillTimer(hwnd,1043);
    KillTimer(hwnd,1044);
    return TRUE; 

     default:
    return DefWindowProc(hwnd,msg, wParam,lParam);
   
}
    return 0;

}
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -