void f_plane_boing(frame_t *buffer, uint16_t frame) { uint8_t axis = 0; memset(buffer, 0, sizeof(frame_t) * CUBE_HEIGHT); if (frame < 10) { if (frame < CUBE_SIZE) axis = frame; else axis = 10 - frame - 1; draw_plane(buffer, PLANE_XZ, axis); } else if (frame >= 10 && frame < 20) { if (frame - 10 < CUBE_SIZE) axis = frame - 10; else axis = 20 - frame - 1; draw_plane(buffer, PLANE_XY, axis); } else { if (frame - 20 < CUBE_SIZE) axis = frame - 20; else axis = 30 - frame - 1; draw_plane(buffer, PLANE_YZ, axis); } }
void f_plane_rotate(frame_t *buffer, uint16_t frame) { memset(buffer, 0, sizeof(frame_t) * CUBE_HEIGHT); if (frame < 8) { draw_plane(buffer, PLANE_XZ, ROT_CENTER); rotate_axis(buffer, frame * 45, AXIS_Z); } else if (frame >= 8 && frame < 16) { draw_plane(buffer, PLANE_XY, ROT_CENTER); rotate_axis(buffer, frame * 45, AXIS_Y); } else { draw_plane(buffer, PLANE_XY, ROT_CENTER); rotate_axis(buffer, frame * 45, AXIS_X); } }
void f_accelerometer(frame_t *buffer, uint16_t frame) { int32_t x, y; static int8_t xbuf[4], ybuf[4]; /* Last accelerometer data.*/ unsigned i; (void) frame; /* Keeping an history of the latest four accelerometer readings.*/ for (i = 3; i > 0; i--) { xbuf[i] = xbuf[i - 1]; ybuf[i] = ybuf[i - 1]; } /* Reading MEMS accelerometer X and Y registers.*/ xbuf[0] = (int8_t) lis302dlReadRegister(&SPID1, LIS302DL_OUTX); ybuf[0] = (int8_t) lis302dlReadRegister(&SPID1, LIS302DL_OUTY); /* Calculating average of the latest four accelerometer readings.*/ x = ((int32_t) xbuf[0] + (int32_t) xbuf[1] + (int32_t) xbuf[2] + (int32_t) xbuf[3]) / 4; y = ((int32_t) ybuf[0] + (int32_t) ybuf[1] + (int32_t) ybuf[2] + (int32_t) ybuf[3]) / 4; memset(buffer, 0, sizeof(frame_t) * CUBE_HEIGHT); draw_plane(buffer, PLANE_XY, ROT_CENTER); rotate_axis(buffer, -((int16_t)map(y, -128, 128, 180, -180))-90, AXIS_X); rotate_axis(buffer, ((int16_t)map(x, -128, 128, 180, -180))-90, AXIS_Y); }
void video_loop(void) { while(vmsg_read != vmsg_write) { video_proc( vmsg[vmsg_read].msg, vmsg[vmsg_read].word1, vmsg[vmsg_read].word2, vmsg[vmsg_read].ptr); vmsg_read = (vmsg_read + 1) & 0x3FF; } if(wnd_changed) { wnd_changed = 0; glViewport(0, 0, wnd_width, wnd_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, wnd_width, 0, wnd_height, -1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } if(disp_data) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, disp_tw, disp_th, GL_RGBA, GL_UNSIGNED_BYTE, disp_data); draw_plane(disp_offx, disp_offy, disp_width, disp_height); } SwapBuffers(dev_ctx); }
void draw_node(bsp_t *node) { unsigned int i; glColor3f(1.0, 1.0, 1.0); for (i = 0; i < node->ntris; i++) { glNormal3f(node->nlist[3 * i + 0], node->nlist[3 * i + 1], node->nlist[3 * i + 2]); glBegin(GL_TRIANGLES); glVertex3f(node->vlist[9 * i + 0], node->vlist[9 * i + 1], node->vlist[9 * i + 2]); glVertex3f(node->vlist[9 * i + 3], node->vlist[9 * i + 4], node->vlist[9 * i + 5]); glVertex3f(node->vlist[9 * i + 6], node->vlist[9 * i + 7], node->vlist[9 * i + 8]); glEnd(); } glDisable(GL_LIGHTING); draw_plane(node); if (node->parent) { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); draw_plane(node->parent); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); } glEnable(GL_LIGHTING); }
void Slice::paint (Projection& with_projection) { // set up OpenGL environment: gl::Disable (gl::BLEND); gl::Disable (gl::DEPTH_TEST); gl::DepthMask (gl::FALSE_); gl::ColorMask (gl::TRUE_, gl::TRUE_, gl::TRUE_, gl::TRUE_); draw_plane (plane(), slice_shader, with_projection); }
void Slice::paint (Projection& with_projection) { ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT; // set up OpenGL environment: gl::Disable (gl::BLEND); gl::Disable (gl::DEPTH_TEST); gl::DepthMask (gl::FALSE_); gl::ColorMask (gl::TRUE_, gl::TRUE_, gl::TRUE_, gl::TRUE_); draw_plane (plane(), slice_shader, with_projection); ASSERT_GL_MRVIEW_CONTEXT_IS_CURRENT; }
void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glPushMatrix(); glPushMatrix(); glColor4f(1.f,1.f,.2f,1.f); glTranslatef(_x, _y+.05f, 0.f); glScalef(2.f,2.f,2.f); glRotatef(-10.f, 0.f, 0.f, 1.f); draw_plane(); glPopMatrix(); draw_vapor(); glPopMatrix(); glutSwapBuffers(); }
void draw_box(device_t *device, float theta) { matrix_t m; matrix_set_rotate(&m, -1, -0.5, 1, theta); device->transform.world = m; transform_update(&device->transform); draw_plane(device, 0, 1, 2, 3); draw_plane(device, 4, 5, 6, 7); draw_plane(device, 0, 4, 5, 1); draw_plane(device, 1, 5, 6, 2); draw_plane(device, 2, 6, 7, 3); draw_plane(device, 3, 7, 4, 0); }
void enemy::move_plane(){ clean_plane(); for(int i = 0; i < 10; i++){ if(_enemy[i].position[3].Y+1 > 24){ new_plane(a, b, i); } else{ for(int j = 0; j < 4; j++) _enemy[i].position[j].Y++; } int pos = random(a, b).X%4; switch(pos){ case 0://Ïò×óÒƶ¯ { if(_enemy[i].position[0].X-1 < 1){ new_plane(a, b, i); } else{ for(int j = 0; j < 4; j++) _enemy[i].position[j].X--; } break; } case 1: { if(_enemy[i].position[2].X+1 > 49){ new_plane(a, b, i); } else{ for(int j = 0; j < 4; j++) _enemy[i].position[j].X++; } break; } default:enemy_bullet[i].initial_enemy_bullet(_enemy[i].position[3]);break; } enemy_bullet[i].move_enemy_bullet(); enemy_bullet[i].draw_enemy_bullet(); } draw_plane(); }
void display(void){ glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glPushMatrix(); // --- Positioning the cam on azimuthal installation glRotatef(cam.elevation, 1.0, 0.0, 0.0); glRotatef(cam.azimut, 0.0, 1.0, 0.0); glTranslatef(-cam.pos.x, -cam.pos.y, -cam.pos.z); glRotatef(-90, 1.0, 0.0, 0.0); // --- Axes glPushMatrix(); glScalef(1.0, 1.0, 1.0); draw_reference_frame(); glPopMatrix(); // --- Draw plane if(!mesh_loaded) { glColor3f (1.0, 1.0, 0.0); draw_plane(10,10); } else draw_model(); // --- Draw tx antennas for(size_t i = 0; i < txs.size(); i++) draw_tx(txs[i]); // --- Draw rx antennas for(size_t i = 0; i < rxs.size(); i++) draw_rx(rxs[i]); draw_rays(); glPopMatrix(); glutSwapBuffers(); }
void glut_display(){ glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(30.0, 1.0, 0.1, 100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(g_distance * cos(g_angle2) * sin(g_angle1), g_distance * sin(g_angle2), g_distance * cos(g_angle2) * cos(g_angle1), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); GLfloat lightpos[]={static_cast<GLfloat>(5 * cos(g_angle4) * sin(g_angle3)), static_cast<GLfloat>(5 * sin(g_angle4)), static_cast<GLfloat>(5 * cos(g_angle4) * cos(g_angle3)), 1.0}; GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glPushMatrix(); glTranslatef(5 * cos(g_angle4) * sin(g_angle3), 5 * sin(g_angle4), 5 * cos(g_angle4) * cos(g_angle3)); glutSolidSphere(0.2, 50, 50); glPopMatrix(); glPushMatrix(); glTranslatef(5 * cos(g_angle4) * sin(g_angle4), 5 * sin(g_angle4), 5 * cos(g_angle4) * cos(g_angle4)); glutSolidSphere(0.2, 50, 50); glPopMatrix(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION,lightpos); glLightfv(GL_LIGHT0, GL_DIFFUSE,diffuse); GLfloat lightpos2[]={static_cast<GLfloat>(10 * cos(g_angle4) * sin(g_angle4)), static_cast<GLfloat>(10 * sin(g_angle4)), static_cast<GLfloat>(10 * cos(g_angle4) * cos(g_angle4)), 1.0}; glEnable(GL_LIGHT1); glLightfv(GL_LIGHT1, GL_POSITION,lightpos2); glLightfv(GL_LIGHT1, GL_DIFFUSE,diffuse); glPushMatrix(); glTranslatef(0.0, -2.0, 0.0); draw_plane(); glPopMatrix(); glPushMatrix(); glScalef(1.0, 2.0, 1.0); draw_pyramid(); glPopMatrix(); glFlush(); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glutSwapBuffers(); }
/* Draw the building to screen */ void Mill::draw_building() { GLfloat test_material[4] = { 1.00, 1.00, 1.00, 1.00 }; GLfloat house_material[4] = { 0.72, 0.72, 0.72, 1.00 }; GLfloat high_roof_material[4] = { 0.55, 0.27, 0.07, 1.00 }; GLfloat window_vert_material[4] = { 0.20, 0.20, 0.20, 1.00 }; GLfloat low_roof_material[4] = { 0.55, 0.27, 0.07, 1.00 }; GLfloat door_material[4] = { 0.50, 0.30, 0.20, 1.00 }; glPushMatrix(); glTranslatef(x, y*-1, z); glTranslatef(0.0, 0.5, 0.0); glTranslatef(-0.15, -0.80, 0.1); glScalef(0.7, 0.5, 0.8); // house glPushMatrix(); //glColor3f(0.72, 0.72, 0.72); glMaterialfv(GL_FRONT, GL_DIFFUSE, house_material); glScalef(0.5, 0.75, 0.5); glutSolidCube(1); glPopMatrix(); glPushMatrix(); //glColor3f(0.72, 0.72, 0.72); glTranslated(0.3, -0.125, 0.0); glScalef(0.75, 0.5, 0.25); glutSolidCube(1); glPopMatrix(); glTranslated(0.0, -0.2, 0.0); // high roof glPushMatrix(); glScaled(0.5, 1.0, 0.6); //glColor3f(0.55, 0.27, 0.07); glMaterialfv(GL_FRONT, GL_DIFFUSE, high_roof_material); glTranslatef(0.0, 0.58, 0.0); glScalef(0.55, 0.2, 0.5); // Right glBegin(GL_POLYGON); glNormal3d(0.5, 0.5, 0.0); glVertex3f(0.0f, 0.5f, 1.0f); glVertex3f(0.0f, 0.5f, -1.0f); glVertex3f(1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glEnd(); // Left glBegin(GL_POLYGON); glNormal3d(-0.5, 0.5, 0.0); glVertex3f(0.0f, 0.5f, 1.0f); glVertex3f(0.0f, 0.5f, -1.0f); glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(-1.0f, 0.0f, 1.0f); glEnd(); glPopMatrix(); //Low roof glPushMatrix(); glTranslated(0.45, 0.35, 0.0); glRotated(90, 0.0, 1.0, 0.0); glScaled(0.4, 0.0, 0.5); //glColor3f(0.55, 0.27, 0.07); glMaterialfv(GL_FRONT, GL_DIFFUSE, low_roof_material); glScalef(0.55, 0.2, 0.5); // Right glBegin(GL_POLYGON); glNormal3d(0.0, 0.5, -0.5); glVertex3f(0.0f, 0.5f, 1.0f); glVertex3f(0.0f, 0.5f, -1.0f); glVertex3f(1.0f, 0.0f, -1.0f); glVertex3f(1.0f, 0.0f, 1.0f); glEnd(); // Left glBegin(GL_POLYGON); glNormal3d(0.0, 0.5, 0.5); glVertex3f(0.0f, 0.5f, 1.0f); glVertex3f(0.0f, 0.5f, -1.0f); glVertex3f(-1.0f, 0.0f, -1.0f); glVertex3f(-1.0f, 0.0f, 1.0f); glEnd(); glPopMatrix(); //Wood glPushMatrix(); glTranslated(0.0, 0.0, 0.24); glRotated(45, 1.0, 0.0, 0.0); glScaled(0.2, 0.5, 1.0); glutSolidCylinder(0.1, 0.15, 10, 3); glPopMatrix(); glPushMatrix(); glTranslated(0.05, 0.0, 0.24); glRotated(45, 1.0, 0.0, 0.0); glScaled(0.2, 0.5, 1.0); glutSolidCylinder(0.1, 0.15, 10, 3); glPopMatrix(); glPushMatrix(); glTranslated(0.1, 0.0, 0.24); glRotated(45, 1.0, 0.0, 0.0); glScaled(0.2, 0.5, 1.0); glutSolidCylinder(0.1, 0.15, 10, 3); glPopMatrix(); glPushMatrix(); glTranslated(0.38, -0.2, 0.22); glRotated(45, 0.0, 1.0, 0.0); glScaled(0.2, 0.5, 1.0); glutSolidCylinder(0.1, 0.15, 10, 3); glPopMatrix(); //Window vertical //glColor3d(0.2, 0.2, 0.2); glMaterialfv(GL_FRONT, GL_DIFFUSE, window_vert_material); glPushMatrix(); glTranslated(-0.2, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.14, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //horizontal //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.38, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.22, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); glPushMatrix(); glTranslated(0.1, 0.0, 0.0); //Window vertical //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.2, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.14, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //horizontal //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.38, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.22, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); glPopMatrix(); glPushMatrix(); glTranslated(0.2, 0.0, 0.0); //Window vertical //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.2, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.14, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //horizontal //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.38, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.22, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); glPopMatrix(); glPushMatrix(); glTranslated(0.3, 0.0, 0.0); //Window vertical //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.2, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.14, 0.3, 0.25); glScaled(0.03, 0.3, 0.03); glutSolidCube(0.5); glPopMatrix(); //horizontal //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.38, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.3, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glPushMatrix(); glTranslated(-0.17, 0.22, 0.25); glRotated(90, 0.0, 0.0, 1.0); glScaled(0.03, 0.15, 0.03); glutSolidCube(0.5); glPopMatrix(); //Door //glColor3d(0.5, 0.3, 0.2); glMaterialfv(GL_FRONT, GL_DIFFUSE, door_material); glPushMatrix(); glTranslated(0.2, -0.082, 0.12); glScaled(0.2, 0.35, 0.03); glutSolidCube(0.5); glPopMatrix(); //glColor3d(0.2, 0.2, 0.2); glMaterialfv(GL_FRONT, GL_DIFFUSE, window_vert_material); glPushMatrix(); glTranslated(0.2, -0.082, 0.13); glScaled(0.1, 0.1, 0.03); glutSolidCube(0.5); glPopMatrix(); glPushMatrix(); //glDisable(GL_LIGHTING); glMaterialfv(GL_FRONT, GL_DIFFUSE, test_material); glTranslatef(-0.08, -0.20, -0.12); glScalef(0.65, 0.01, 0.56); draw_plane(this->images.at(11).get_image()); //glEnable(GL_LIGHTING); glPopMatrix(); glPopMatrix(); glPopMatrix(); // Animation checking // Each building will fly in from the sky and continue to fall until it lands on the grid. if (y < -0.50) // If the building's Y position is below -0.50 (grid Y coordinate) { Building::is_animating = true; // The building is animating y = y + 0.05; // Increment the Y value (moving it up). This is because the Y value is inverted in the draw_building function. } else // If the building's Y position is on the ground (or above -0.50) { y = -0.50; // Set the Y coordinate to -0.50 Building::is_animating = false; // Set the animation flag to false. } }
/* Draw the building to screen */ void House::draw_building() { glColor3f(1.0, 1.0, 1.0); GLfloat house_material[4] = { 1.00, 1.00, 1.00, 1.00 }; GLfloat roof_material[4] = { 0.17, 0.17, 0.17, 1.00 }; glPushMatrix(); glTranslatef(x, y*-1, z); glTranslatef(0.0, -0.31, -0.20); glScalef(0.5, 0.5, 0.5); // house glPushMatrix(); glScalef(0.49, 0.38, 0.50); glMaterialfv(GL_FRONT, GL_DIFFUSE, house_material); glColor3f(1.0, 1.0, 1.0); draw_plane(house_tex.get_image()); // draw house with texture glPopMatrix(); glPushMatrix(); // door glPushMatrix(); glTranslatef(0.22, -0.15, 0.47); glScalef(0.15, 0.20, 0.05); draw_plane(door_tex.get_image()); // draw house with texture glTranslatef(0.0, 0.0, 0.8); glPopMatrix(); // window glPushMatrix(); glTranslatef(-0.25, 0.1, 0.47); glScalef(0.15, 0.15, 0.05); draw_plane(window_tex.get_image()); glPopMatrix(); glPopMatrix(); // roof draw_roof(roof_tex.get_image()); glPushMatrix(); glTranslatef(0.0, -0.38, 0.41); glScalef(0.9, 0.01, 0.9); draw_plane(tex.get_image()); // draw grass texture glPopMatrix(); glPopMatrix(); // Animation checking // Each building will fly in from the sky and continue to fall until it lands on the grid. if (y < -0.50) // If the building's Y position is below -0.50 (grid Y coordinate) { Building::is_animating = true; // The building is animating y = y + 0.05; // Increment the Y value (moving it up). This is because the Y value is inverted in the draw_building function. } else // If the building's Y position is on the ground (or above -0.50) { y = -0.50; // Set the Y coordinate to -0.50 Building::is_animating = false; // Set the animation flag to false. } }