Advertisement
Ladies_Man

#CCG FINAL PART1 (scheme, afx, main)

Dec 25th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 15.35 KB | None | 0 0
  1. //scheme.txt
  2. 5
  3. c
  4. 1001 90 380 1000
  5. 2001
  6. b
  7. 2001 200 700 0
  8. 1001 0 2002
  9. b
  10. 2002 300 480 10
  11. 2001 1002 0
  12. c
  13. 1002 400 250 300
  14. 2002
  15. p
  16. 800 930 600 250
  17. end_scheme
  18.  
  19.  
  20. 1
  21. p
  22. 500 930 600 700
  23. end_scheme
  24.  
  25.  
  26.  
  27. 3
  28. c
  29. 1001 100 450 100
  30. 2000
  31. b
  32. 2000 200 800 0
  33. 1001 0 1002
  34. c
  35. 1002 300 600 10
  36. 2000
  37. end_scheme
  38.  
  39.  
  40.  
  41. 5
  42. b
  43. 2001 150 480 10
  44. 0 1001 2002
  45. c
  46. 1001 120 250 30
  47. 2001
  48. b
  49. 2002 250 700 0
  50. 2001 0 1002
  51. c
  52. 1002 310 280 100
  53. 2002
  54. p
  55. 800 930 600 250
  56. end_scheme
  57.  
  58.  
  59.  
  60.  
  61. 7
  62. c
  63. 1001 90 380 100
  64. 2001
  65. b
  66. 2001 200 750 0
  67. 1001 0 2002
  68. b
  69. 2002 300 480 10
  70. 2001 1002 2003
  71. c
  72. 1002 350 210 300
  73. 2002
  74. b
  75. 2003 400 600 0
  76. 2002 0 1003
  77. c
  78. 1003 460 370 1000
  79. 2003
  80. p
  81. 800 930 600 250
  82. end_scheme
  83.  
  84.  
  85.  
  86.  
  87. 10
  88. c
  89. 1001 210 400 100
  90. 2001
  91. b
  92. 2001 250 700 0
  93. 1001 0 2002
  94. b
  95. 2002 350 500 5
  96. 2001 1002 2003
  97. c
  98. 1002 320 230 30
  99. 2002
  100. b
  101. 2003 450 700 0
  102. 2002 0 2004
  103. b
  104. 2004 550 500 10
  105. 2003 1003 2005
  106. c
  107. 1003 570 300 50
  108. 2004
  109. b
  110. 2005 650 700 0
  111. 2004 0 1004
  112. c
  113. 1004 760 400 10
  114. 2005
  115. p
  116. 800 930 600 250
  117. end_scheme
  118.  
  119.  
  120.  
  121. //=======================================================================================
  122. //=======================================================================================
  123. //=======================================================================================
  124. //stdafx.h
  125. // stdafx.h : include file for standard system include files,
  126. // or project specific include files that are used frequently, but
  127. // are changed infrequently
  128. //
  129. #pragma once
  130.  
  131. #include "targetver.h"
  132.  
  133. #define _CRT_SECURE_NO_WARNINGS
  134.  
  135. //if print is lagging switch this
  136. #include <stdio.h>     
  137. //#include <iostream>
  138. #include <vector>
  139. #include <tchar.h>
  140. #include <stdlib.h>
  141.  
  142. #define _USE_MATH_DEFINES
  143. #include <cmath>
  144. #include <math.h>
  145.  
  146. #include <ctime>
  147. #include <time.h>
  148.  
  149. #include <Windows.h>
  150.  
  151. #include <string>
  152.  
  153. #define GLEW_STATIC
  154. #include <GL\glew.h>
  155. #include <GLFW\glfw3.h>
  156.  
  157. typedef struct { float x, y; } coord;
  158.  
  159.  
  160. #include "cell.h"
  161. #include "map.h"
  162. #include "pendulum.h"
  163. #include "node.h"
  164. #include "dll.h"
  165.  
  166.  
  167.  
  168. #define SCREEN_WIDTH 1000
  169. #define SCREEN_HEIGHT 1000
  170. #define ROOF_HEIGHT 950
  171. #define FLOOR_HEIGHT 50
  172. #define SPLIT_X 10
  173. #define SPLIT_Y 10
  174. #define G_CONST 9.781665
  175. #define MAXRANDID 99999
  176.  
  177. #define REVD(COORD_Y) ((SPLIT_Y - 1) - (COORD_Y))
  178.  
  179. #define PC_MODE 16
  180. #define CONSOLE_MODE 0
  181.  
  182.  
  183. //Performance tests:
  184. //#define PERFORM_TEST
  185.  
  186.  
  187. //=======================================================================================
  188. //=======================================================================================
  189. //=======================================================================================
  190. //glfw30.cpp
  191.  
  192.  
  193. // glfw_30.cpp : Defines the entry point for the console application.
  194. //  http://www.glfw.org/docs/latest/quick.html
  195.  
  196. #include "stdafx.h"
  197.  
  198. #include <GLAux.h>
  199. #pragma comment(lib,"glaux.lib")
  200.  
  201.  
  202. using namespace std;
  203.  
  204. GLdouble A, B, C, D;
  205.  
  206. float t_main = 0;
  207. float t_list_pend = 0, t_list_move = 0, t_pend = 0;
  208. static float alpha;
  209.  
  210. bool pendulum_exists = false;
  211.  
  212. int mouse_curr_x, mouse_curr_y;
  213.  
  214. class cell;
  215. class map;
  216. class node;
  217. class dll;
  218. class pendulum;
  219.  
  220. map *m;
  221. dll *list;
  222. pendulum *pend;
  223.  
  224. #ifdef PERFORM_TEST
  225. float test_fps;
  226. float test_time = 0;
  227. int test_n = 0;
  228. FILE *TEST_FPS_FILE;
  229. #endif
  230.  
  231.  
  232.  
  233. void draw_constraints(int h) {
  234.    
  235.     glLineWidth(2.0);
  236.     glColor3f(0, 0, 0);
  237.     int i, n = 20;
  238.     float di = SCREEN_WIDTH / n;
  239.    
  240.     if (h > SCREEN_HEIGHT / 2) {
  241.         glBegin(GL_POLYGON);
  242.             glColor3f(1, 1, 1);
  243.             glVertex2f(0, h);
  244.             glVertex2f(0, SCREEN_HEIGHT);
  245.             glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
  246.             glVertex2f(SCREEN_WIDTH, h);
  247.         glEnd();
  248.         for (i = 0; i < SCREEN_WIDTH; i += (int)di) {
  249.             glBegin(GL_LINES);
  250.                 glColor3f(0,0,0);
  251.                 glVertex2f(i, h);
  252.                 glVertex2f(i + di, h + di);
  253.             glEnd();
  254.         }
  255.     }
  256.     else {
  257.         glBegin(GL_POLYGON);
  258.             glColor3f(1, 1, 1);
  259.             glVertex2f(0, -h);
  260.             glVertex2f(0, h);
  261.             glVertex2f(SCREEN_WIDTH, h);
  262.             glVertex2f(SCREEN_WIDTH, -h);
  263.         glEnd();
  264.         for (i = 0; i < SCREEN_WIDTH; i += (int)di) {
  265.             glBegin(GL_LINES);
  266.                 glColor3f(0,0,0);
  267.                 glVertex2f(i, h);
  268.                 glVertex2f(i - di, h - di);
  269.             glEnd();
  270.         }
  271.     }
  272.  
  273.     glLineWidth(4.0);
  274.     glBegin(GL_LINES);
  275.         glColor3f(0,0,0);
  276.         glVertex2f(0, h);
  277.         glVertex2f((GLfloat)SCREEN_WIDTH, h);
  278.     glEnd();
  279. }
  280.  
  281. void draw_gears(float start_angle, float angle, int x, int y, int inner_rad, int outer_rad, int teeth_len, int teeth, float color) {
  282.    
  283.     glPushMatrix();
  284.     glRotatef(angle + start_angle, 0, 0, 1);
  285.  
  286.     int i;
  287.     GLfloat phi;
  288.     float da = 2 * M_PI / teeth / 4.0;
  289.  
  290.     glBegin(GL_QUAD_STRIP);
  291.     glColor3f(color, color, color);
  292.    
  293.     for (i = 0; i <= teeth; i++) {
  294.         phi = i * 2.0 * M_PI / teeth;
  295.         glVertex2f(x + inner_rad * cos(phi), y + inner_rad * sin(phi));
  296.         glVertex2f(x + outer_rad * cos(phi), y + outer_rad * sin(phi));
  297.         glVertex2f(x + inner_rad * cos(phi), y + inner_rad * sin(phi));
  298.         glVertex2f(x + outer_rad * cos(phi + 3 * da), y + outer_rad * sin(phi + 3 * da));
  299.     }
  300.     glEnd();
  301.  
  302.     glBegin(GL_QUADS);
  303.     da = 2.0 * M_PI / teeth / 4.0;
  304.     for (i = 0; i < teeth; i++) {
  305.         phi = i * 2.0 * M_PI / teeth;
  306.  
  307.         glVertex2f(x + outer_rad * cos(phi), y + outer_rad * sin(phi));
  308.         glVertex2f(x + (outer_rad + teeth_len) * cos(phi + da), y + (outer_rad + teeth_len) * sin(phi + da));
  309.         glVertex2f(x + (outer_rad + teeth_len) * cos(phi + 2 * da), y + (outer_rad + teeth_len) * sin(phi + 2 * da));
  310.         glVertex2f(x + outer_rad * cos(phi + 3 * da), y + outer_rad * sin(phi + 3 * da));
  311.     }
  312.     glEnd();
  313.  
  314.     glPopMatrix();
  315.  
  316. }
  317.  
  318. void draw_permission_signal() {
  319.  
  320.     GLfloat phi = 0, theta = 0;
  321.  
  322.     int center_x = 50, center_y = ROOF_HEIGHT - 50;
  323.     int rad = 20;
  324.  
  325.     //outer
  326.     glBegin(GL_POLYGON);
  327.  
  328.     glColor3f(0, 0, 0);
  329.     for (phi = 0; phi < 2 * M_PI; phi += 0.1) {
  330.         glVertex2f(center_x + rad*cos(phi), center_y + rad*sin(phi));
  331.     }
  332.     glEnd();
  333.  
  334.     //inner
  335.     rad = 18;
  336.     glBegin(GL_POLYGON);
  337.     glColor3f(1, 0.2, 0.2);
  338.     for (phi = 0; phi < 2 * M_PI; phi += 0.1) {
  339.         glVertex2f(center_x + rad*cos(phi), center_y + rad*sin(phi));
  340.     }
  341.     glEnd();
  342.  
  343.     rad = 14;
  344.     glBegin(GL_POLYGON);
  345.     glColor3f(1, 0, 0);
  346.     for (phi = 0; phi < 2 * M_PI; phi += 0.1) {
  347.         glVertex2f(center_x + rad*cos(phi), center_y + rad*sin(phi));
  348.     }
  349.     glEnd();
  350.  
  351. }
  352.  
  353. static void cursor_callback(GLFWwindow* window, double x, double y)
  354. {
  355.     mouse_curr_x = (int)x;
  356.     mouse_curr_y = (int)y;
  357.  
  358.     int tmpx = (int)(x / (SCREEN_WIDTH / SPLIT_X));
  359.     int tmpy = (int)(y / (SCREEN_HEIGHT / SPLIT_Y));
  360.  
  361.     //printf("%d\t%d\t%c\n", (int)x, (int)y, m->get_cell_type(tmpx, tmpy));
  362.  
  363.     //m->dispell_map();
  364.     //m->highlight_cell(tmpx, tmpy);
  365. }
  366.  
  367. static void mouse_callback(GLFWwindow* window, int button, int action, int mods)
  368. {
  369.     int tmpx = (int)(mouse_curr_x / (SCREEN_WIDTH / SPLIT_X));
  370.     int tmpy = (int)(mouse_curr_y / (SCREEN_HEIGHT / SPLIT_Y));
  371.  
  372.     if (button == GLFW_MOUSE_BUTTON_RIGHT)
  373.     {
  374.         if (action == GLFW_PRESS) {
  375.            
  376.  
  377.             //printf("%d\t%d\t%c\n", (int)mouse_curr_x, (int)mouse_curr_y, m->get_cell_type(tmpx, tmpy));
  378.         }
  379.         if (action == GLFW_RELEASE) glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
  380.     }
  381.  
  382.     if (button == GLFW_MOUSE_BUTTON_LEFT)
  383.     {
  384.         if (action == GLFW_PRESS) {
  385.  
  386.             //printf("M: %d\t%d\t%c(before click)\n", mouse_curr_x, mouse_curr_y, m->get_cell_type(tmpx, tmpy));
  387.             /*
  388.             if ('e' == m->get_cell_type(tmpx, tmpy)) {
  389.                 m->erase_cell(tmpx, tmpy);
  390.                 m->set_cell(1, tmpx, tmpy, 'b');
  391.                 return;
  392.             }
  393.             if ('b' == m->get_cell_type(tmpx, tmpy)) {
  394.                 m->erase_cell(tmpx, tmpy);
  395.                 m->set_cell(1, tmpx, tmpy, 'c');
  396.                 return;
  397.             }
  398.             if ('c' == m->get_cell_type(tmpx, tmpy)) {
  399.                 m->erase_cell(tmpx, tmpy);
  400.                 m->set_cell(1, tmpx, tmpy, 'e');
  401.                 return;
  402.             }
  403.             */
  404.            
  405.         }
  406.        
  407.     }
  408. }
  409.  
  410. static void resize_callback(GLFWwindow* window, int width, int height)
  411. {
  412.     //      windowWidth = width;
  413.     //      windowHeight = height;
  414.  
  415.     glViewport(0, 0, width, height);
  416.     glMatrixMode(GL_PROJECTION);
  417.     glLoadIdentity();
  418.     glOrtho(0.0, (GLdouble)width, 0.0, (GLdouble)height, -1, 1);
  419.  
  420.     glMatrixMode(GL_MODELVIEW);
  421.     glLoadIdentity();
  422.  
  423.     A = width / 4.0;
  424.     B = 0.0;
  425.     C = D = height / 2.0;
  426.  
  427.     //printf("Reshape occured\n");
  428. }
  429.  
  430. static void keyboard_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
  431. {
  432.     if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
  433.         glfwSetWindowShouldClose(window, GL_TRUE);
  434.     if (GLFW_KEY_S == key && action == GLFW_PRESS) {
  435.         m->validate_map();
  436.     }
  437.     if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS) {
  438.         //scheme
  439.         if (list->permit_phys_move) {
  440.             if (!list->phys_move_enabled) {
  441.                 list->phys_move_enabled = true;
  442.             }
  443.             else {
  444.                 list->phys_move_enabled = false;
  445.             }
  446.         }
  447.         else {
  448.             printf("physics can't be enabled at the moment. check back later.\n");
  449.         }
  450.        
  451.     }
  452. }
  453.  
  454. static void error_callback(int error, const char* description)
  455. {
  456.     fputs(description, stderr);
  457. }
  458.  
  459.  
  460. void display(GLFWwindow* window)
  461. {
  462.     float LO = 0.2;
  463.     float HI = 0.8;
  464.  
  465.     float clr1 = LO + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (HI - LO)));
  466.     float clr2 = LO + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (HI - LO)));
  467.     float clr3 = LO + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (HI - LO)));
  468.     float clr4 = LO + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (HI - LO)));
  469.     float clr5 = LO + static_cast <float> (rand()) / (static_cast <float> (RAND_MAX / (HI - LO)));
  470.  
  471.     alpha = 0;
  472.  
  473.  
  474. #ifdef PERFORM_TEST
  475.  
  476.     double lastTime = glfwGetTime();
  477.     int nbFrames = 0;
  478.     float fps_sum = 0;
  479.  
  480.    
  481.     printf("Test#%d\n", test_fps);
  482. #endif
  483.  
  484.     while (!glfwWindowShouldClose(window))
  485.     {
  486.         glClearColor(0.6, 0.6, 0.6, 1);
  487.         //glClearColor(1, 1, 1, 1);
  488.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  489.        
  490.         draw_gears(0, alpha*0.7, -1500, 1500, 200, 1500, 20, 300, 0.8);
  491.         draw_gears(0, -alpha*0.8, 200, 900, 200, 500, 30, 30, clr1);
  492.         draw_gears(0, alpha * 0.7, -200, 900, 60, 480, 30, 100, clr2);
  493.         draw_gears(0, -alpha, 260, 120, 40, 90, 30, 10, clr3);
  494.         draw_gears(400, alpha*1.2, 850, 330, 50, 200, 50, 17, clr4);
  495.         //draw_gears(clr4*100, alpha*0.3, 850, 330, 50, 200, clr4*10, 17, clr4);
  496.         draw_gears(500, alpha*1.1, 850, 800, 60, 200, 40, 20, clr5);
  497.         draw_gears(clr5 * 100, alpha*clr5, 850, 800, clr4 * 10, 200, 40, clr5 * 10, clr5);
  498.        
  499.         draw_constraints(ROOF_HEIGHT);
  500.         draw_constraints(FLOOR_HEIGHT);
  501.        
  502.         if (!list->permit_phys_move && cos(t_main) > 0) {
  503.             draw_permission_signal();
  504.         }
  505.  
  506.         if (glfwGetKey(window, GLFW_KEY_P) == GLFW_PRESS) {
  507.             m->print_map();
  508.         }
  509.  
  510.         //m->draw_map();
  511.         if (pendulum_exists) {
  512.             pend->draw();
  513.             pend->move(t_pend);
  514.             t_pend += 0.05;
  515.         }
  516.  
  517.         list->draw_objects();
  518.         list->draw_ropes();
  519.  
  520.         float dt_list_move = 0.005;
  521.  
  522.         list->check_attenuation();
  523.         list->enable_phys_pend(t_list_pend);
  524.  
  525.         list->check_collisions();
  526.         list->enable_phys_move(t_list_move, dt_list_move);
  527.  
  528.         if (list->phys_move_enabled && list->permit_phys_move) {
  529.             t_list_move += dt_list_move;
  530.         }
  531.         if (list->phys_pend_enabled) {
  532.             t_list_pend += 0.06;
  533.         }
  534.  
  535.         t_main += 0.02;
  536.         alpha += 0.03;
  537.        
  538. #ifdef PERFORM_TEST
  539.  
  540.         double currentTime = glfwGetTime();
  541.         nbFrames++;
  542.         if (currentTime - lastTime >= 1.0) {
  543.             printf("%f fps\n", double(nbFrames));
  544.             fps_sum += nbFrames;
  545.             nbFrames = 0;
  546.             lastTime += 1.0;
  547.         }
  548.  
  549.         if (currentTime >= 10.0) {
  550.             fprintf(TEST_FPS_FILE, "%f\n", fps_sum / 10.0);
  551.             return;
  552.         }
  553.  
  554. #endif
  555.        
  556.         glfwSwapBuffers(window);
  557.         glfwPollEvents();
  558.         //glfwWaitEvents();
  559.     }
  560.  
  561. }
  562.  
  563.  
  564. int main(int argc, _TCHAR* argv[])
  565. {
  566.     int num;
  567.  
  568. #ifdef PERFORM_TEST
  569.     TEST_FPS_FILE = fopen("FPS_TEST_FILE.txt", "w");
  570.  
  571.     for (test_fps = 0; test_fps < 10; test_fps++)
  572.     {
  573.  
  574. #endif
  575.  
  576.         if (!glfwInit()) {
  577.             printf("glfwInit failed\n");
  578.             return -1;
  579.         }
  580.  
  581.         glfwWindowHint(GLFW_SAMPLES, PC_MODE);
  582.  
  583.         glfwSetErrorCallback(error_callback);
  584.  
  585.         GLFWwindow* window;
  586.  
  587.         //      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
  588.         //      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
  589.         //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
  590.         window = glfwCreateWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "Anthony's Porject", NULL, NULL);
  591.         if (window == NULL) {
  592.             printf("glfwOpenWindow failed.\n");
  593.             glfwTerminate();
  594.             return -2;
  595.         }
  596.  
  597.         int i, attrib;
  598.         attrib = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
  599.         attrib = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
  600.         attrib = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
  601.  
  602.         glfwMakeContextCurrent(window);
  603.  
  604.         glfwSetKeyCallback(window, keyboard_callback);
  605.         glfwSetFramebufferSizeCallback(window, resize_callback);
  606.         glfwSetMouseButtonCallback(window, mouse_callback);
  607.         glfwSetCursorPosCallback(window, cursor_callback);
  608.         resize_callback(window, SCREEN_WIDTH, SCREEN_HEIGHT);
  609.  
  610.         srand(time(NULL));
  611.  
  612.         FILE *fp;
  613.         fp = fopen("scheme.txt", "r");
  614.         if (NULL == fp) {
  615.             printf("cannot open file\n");
  616.         }
  617.  
  618.  
  619.         list = new dll();
  620.  
  621.  
  622.         pend = new pendulum();
  623.  
  624.  
  625.         m = new map();
  626.         m->set_map(SPLIT_X, SPLIT_Y);
  627.  
  628.  
  629.         printf("reading scheme\n");
  630.  
  631.  
  632.        
  633.         fscanf(fp, "%d", &num);
  634.  
  635.         for (i = 0; i < num; i++) {
  636.             char el_type[6];
  637.             printf("type ");
  638.             fscanf(fp, "%s", el_type);
  639.  
  640.             if (0 == strcmp(el_type, "end_scheme"))
  641.                 break;
  642.  
  643.             node *curr_node;
  644.             int pos_x, pos_y, mass;
  645.             int body_name, conn_left_name, conn_center_name, conn_right_name;
  646.  
  647.             if (0 == strcmp(el_type, "block") || 0 == strcmp(el_type, "b")) {
  648.  
  649.                 printf("name pos_x pos_y mass ");
  650.                 fscanf(fp, "%d%d%d%d", &body_name, &pos_x, &pos_y, &mass);
  651.                 printf("connection[L C R] ");
  652.                 fscanf(fp, "%d%d%d", &conn_left_name, &conn_center_name, &conn_right_name);
  653.  
  654.                 list->append_back(body_name);
  655.                 curr_node = list->get_by_id(body_name);
  656.                 curr_node->set_list_param('b', body_name, i, pos_x, pos_y, mass);
  657.                 curr_node->set_cp_ids(conn_left_name, conn_center_name, conn_right_name);
  658.  
  659.                 printf("block:%d[x:%d y:%d m:%d CL:%d CC:%d CR:%d]\n\n", body_name, pos_x, pos_y, mass, conn_left_name, conn_center_name, conn_right_name);
  660.             }
  661.  
  662.             if (0 == strcmp(el_type, "cargo") || 0 == strcmp(el_type, "c")) {
  663.  
  664.                 printf("name pos_x pos_y mass ");
  665.                 fscanf(fp, "%d%d%d%d", &body_name, &pos_x, &pos_y, &mass);
  666.                 printf("connection[T B] ");
  667.                 fscanf(fp, "%d", &conn_center_name);
  668.  
  669.                 list->append_back(body_name);
  670.                 curr_node = list->get_by_id(body_name);
  671.                 curr_node->set_list_param('c', body_name, i, pos_x, pos_y, mass);
  672.                 curr_node->set_cp_ids(conn_center_name);
  673.  
  674.                 printf("cargo:%d[x:%d y:%d m:%d CC:%d]\n\n", body_name, pos_x, pos_y, mass, conn_center_name);
  675.             }
  676.  
  677.             if (0 == strcmp(el_type, "pendulum") || 0 == strcmp(el_type, "p")) {
  678.                 pendulum_exists = true;
  679.  
  680.                 float carrier_x, carrier_y, ticker_x, ticker_y;
  681.                 fscanf(fp, "%f%f%f%f", &carrier_x, &carrier_y, &ticker_x, &ticker_y);
  682.  
  683.                 coord carr, tick;
  684.  
  685.                 carr.x = carrier_x;
  686.                 carr.y = carrier_y;
  687.                 tick.x = ticker_x;
  688.                 tick.y = ticker_y;
  689.  
  690.                 pend->set(carr, tick);
  691.  
  692.                 printf("pendulum [CRR:%f,%f TKR:%f,%f] has been added\n\n", pend->carrier.x, pend->carrier.y, pend->curr_ticker.x, pend->curr_ticker.y);
  693.             }
  694.         }
  695.         fclose(fp);
  696.         printf("file has been closed\n");
  697.  
  698.         list->set_connection_points();
  699.         list->set_pend_params();
  700.  
  701.  
  702.         list->display_objects();
  703.  
  704.         printf("\n");
  705.  
  706.         if (NULL != window) {
  707.  
  708.             display(window);
  709.  
  710.         }
  711.  
  712.         glfwDestroyWindow(window);
  713.         glfwTerminate();
  714.  
  715. #ifdef PERFORM_TEST
  716.     }
  717.     fprintf(TEST_FPS_FILE, "scheme difficulty:%d\n", num);
  718.  
  719.     fclose(TEST_FPS_FILE);
  720.     getchar();
  721. #endif
  722.  
  723.     return 0;
  724. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement