void HariMain(void) { char buf[214 * 82 * osak_getbuflen()], s[2]; int win, col; win = api_openwin(buf, 25 * 8 + 14, 3 * 16 + 34, -1, "LuckyNum"); api_boxfilwin(win, BPX, BPY, 25 * 8 + BPX, 3 * 16 + BPY, 0); api_putstrwin(win, BPX, BPY, 6, 12, "LuckyNumber="); api_putstrwin(win, BPX, 16 + BPY, 6, 12, "LuckyColor ="); api_putstrwin(win, BPX, 32 + BPY, 3, 17, "Good Luck!(^o^)/~"); srand(tomo_gettick()); /* seedを与える */ s[0] = '0' + rand() % 10; s[1] = '\0'; api_putstrwin(win, 13 * 8 + BPX, BPY, 6, 1, s); col = rand() % 9; /* Hariboteは明るい色が前に集まっているので変なループはいらない */ api_boxfilwin(win, 13 * 8 + BPX, 16 + BPY, 14 * 8 + BPX - 1, 32 + BPY - 1, col); while (api_getkey(1) != 0x0a); api_closewin(win); api_end(); }
void HariMain(void) { char buf[152 * 100], col; int win, timer; int bpx = 8, bpy = 26; win = api_openwin(buf, 152, 100, -1, "Mt.orz"); timer = api_alloctimer(); api_inittimer(timer, 128); for (;;) { for (col = 8; col < 16; col++) { if (col == 8) { col = 0; } /* OSASKのパレットとは微妙に違うため */ api_putstrwin(win, 7 * 8 + bpx, 0 + bpy, col, 3, "orz"); api_putstrwin(win, 5 * 8 + bpx, 16 + bpy, col, 7, "orz orz"); api_putstrwin(win, 3 * 8 + bpx, 2 * 16 + bpy, col, 11, "orz orz orz"); api_putstrwin(win, 8 + bpx, 3 * 16 + bpy, col, 15, "orz orz orz orz"); if (col == 0) { col = 8; } /* 上と同じ */ api_settimer(timer, 50); /* 0.5秒 */ if (api_getkey(1) != 128) { goto end; } } } end: api_closewin(win); api_end(); }
void HariMain() { int win, xsize = 400, ysize = 200; char win_buf[xsize * ysize]; api_initmalloc(); struct MOUSE_INFO *minfo; minfo = api_malloc(sizeof(struct MOUSE_INFO)); minfo->flag = -589; int counter = 0; int index = 0; char cbuf[20]; win = api_openwin((char *)win_buf, xsize, ysize, -1 /*ºÚÉ«*/, "minesweeper"); api_refreshwin(win, 0, 0, xsize-1, ysize-1); char s[20]; for(;;) { sprintf(cbuf, "%10d", counter); api_boxfilwin(win, 30, 30, 30 + strlen(cbuf) * 8, 30 + 16, 8/*ÁÁ»Ò*/); api_putstrwin(win, 30, 30, 0 /*ºÚÉ«*/, strlen(cbuf), cbuf); api_getmouse(1, minfo); if(minfo->flag == 1) { sprintf(s,"%5d %5d, [l m r] %d", minfo->x, minfo->y, minfo->btn); //sprintf(s,"%d", (int)minfo); if( (minfo->btn & 0x01) != 0 ){ s[14] = 'L'; } if( (minfo->btn & 0x02) != 0 ){ s[18] = 'R'; } if( (minfo->btn & 0x04) != 0 ){ s[16] = 'M'; } api_boxfilwin(win, 30, 50, 30 + 40 * 8, 50 + 16, 8/*ÁÁ»Ò*/); api_putstrwin(win, 30, 50, 0, strlen(s), s); minfo->flag = -1; } counter++; } api_free(minfo, sizeof(struct MOUSE_INFO)); api_closewin(win); api_end(); }
void HariMain(void) { char buf[416 * 52 * osak_getbuflen()], s[2]; int win, timer, i, curc = 0, curx = 8; win = api_openwin(buf, 416, 50, -1, "1Line"); timer = api_alloctimer(); api_inittimer(timer, 128); make_textbox(win, 8, 28, 400, 16); s[1] = '\0'; api_settimer(timer, 50); /* 0.5•b */ for (;;) { i = api_getkey(1); if (i == 128) { if (curc == 0) { /* On */ curc = 7; } else { /* Off */ curc = 0; } api_boxfilwin(win, curx, 43, 7 + curx, 43, curc); api_settimer(timer, 50); /* 0.5•b */ } if (i == 0x08) { /* BackSpace */ if (8 < curx) { api_boxfilwin(win, curx - 8, 28, curx + 7, 43, 7); curx -= 8; api_boxfilwin(win, curx, 43, 7 + curx, 43, curc); } } if (0x20 <= i && i <= 'z') { if (curx < 400) { api_boxfilwin(win, curx, 28 + 15, 7 + curx, 28 + 15, 7); s[0] = i; api_putstrwin(win, curx, 28, 0, 1, s); curx += 8; api_boxfilwin(win, curx, 28 + 15, 7 + curx, 28 + 15, curc); } } } api_closewin(win); api_end(); }
void HariMain(void) { char *buf; int win, i; api_initmalloc(); buf = api_malloc(160 * 100); win = api_openwin(buf, 160, 100, -1, "lines"); for (i = 0; i < 8; i++) { api_linewin(win + 1, 8, 26, 77, i * 9 + 26, i); api_linewin(win + 1, 88, 26, i * 9 + 88, 89, i); } api_refreshwin(win, 6, 26, 154, 90); for (;;) { if (api_getkey(1) == 0x0a) { break; //enter } } api_closewin(win); api_end(); }
void HariMain(void) { char *buf; int win, i, x, y; api_initmalloc(); buf = api_malloc(160 * 100); win = api_openwin(buf, 160, 100, -1, "walk"); api_boxfilwin(win, 4, 24, 155, 95, 0);/*黑色*/ x = 76; y = 56; api_putstrwin(win, x, y, 3, 1, "*");/*黄色*/ for (;;) { i = api_getkey(1); api_putstrwin(win, x, y, 0 , 1, "*"); /*用黑色擦除*/ if (i == '4' && x > 4) { x -= 8; } if (i == '6' && x < 148) { x += 8; } if (i == '8' && y > 24) { y -= 8; } if (i == '2' && y < 80) { y += 8; } if (i == 0x0a) { break; } /*按回车键结束*/ api_putstrwin(win, x, y, 3 , 1, "*");/*黄色*/ } api_closewin(win); api_end(); }
void HariMain(void) { char *buf; int win, i, x, y, timer; api_initmalloc(); buf = api_malloc(200 * 200); char* title; char keyflag[4]; char *last_direction; *last_direction = '4'; //snake struct snakeNode *head = api_malloc(sizeof(struct snakeNode)); head->preNode = NULL; head->posX = 75; head->posY = 55; head->moveDirection = 4; struct snakeNode *tail = head; //snake //food struct Food food; food.posX = 69; food.posY = 61; food.isEaten = 1;// not eaten; //food sprintf(title, "posX: %d, posY: %d, mp: %d", tail->posX, tail->posY, tail->moveDirection); //sprintf(title, "Hungry Snake"); win = api_openwin(buf, 200, 200, -1, title); timer = api_alloctimer(); api_inittimer(timer, 128); api_boxfilwin(win, 5, 25, 195, 195, 0); x = 75; y = 55; tail->posX = 75; tail->posY = 55; api_putstrwin(win, tail->posX, tail->posY, 3, 1, "*"); //scrnRefresher(win, tail, 3, "*"); for (;;) { i = *last_direction; scrnRefresher(win, tail, 0, "*"); // updateSnake(head); updateSnake(tail); scrnRefresher(win, tail, 3, "*"); //add food here foodInit(&food, win, 4, "+"); //add food here /*detecting*/ detecting(head, &tail, &food); delay(); //if (snakeLength < 10) {tail = addSegment(tail, &snakeLength);} wait(1, timer, keyflag, last_direction, head); } api_closewin(win); api_end(); }