private void openGLControl_OpenGLDraw(object sender, RenderEventArgs e) { CursorWektor.X =-1 * ((float)Cursor.Position.X - 680) / 50; CursorWektor.Z = -1 * ((float)Cursor.Position.Y - 374) / 50; // double Angle = Math.Atan2(CursorWektor.Z, CursorWektor.X); double Angle = -45; CursorWektorAngled = rotate_wektor(0, 0, (float)Angle, CursorWektor); // CursorWektorAngled.X = CursorWektor.X * (float)Math.Sin(Angle -ConvertToRadians(90)); // CursorWektorAngled.Z = CursorWektor.Z * (float)Math.Cos(Angle -ConvertToRadians(90)); // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; rysow = new Rysownik(gl); // Clear the color and depth buffer. gl.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT); // (x > 0 ? x : (2*PI + x)) * 360 / (2*PI) double AngleX; AngleX = CursorWektor.X; // if(CursorWektor.X<0){AngleX = (2*Math.PI + CursorWektor.X) * 360 / (2*Math.PI) ;} double AngleY; AngleY = CursorWektor.Z; // if (CursorWektor.Z < 0) { AngleY = (2 * Math.PI + CursorWektor.Z) * 360 / (2 * Math.PI); } Angle_between_wektor_X_Z(WektorZero, CursorWektor); // Load the identity matrix. gl.MatrixMode(OpenGL.GL_PROJECTION); // Load the identity. gl.LoadIdentity(); gl.Perspective(60.0f, 0, 0, 0); rysow.DrawLive(new Wektor(0.9f, -0.7f, 0), new Wektor(0.05f, 0.03f, 0f), PlayerLive); rysow.DrawLive(new Wektor(-0.9f, -0.7f, 0), new Wektor(0.05f, 0.04f, 0f), Boss.Live); // gl.DepthMask(0); // rysow.DrawCubo(0, 0, 0, 0.33f, 0.33f, 0.33f,0.0f,true,0.6f); // gl.DepthMask(1); gl.Enable(SharpGL.OpenGL.GL_SMOOTH); gl.Enable(SharpGL.OpenGL.GL_FLAT); // gl.Enable(SharpGL.OpenGL.GL_LINE_SMOOTH); // Create a perspective transformation. gl.Perspective(60.0f, (double)Width / (double)Height, 0.01, 100.0); // Use the 'look at' helper function to position and aim the camera. gl.LookAt(cuboPlayer.polozenie.X - 5, YAxisCamera, cuboPlayer.polozenie.Z - 5, cuboPlayer.polozenie.X, cuboPlayer.polozenie.Y, cuboPlayer.polozenie.Z, 0, 1, 0); // Rotate around the Y axis. float samesize= 2.3f; // =new Wektor(1.0, 1.0, 1.0); //Wektor re(1.0,1.0,1.0); for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskow[i].polozenie.X, listaPociskow[i].polozenie.Y, listaPociskow[i].polozenie.Z, listaPociskow[i].grubosci.X, listaPociskow[i].grubosci.Y, listaPociskow[i].grubosci.Z, (float)listaPociskow[i].angle + rotation, true,1.0f); } // list for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { rysow.DrawCubo(listaPociskowPlayera[i].polozenie.X, listaPociskowPlayera[i].polozenie.Y, listaPociskowPlayera[i].polozenie.Z, listaPociskowPlayera[i].grubosci.X, listaPociskowPlayera[i].grubosci.Y, listaPociskowPlayera[i].grubosci.Z, (float)listaPociskowPlayera[i].angle + rotation, true, 1.0f); } rysow.DrawCubo(Boss.polozenie.X, Boss.polozenie.Y, Boss.polozenie.Z, Boss.grubosci.X, Boss.grubosci.Y, Boss.grubosci.Z, 20,2); rysow.draw_floor(); cuboPlayer.angle = -1f * Angle_between_wektor_X_Z(cuboPlayer.polozenie, CursorWektor); rysow.DrawPlayer(cuboPlayer.polozenie, cuboPlayer.grubosci, cuboPlayer.angle); gl.Enable(SharpGL.OpenGL.GL_BLEND); gl.BlendFunc(SharpGL.OpenGL.GL_SRC_ALPHA,SharpGL.OpenGL.GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); rysow.DrawCubo_with_alpha(CursorWektor.X, CursorWektor.Y, CursorWektor.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y, cuboPlayer.grubosci.Z, rotation * 2,0.3f); rysow.DrawCubo_with_alpha(CursorWektorAngled.X,CursorWektorAngled.Y,CursorWektorAngled.Z, cuboPlayer.grubosci.X, cuboPlayer.grubosci.Y*3, cuboPlayer.grubosci.Z, (float)(1.5 * -1) * rotation ,0.3f); //player config int hour_0_to_7; hour_0_to_7 = 900000; if (KeyW && !KeyA && !KeyD && !KeyS) { hour_0_to_7 = -1; } if (!KeyW && !KeyA && !KeyD && KeyS) { hour_0_to_7 = 4; } if (!KeyW && KeyA && !KeyD && !KeyS) { hour_0_to_7 = 6; } if (!KeyW && !KeyA && KeyD && !KeyS) { hour_0_to_7 = 2; } if (KeyA && KeyS && !KeyW) { hour_0_to_7 = 5; } if (KeyS && KeyD && !KeyW) { hour_0_to_7 = 3; } if (KeyD && KeyW) { hour_0_to_7 = 1; } if (KeyW && KeyA) { hour_0_to_7 = 7; } Wektor temp; temp = new Wektor(0.0f, 0.0f, 0.2f); if (Math.Abs(cuboPlayer.predkosc.X) < 0.2f && Math.Abs(cuboPlayer.predkosc.Z) < 0.2f) { switch (hour_0_to_7) { case -1: cuboPlayer.predkosc = RotateWektorOnZero(temp, 315); break; case 1: cuboPlayer.predkosc = temp; // cuboPlayer.predkosc.Z += 0.21f; Debug.WriteLine(RotateWektorOnZero(temp, 45).X + " " + RotateWektorOnZero(temp, 45).Z); break; case 2: cuboPlayer.predkosc = RotateWektorOnZero(temp, 45); //cuboPlayer.predkosc.Z += RotateWektorOnZero(temp, 90).Z; Debug.WriteLine(RotateWektorOnZero(temp, 90).X + " " + RotateWektorOnZero(temp, 90).Z); break; case 3: cuboPlayer.predkosc = RotateWektorOnZero(temp, 90); break; case 4: cuboPlayer.predkosc = RotateWektorOnZero(temp, 135); break; case 5: cuboPlayer.predkosc = RotateWektorOnZero(temp, 180); break; case 6: cuboPlayer.predkosc = RotateWektorOnZero(temp, 225); break; case 7: cuboPlayer.predkosc = RotateWektorOnZero(temp, 270); break; // default: // cuboPlayer.wycisz_predkosc_only_XZ_o(0.1f); } } cuboPlayer.wycisz_predkosc_only_XZ_o(0.01f); cuboPlayer.krok_naprzod(); if (bulletOne != null) { bulletOne.krok_naprzod(); } Boss.krok_naprzod(); // foreach (KwadratMaterialnyPocisk prime in listaPociskow) // Loop through List with foreach. // { // prime.krok_naprzod(); // } for (int i = 0; i < listaPociskow.Count; i++) // Loop with for. { if (listaPociskow[i].vitality < 1) { listaPociskow.RemoveAt(i); } else { listaPociskow[i].krok_naprzod(); } } //foreach (KwadratMaterialnyPocisk prime in listaPociskowPlayera) // Loop through List with foreach. //{ // if (prime.vitality < 3) // { // listaPociskowPlayera.Remove(prime); // } // else // { // prime.krok_naprzod(); // } //} for (int i = 0; i < listaPociskowPlayera.Count; i++) // Loop with for. { if(czy_nachodza(listaPociskowPlayera[i].polozenie,Boss.polozenie,Boss.grubosci.X)) { Boss.Live--; Debug.WriteLine("nachodza"); } if (listaPociskowPlayera[i].vitality < 3) { listaPociskowPlayera.RemoveAt(i); } else { listaPociskowPlayera[i].krok_naprzod(); } } if(Boss.counter%250 == 0) { listaPociskow = new List<KwadratMaterialnyPocisk>(); for (int i = 0; i < 13; i++) { listaPociskow.Add(new KwadratMaterialnyPocisk(Boss.polozenie, losowyWektorPredkosci(), 20)); } } // cuboOne.daj_kat_kwadrata(); // Nudge the rotation. rotation += 3.0f; Wektor inc; inc = new Wektor(0.01f, 0.0f, 0.0f); da += inc; re= re * 1.01f; if (bulletOne != null) { if (bulletOne.vitality < 0) { bulletOne = null; } } }