// program to bounce around a 2d mass spring system with (optional) gravity and floor // Date: 10/17/08 // Author: CSCI 323 class #include #include #include "glut.h" #include "point.h" #include using namespace std; int NPTS = 10; // number of points on each side point *jello; clock_t lastTime; clock_t curTime; double elapsed; void init(void) { int i, j, index; double x, y; // jello initialization jello = new point[NPTS*NPTS]; for (i = 0; i < NPTS; i++) for (j = 0; j < NPTS; j++) { index = i*NPTS+j; x = /*-0.15*/ + (j-NPTS/2)*jello[index].SRL*0.707 - (i-NPTS/2)*jello[index].SRL*0.707; y = 0.6 + (i-NPTS/2)*jello[index].SRL*0.707 + (j-NPTS/2)*jello[index].SRL*0.707; jello[index].setx(x); jello[index].sety(y); jello[index].setnewx(x); jello[index].setnewy(y); } // graphics initialization glClearColor(0.0, 0.0, 0.0, 1.0); lastTime = clock(); return; } void display(void) { int i, j, index; glClear(GL_COLOR_BUFFER_BIT); for (i=0; i 0.0) { lastTime = curTime; for (i=0; i