int main(int argc, char** argv) { int size_of_board; //BOARD'IN BUYUKLUGU char cells[21][21]; //CHAR TIPINDE 2D ARRAY int check_player_move=1; // PLAYERIN ANLAMLI HAREKETINI KONTROL int player_can_move=1;//Playerin hamlesinin olup olmadigi kontrol edilir int computer_can_move=1;//Computerin hamlesinin olup olmadigi kontrol edilir //Gecerli bir size of board degeri girilene kadar, //kullanicidan size of board degeri istenir. size_of_board=board_size(); //Hucrelerin oyun basi degerleri verilir first_view(size_of_board, cells); //Guncel board ekrana cizilir. paint_board(size_of_board, cells); //Eger player veya computer hamle yapabiliyorsa while(player_can_move==1 || computer_can_move==1) { computer_can_move=1; //Player yapacak hamleye sahip mi degil mi player_can_move=does_player_have_move(size_of_board, cells); //Eger Player Hamle yapabiliyorsa if(player_can_move) { while(check_player_move) { //Player Hareketi //Legal bir hareket girilene kadar donguden cikmaz check_player_move=for_player_move(size_of_board, cells); } check_player_move=1; //Guncel board ekrana cizilir. paint_board(size_of_board, cells); } //Computer Hareketi for_computer_move(size_of_board, cells, &computer_can_move); //Guncel board ekrana cizilir. paint_board(size_of_board, cells); cout <<"\n"; } //Skor Yazilir scoreboard(size_of_board, cells); return 0; }
static void paint_screen(void) { GrContext *grc; paint_board(&brd); paint_button_group(bgact); paint_board(&brdimg); grc = GrCreateSubContext(brdimg.x + 4, brdimg.y + 4, brdimg.x + brdimg.wide - 5, brdimg.y + brdimg.high - 5, grcglob, NULL); if (bgact == &bgp1) GrLoadContextFromPnm(grc, "pnmtest.ppm"); else GrLoadContextFromPnm(grc, "pnmtest2.ppm"); GrDestroyContext(grc); the_info(500, 215); drawing(400, 290, 200, 150, BROWN, DARKGRAY); the_title(500, 330); paint_foot("Hold down left mouse buttom to see a comment"); }
// // 函数: WndProc(HWND, UINT, WPARAM, LPARAM) // // 目的: 处理主窗口的消息。 // // WM_COMMAND - 处理应用程序菜单 // WM_PAINT - 绘制主窗口 // WM_DESTROY - 发送退出消息并返回 // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // 分析菜单选择: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; case ID_HELP_SPLASHSCREEN: ghDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SPLASH), 0, Splash); ShowWindow(ghDlg, SW_SHOW); break; case ID_CONTROL_YIELD: if (!eval_null()){ MessageBoxA(0, "You could only yield before a game start.", "Yield", 0); break; } mainboard[7][7] = 1; paint_board(hWnd); break; case ID_CONTROL_RESTART: clear_board(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT:{ Graphics *myGraphics; Pen *myPen; hdc = BeginPaint(hWnd, &ps); // TODO: 在此添加任意绘图代码... myGraphics = new Graphics(hdc); myPen = new Pen(Color(255, 0, 0, 0), 1); myGraphics->DrawRectangle(myPen, Rect(400, 20, 20, 20)); for (int i = 0; i < 375; i += 25) myGraphics->DrawLine(myPen, 20, 20 + i, 370, 20 + i); for (int i = 0; i < 375; i += 25) myGraphics->DrawLine(myPen, 20 + i, 20, 20 + i, 370); delete myGraphics; delete myPen; EndPaint(hWnd, &ps); paint_board(hWnd); } break; case WM_DESTROY: GdiplusShutdown(gdiplusToken); PostQuitMessage(0); break; case WM_LBUTTONDOWN: board_clicked(hWnd, LOWORD(lParam), HIWORD(lParam)); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }