/**************/ /* tictac.c */ /**************************************************************************** PROGRAM: tictac.c Windows: Win 3.1 (& WIN32 ? ) PURPOSE: Pelaa ruksipeliä. Editor: Vesa Lappalainen 16.10.1995 PROJECT: tictac.c, tictac.rc, tictac.def ALI\tabhand.c, ALI\mdialog.c, ALI\tausta.c ****************************************************************************/ #include #include #include "tictac.rh" #include "tabhand.h" #include "tausta.h" #define MAXKOKO 9 typedef enum { TYHJA, RUKSI, PALLO, MAXVEMPAIMIA } tVuorossa; typedef struct { int xkoko; int ykoko; tVuorossa vuorossa; int lauta[MAXKOKO][MAXKOKO]; HBITMAP hbKuva[MAXVEMPAIMIA]; } tTicTac; static tTicTac G = {3,3,RUKSI}; static char *bNimet[] = {"TYHJA","RUKSI","PALLO",NULL}; /***************************************************************************/ //TblClassSWindowMAIN("TicTacClass",NULL,"Tic Tac for Windows",MsgTbl,0); TblDlgMAIN("PIKA","TICTAC",MsgTbl); /***************************************************************************/ #define ALKU 39 #define KOKO 30 int alusta_lauta(void) { int xi,yi; for (yi=0; yihWnd,1000 + xi + yi*10); DestroyWindow(nhWnd); } } return 0; } static int luo_nappulat(tMSGParam *msg) { int xi,yi,x,y=ALKU; HINSTANCE hInstance = GetWindowInstance(msg->hWnd); for (yi=0; yihWnd,(HMENU)(1000 + xi + yi*10), hInstance,NULL); x += KOKO; } y += KOKO; } return alusta_lauta(); } static EVENT WM_create(tMSGParam *msg) { int i; HINSTANCE hInstance = GetWindowInstance(msg->hWnd); for (i=TYHJA; ihWnd,msg->id); int xi = msg->id % 10; int yi = (msg->id % 100) / 10; if ( G.lauta[yi][xi] ) return 1; G.lauta[yi][xi] = G.vuorossa; if ( G.vuorossa == RUKSI ) { // SetDlgItemText(msg->hWnd,msg->id,"X"); G.vuorossa = PALLO; } else { // SetDlgItemText(msg->hWnd,msg->id,"O"); G.vuorossa = RUKSI; } InvalidateRect(nhWnd,NULL,TRUE); // EnableWindow(nhWnd,FALSE); // tarkista(G.lauta); return 0; } static EVENT WM_drawitem_NAPPULAT(tMSGParam *msg) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)(msg->lParam); int xi = dis->CtlID % 10; int yi = (dis->CtlID % 100) / 10; PiirraBittikartta(dis->hDC,G.hbKuva[G.lauta[yi][xi]],0,0); return 0; } static EVENT WM_close(tMSGParam *msg) { int i; (void) msg; for (i=TYHJA; i