このアニメーションの粒子の落ちてくる速度を遅くしたいです。どこの数字を変更したら遅くなりますか?
#include "GL/glut.h" #include <math.h> #include <stdlib.h> #include <stdio.h> #ifdef WIN32 //to correct ASCI deviations in Microsoft VC++ 6.0 #define M_PI 3.1415926535897932384626433832795 double drand48() { return (rand()%10000)/10000.0; } #endif #define MAX_POINTS 5000 int num; GLfloat curx, cury; GLfloat x[MAX_POINTS], y[MAX_POINTS]; GLfloat xacc[MAX_POINTS], yacc[MAX_POINTS]; GLfloat red, green, blue; int step; int length; void initialize() { int j; double temp, temp2; num = drand48()*(MAX_POINTS-1); //疑似乱数の生成 curx = -0.5 + drand48(); cury = 0.0 + drand48(); red = 0.5 + 0.5*drand48(); green = 0.5 + 0.5*drand48(); blue = 0.5 + 0.5*drand48(); glPointSize(123.0); step = 0; length = 700 + 300*drand48(); for (j=0 ; j<num; j++ ) { x[j] = curx; y[j] = cury; temp = drand48(); temp2 = drand48()*2.0*M_PI; xacc[j] = (cos(temp2) * temp)/length; yacc[j] = (sin(temp2) * temp)/length; } } void draw_blast(void) { int i; double glow = (length - step) / (double)length; glColor3f(red*glow, green*glow, blue*glow); glBegin(GL_POINTS); for (i=0;i<num;i++) { x[i] += xacc[i]; y[i] += yacc[i]; glVertex2f(x[i], y[i]); } glEnd(); glFlush(); glutSwapBuffers(); } void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT); if (step < 1.9*length) { for (i=0; i<num; i++) yacc[i] -= 3.2 / length; // 重力 draw_blast(); } step ++; if (step > length) initialize(); } void idle(void) { glutPostRedisplay(); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; } } void reshape (int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho(-1.0, 1.0, -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0); else glOrtho(-1.0*(GLfloat)w/(GLfloat)h, 1.0*(GLfloat)w/(GLfloat)h, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); glutInitWindowSize (800, 800); glutInitWindowPosition(0, 0); glutCreateWindow ("Fireworks"); glClearColor (0.0, 0.0, 0.0, 0.0); initialize(); glutDisplayFunc(display); glutReshapeFunc(reshape); glutIdleFunc(idle); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }