I have a problem with my OpenLL project. I have to make moving triangle with X-X. All have to turn around. I have made it but I do not know what is happening with acceleration ...
#include & lt; Stdio.h & gt; # Include & lt; Stdlib.h & gt; # Include & lt; Iostream & gt; # Include & lt; Math.h> # Include & lt; Iomanip & gt; # Include & lt; Time.h> #include "glut.h" # included "math.h" using namespace std; Float x = 0, y = 0, angle = 0, agglen = 0, q = 1, w = 1, e = 1, qn = 0, wn = 0, n = 0; Double xn = 0, c = 0; Int licznik = 0; Int zmiana = 0, a = 0; Bull flag = true; Fixed zero timer callback (int value) {if (xn! = X) {licznik ++; // Odlijny Collagen Kletek X + = XN / 100.0; Angle + = agglen / 100.0; Q + = qn / 100.0; W + = wn / 100.0; E + = N / 100.0; If (q> 1) {q = 0; } If (w> 1) {w = 0; } If (E & gt; 1) {E = 0; } GlutPostRedisplay (); GlutTimerFunc (50, timer callback, value); // ustawienie ponownego wywołania naszej funkcji "timer callback" po 100 ms} if (licoscic == 100) {if (a == 0) {x = -0.8; GlutPostRedisplay (); } And if (a == 1) {x = 0; GlutPostRedisplay (); } And if (a == 2) {x = 0.8; GlutPostRedisplay (); } And if (a == 3) {x = 0; GlutPostRedisplay (); } Xn = 0; Eglene = 0; Lysenic = 0; Zmiana = 1; }} Zero trojakat (float x, float y, float angle) {glColor3f (q, w, e); GlPushMatrix (); GlTranslatef (X, Y, 0); Glottage (angle, 0, 0, 1); GlBegin (GL_POLYGON); Glitax 2f (0, 0.2); Glitax 2f (-0.2, -0.2); Glitax 2f (0.2, -0.2); GlEnd (); GlPopMatrix (); } Zero Prosevny () {a ++; If (a & gt; 3) {a = 0; }; If ((a == 1) || (a == 2)) {flaga = true; } And if ((a == 0) || (a == 3)) {flaga = false;} if (flaga == true) {xn + = .8; Eglene + = 360; Qn + = .1; Wn + = .7; N + = .3; } And if (flaga == wrong) {xn - = .8; Eglene + = 360; Qn + = .8; Wn + = .4; N + = .3; } Zmiana = 4; // wyzerowanie zliczania klatek timer callback (0); // wywołanie funkcji która będzie się okresowo powtarzać} void przesuwanie_w_lewo () // pierwsze przesuniecie o połowe jednostki {xn = 0; Xn - $ .8; Eglene + = 360; Qn - =. 9; Wn - = .7; N - = .3; Zmiana = 4; TimerCallback (0); // wywołanie funkcji która będzie się okresowo powtarzać} zero performance (zero) {/ * clear window * / glClear (GL_COLOR_BUFFER_BIT); Trojakat (x, y, angle); GlFlush (); If ((zmiana == 0) || (zmiana == 1) || (zmiana == 2)) {if (zmiana == 0) {przesuwanie_w_lewo (); } And if (zmiana == 1) {przesuwanie (); }}} Zero init () {/ * black color set clear color / glClearColor (0.0, 0.0, 0.0, 0.0); / * Set the set in white * / / * Set the original orthogonal view with clipping * / / * On the basis of the particle centered from 2 in the form of a / / * box / / * This is the default view and the statement deleted Can be * / glMatrixMode (GL_PROJECTION); GlLoadIdentity (); Glotho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); GlMatrixMode (GL_MODELVIEW); GlLoadIdentity (); } Int main (int argc, char * argv []) {glutInit (and argc, argv); GlutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); GlutInitWindowSize (400, 400); GlutInitWindowPosition (0, 0); GlutCreateWindow ("trojkat"); GlutDisplayFunc (display); in this(); GlutMainLoop (); Return 0; }
No comments:
Post a Comment