int main() { int win, win2, win3; double t = 0, h = 2 * M_PI / 100, quit = 0, run = 1; double clr2 = 0, clr3 = 0; double r[6] = { 0 }; param_set prms = { &win, &win2, &win3, &F, &D, &B, &t, &h, &clr2, &clr3, &run, r }; e_ctrl ctrls[] = { {"Force", &F, 0.1, &init, &prms}, {"Dumping", &D, 0.01, &init, &prms}, {"Nonlinear", &B, 0.1, &init, &prms}, {"_Clear Phase", &clr2, 0, NULL, NULL}, {"_Clear Poincare", &clr3, 0, NULL, NULL}, {"_Run", &run, 0, NULL, NULL}, {"_Quit", &quit, 0, NULL, NULL}, }; int cwin; cwin = init_ctrls(ctrls, 7); win = gopen(2 * WD + 2 * MG, HT); win2 = gopen(WD + MG, HT); win3 = gopen(WD + MG, HT); window(win, 0, -HT / 2, 2 * WD + 2 * MG, HT / 2 - 1); window(win2, -(MG + WD) / 2, -HT / 2, (WD + MG) / 2 - 1, HT / 2 - 1); window(win3, -(MG + WD) / 2, -HT / 2, (WD + MG) / 2 - 1, HT / 2 - 1); winname(win2, "Phase chart"); winname(win3, "Poincare chart"); layer(win, 0, 1); layer(win2, 0, 1); layer(win3, 0, 1); gsetbgcolor(win, ECTRL_BGCOLOR); gsetbgcolor(win2, ECTRL_FGCOLOR); gsetbgcolor(win3, ECTRL_FGCOLOR); newcolor(win, ECTRL_FGCOLOR); newcolor(win2, ECTRL_BGCOLOR); newcolor(win3, "red3"); gclr(win2); gclr(win3); gsetnonblock(ENABLE); while (!quit) { int iscwin, type, button; double wx, wy; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 7, wx, wy, iscwin, type, button); if (run) { rk4fixv6(duffing, t, r, h); t += h; draw(&prms); } msleep(5); } gcloseall(); return 0; }
void game(void){//ゲーム内容 int j; gsetnonblock(ENABLE);//ノンブロッキングモードに while(1){ gclr(win);//画面消去 //防護壁のx座標設定(レベル5になるまで値変化) defence_x=rand()%400; if(defence_x > 320){//x座標が340を超えたら340以下の数を減らす defence_x -= rand()%320; } LEVEL5();//レベル5の動作 newpen(win, 1); level();// レベルの表記 timecount();//時間の表記 human();// 棒人間 input();//入力待ち for(i=0; i<kosu; i++){ j = rand() % 16;// 色はランダム if(j < 3) j = j + rand() % 10 + 3;//色は3〜15のどれか if(a > 2){ //レベル3、4でときどき黒になって消えて見える if(rand()%5 == 0) j = 0; } newpen(win, j); fillrect(win, x_sq[i], y_sq[i], w_sq[i], h_sq[i]);//四角 fillcirc(win, x_circ[i], y_circ[i], r_circ[i], r_circ[i]);//円 LEVEL4();//レベル4のみ出る円(半分を埋め尽くす円) //落下速度dx,dy y_sq[i] -= dy; y_circ[i] -= dy; LEVEL2();//レベル2以上で変化させる } atari();//当たり判定 msleep(time);// 0.1秒止める count++; if(count/10 == 20*a){// カウント10回=約1秒とする dy += rand()%2+1;//速度変化は毎回変わる dx += rand()%2;//揺れる大きさ a++;//レベル kosu+=rand()%2+1;//増やす個数は毎回変わる dh+=3;//通常四角の縦幅変化量 dw+=3;//通常四角の横幅変化量 dr+=3;//通常円の半径の変化量 } } }
int main() { int win; double angle = 30, ratio = 5, run = 0, reset = 0, quit = 0; double t = 0, h = 0.1; double sx, sy, bx, by; param_set prms = { &win, &angle, &ratio, &t, &h, &run, &reset, &sx, &sy, &bx, &by }; e_ctrl ctrls[] = { {"Angle", &angle, 1, &init, &prms}, {"Ratio M/m", &ratio, 1, &init, &prms}, {"Step", &h, 0.01, &init, &prms}, {"_Run", &run, 0, NULL, NULL}, {"_Reset", &reset, 0, &init, &prms}, {"_Quit", &quit, 0, NULL, NULL} }; int cwin; cwin = init_ctrls(ctrls, 6); win = gopen(WD, HT); layer(win, 0, 1); gsetbgcolor(win, ECTRL_BGCOLOR); newcolor(win, ECTRL_BGCOLOR); init(&prms); gsetnonblock(ENABLE); while (!quit) { int iscwin, type, button; double wx, wy; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 6, wx, wy, iscwin, type, button); if (run) { t += h; step(&prms); draw(&prms); if (by < 0) run = 0; } msleep(40); } gcloseall(); return 0; }
int main() { int win; int cnt; float x_cen = X_CEN; float y_cen = Y_CEN; win = gopen(WIDTH,HEIGHT); puts("Move your mouse cursor on the window :-)"); /* レイヤの設定をする */ layer(win, 0,1); /* ノンブロックモードにする */ gsetnonblock(ENABLE); cnt = 0; while ( 1 ) { int win_ev; /* イベントのあったウィンドゥ番号 */ int type, b; /* イベントのタイプ,ボタン */ float r, x, y; win_ev = ggetevent(&type,&b,&x,&y) ; if ( win_ev == win ) { if ( type == MotionNotify ){ x_cen = x; y_cen = y; } else if ( type == ButtonPress ) { break; } } else { int i; if ( CNT_MAX <= cnt ) cnt = 0; gclr(win); for ( i=0 ; i < 4 ; i++ ) { r = pow((cnt+i*(CNT_MAX/4)) % CNT_MAX, 2)/DIV; drawcirc(win,x_cen,y_cen,r,r); } copylayer(win, 1,0); msleep(20); cnt++; } } gclose(win); return(0); }
int main(int argc, char **argv) { int win; double chbg = 0, quit = 0; double order = 8, rt = 0.8, ra = 15, rnd = 0.1; int bgcolor_r = 0x036 - 48, bgcolor_g = 0x064 - 48, bgcolor_b = 0x088 - 48; param_set prms = { &win, &order, &rt, &ra, &rnd, &chbg, &bgcolor_r, &bgcolor_g, &bgcolor_b }; e_ctrl ctrls[] = { {"Order", &order, 1, &remake_all, &prms}, {"Ratio", &rt, 0.01, &remake_all, &prms}, {"Angle", &ra, 1, &remake_all, &prms}, {"Randomness", &rnd, 0.01, &remake_all, &prms}, {"_Change bgcolor", &chbg, 0, &change_bgcolor, &prms}, {"_Quit", &quit, 0, NULL, NULL}, }; int cwin; cwin = init_ctrls(ctrls, 6); srand48(time(NULL)); win = gopen(L, L); window(win, -L / 2, 0, L / 2 - 1, L - 1); winname(win, "Snow falls on fractal tree"); layer(win, 0, 1); remake_all(&prms); gsetnonblock(ENABLE); while (!quit) { int type, button, iscwin; double wx, wy; if (order > 11) order = 12; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 6, wx, wy, iscwin, type, button); draw(win, prms.snowx, prms.snowy, MAXSNOW); msleep(40); } gcloseall(); return 0; }
int main(int argc, char **argv) { int win; double angle = 10, run = 0, reset = 0, quit = 0; double t = 0, h = 0.0001; param_set prms = {&win, &angle, &t, &run, &reset}; e_ctrl ctrls[] = { {"Initial Angle", &angle, 1, &init, &prms}, {"_Run", &run, 0, NULL, NULL}, {"_Reset", &reset, 0, &init, &prms}, {"_Quit", &quit, 0, NULL, NULL} }; int cwin; cwin = init_ctrls(ctrls, 4); gsetinitialbgcolor(ECTRL_BGCOLOR); win = gopen(WD, HT); newlinewidth(win, 6); window(win, -WD/2, -MG, WD/2, HT-MG); layer(win, 0, 1); init(&prms); gsetnonblock(ENABLE); while (!quit) { int iscwin, type, button; double wx, wy; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 4, wx, wy, iscwin, type, button); if (run) { rk4fixv6(rod, t, prms.r, h); t += h; if ((int)(t*RH) % (RH/100) == 0 ) { draw(&prms); msleep(10); } if (prms.r[0] >= M_PI/2) { run = 0; post(&prms); } } } gcloseall(); return 0; }
int main(int argc, char **argv) { int win, win2; double quit = 0, run = 1, t = 0, h = 0.05; double x0 = -40, IR = R / 3; param_set prms = { &win, &win2, &x0, &IR, &h, &run, &quit }; e_ctrl ctrls[] = { {"Step", &h, 0.01, NULL, NULL}, {"X0", &x0, 1, &init, &prms}, {"Inner radius", &IR, 1, &init, &prms}, {"_Run", &run, 0, NULL, NULL}, {"_Quit", &quit, 0, NULL, NULL} }; int cwin; cwin = init_ctrls(ctrls, 5); srand48(time(NULL)); win = gopen(2 * R, 2 * R); win2 = gopen(2 * R, R); window(win, -R, -R, R - 1, R - 1); gsetbgcolor(win, WCOLOR); gsetbgcolor(win2, ECTRL_FGCOLOR); newcolor(win, ECTRL_FGCOLOR); layer(win, 0, 1); layer(win2, 0, 1); gsetnonblock(ENABLE); init(&prms); run = 1; while (!quit) { int iscwin, type, button; double wx, wy; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 5, wx, wy, iscwin, type, button); if (run) { step(&prms); draw(&prms); t += h; } msleep(40); } gcloseall(); return 0; }
int main(int argc, char *argv[]) { int win; double R = 2 * L / 3, r_inc = 10, run = 0, reset = 0, quit = 0; double agg_prob = 1, mid, src_r = 0, new_r = 1, rem_r = 0; param_set prms = { &win, &R, &agg_prob, &r_inc, &run, &reset, &mid, &src_r, &new_r, &rem_r }; e_ctrl ctrls[] = { {"Size", &R, dR, &init, &prms}, {"Aggr. prob.", &agg_prob, 0.1, &init, &prms}, {"Radius Inc.", &r_inc, 1, &init, &prms}, {"_Run", &run, 0, NULL, NULL}, {"_Reset", &reset, 0, &init, &prms}, {"_Quit", &quit, 0, NULL, NULL} }; int cwin; cwin = init_ctrls(ctrls, 6); srand48(time(NULL)); win = gopen(L, L); gsetnonblock(ENABLE); init(&prms); while (!quit) { int iscwin, type, button; double wx, wy; iscwin = ggetxpress(&type, &button, &wx, &wy); display_ctrls(cwin, ctrls, 6, wx, wy, iscwin, type, button); if (run) draw(&prms); } gcloseall(); return 0; }
int main() { int win, i, j, k, m, key = 0; int arp[5] = { 0, 3, 1, 4, 2 }, ars[7] = { 0, 5, 3, 1, 6, 4, 2}; double pentagon[3][5], septagon[3][7], parab[3][144], y; win = gopen(L, L); window(win, -L / 2, -L / 2, L / 2, L / 2); gsetbgcolor(win, ECTRL_BGCOLOR); newcolor(win, ECTRL_FGCOLOR); winname(win, "e_3d demo"); layer(win, 0, 1); gsetnonblock(ENABLE); i = j = m = 0; for (i = 0; i < 144; i++) { y = L/(2*144.0)*i; parab[0][i] = 0; parab[1][i] = -y; parab[2][i] = 0.02*y*(L/2 - y); } while (key != 'q') { g3dsetangle(torad(40 * (1.5 + sin(j * 2 * M_PI / 30))), i * 2 * M_PI / 144); gclr(win); for (k = 0; k < 5; k++) { pentagon[0][k] = L / 6 * cos(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5; pentagon[1][k] = L / 6 * sin(arp[k] * 2 * M_PI / 5 + m * 2 * M_PI / 50) + L / 5; pentagon[2][k] = 0; } for (k = 0; k < 7; k++) { septagon[0][k] = L / 6 * cos(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) - L / 5; septagon[1][k] = 0; septagon[2][k] = L / 6 * sin(ars[k] * 2 * M_PI / 7 + 2 * m * 2 * M_PI / 50) + L / 5; } newcolor(win, "lightsteelblue"); newlinestyle(win, LineOnOffDash); for(k = 0; k < 6; k++) { drawline3d(win, -L/10*k, 0, 0, -L/10*k, -L/2, 0); drawline3d(win, 0, -L/10*k, 0, -L/2, -L/10*k, 0); } newlinestyle(win, LineSolid); newcolor(win, "red4"); fillpoly3d(win, pentagon[0], pentagon[1], pentagon[2], 5, 0); newcolor(win, "green4"); fillpoly3d(win, septagon[0], septagon[1], septagon[2], 7, 0); newcolor(win, ECTRL_FGCOLOR); drawarrow3d(win, 0, 0, 0, 0, 0, L / 3, 10, 6, 12); drawarrow3d(win, 0, 0, 0, 0, L / 3, 0, 10, 6, 12); drawarrow3d(win, 0, 0, 0, L / 3, 0, 0, 10, 6, 12); newcolor(win, "gold3"); drawstr3d(win, 0, 0, L/3+10, FONTSET, 0, "z¼´"); drawlines3d(win, parab[0], parab[1], parab[2], 144); y = L/(2*36.0)*(i%36); putimg24m3d(win, 0 - 6 *(-sin(_phi) - cos(_th)*cos(_phi)), -y - 6*(cos(_phi) - cos(_th)*sin(_phi)), 0.02*y*(L/2 - y) -6*sin(_th), 12, 12, Xpm_image_stone6); copylayer(win, 1, 0); i++; i %= 144; j++; j %= 30; m++; m %= 50; msleep(40); key = ggetch(); } gcloseall(); return 0; }