【2018年1月10日から放送開始】TVアニメ『ダメプリ ANIME CARAVAN』 OPムービー【OP BREAKERZ】
アニメ『ダメプリ ANIME CARAVAN』
腐女子アニメは、大好物。姫がイケメン王子たちに囲まれます。たぶん。
「忘れちゃったの~?」「初対面ですよねぇ?」「今、出会ったでしょ?」私の中ではクレイジーな会話が見どころです。
壁ドンしてくれるのを期待しながら見てます。(まだ一話しか見てませんが)
ブログ記事のタイトルは、将来内容が思い出せるようにつけているのですが、今回は「壁ドン」と適当につけてしまったので、そのうち記事の内容忘れますね。
今回は壁ドンというか、球のバウンドのアニメーションです。
ソースをドン。
takk@deb9:~$ cat -n bounce1.c
1 #include <GL/glut.h>
2 #include <math.h>
3
4 #define DEG2RAD(deg) deg * 2.0 * M_PI / 360.0
5
6 GLdouble colors[][4]={
7 {0.0, 1.0, 0.0, 0.0}, //0 GREEN
8 {1.0, 1.0, 1.0, 0.0}, //1 WHITE
9 };
10
11 #define GREEN 0
12 #define WHITE 1
13
14 struct maru_struct
15 {
16 GLdouble rx;
17 GLdouble ry;
18 GLdouble rsize;
19 int color;
20 int dir;
21 };
22
23 #define MARU_NUM 6
24 #define SPEED 0.05
25
26 struct maru_struct maru[MARU_NUM];
27
28 #define COLOR(n) colors[n][0],colors[n][1],colors[n][2],colors[n][3]
29
30 void maru_disp(GLdouble x, GLdouble y, GLdouble r, int color)
31 {
32 GLdouble xx, yy;
33 int i,n=20;
34 double deg,offs = 90.0;
35
36 glBegin(GL_POLYGON);
37 glColor4f(COLOR(color));
38
39 for(i=0; i<n; i++){
40 deg = (360.0/n) * i + offs;
41 xx = x + r * cos(DEG2RAD(deg));
42 yy = y + r * sin(DEG2RAD(deg));
43 glVertex2d(xx, yy);
44 }
45
46 glEnd();
47 }
48
49 void callback_timer(int value)
50 {
51 glutPostRedisplay();
52 glutTimerFunc(30,callback_timer,0);
53 }
54
55 void maru_init()
56 {
57 struct maru_struct* p;
58 int i;
59 for(i=1;i<MARU_NUM;i++){
60 p = &maru[i];
61 p->rx = ((rand()%200)-100)/100.0;
62 p->ry = ((rand()%200)-100)/100.0;
63 p->rsize = (rand()%50)/200.0;
64 p->dir = rand()%360;
65 p->color = GREEN;
66 }
67 }
68
69 void maru_move()
70 {
71 struct maru_struct* p;
72 int i;
73
74 for(i=1;i<MARU_NUM;i++){
75 p = &maru[i];
76 if(p->rx < -1.0) p->dir = ((180-p->dir)+360)%360;
77 if(p->rx > 1.0) p->dir = ((180-p->dir)+360)%360;
78 if(p->ry < -1.0) p->dir = ((360-p->dir)+360)%360;
79 if(p->ry > 1.0) p->dir = ((360-p->dir)+360)%360;
80 p->rx += SPEED * cos(p->dir*M_PI/180.0);
81 p->ry += SPEED * sin(p->dir*M_PI/180.0);
82 }
83 }
84
85 void callback_display()
86 {
87 struct maru_struct* p;
88 int i;
89 glClearColor(COLOR(WHITE));
90 glClear(GL_COLOR_BUFFER_BIT);
91
92 maru_move();
93 for(i=1;i<MARU_NUM;i++){
94 p = &maru[i];
95 maru_disp(p->rx, p->ry, p->rsize,p->color);
96 }
97
98 glFlush();
99 }
100
101 int main(int argc, char *argv[])
102 {
103 maru_init();
104
105 glutInit(&argc, argv);
106 glutInitDisplayMode(GLUT_RGBA);
107 glutCreateWindow("bounce1");
108
109 glutTimerFunc(30,callback_timer,0);
110 glutDisplayFunc(callback_display);
111
112 glutMainLoop();
113
114 return 0;
115 }
116
takk@deb9:~$
実行すると、5個のボールが壁ドンしつづけます。


コメント