Merge branch 'Kolizja-Pod-Klawiszem-K' of https://gitea.7o7.cx/sherl/grafikaKBT into Kolizja-Pod-Klawiszem-K

This commit is contained in:
Pc
2025-01-19 18:06:51 +01:00
2 changed files with 15 additions and 14 deletions

View File

@@ -1,4 +1,3 @@
#pragma once
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>

View File

@@ -121,14 +121,14 @@ float velocity = 0.0f; // Aktualna prędkość łazika
float rotationVelocity = 0.0f; // Prędkość obrotu łazika float rotationVelocity = 0.0f; // Prędkość obrotu łazika
const float friction = 0.01f; // Współczynnik tarcia (μ) const float friction = 0.1f; // Współczynnik tarcia (μ)
const float maxSpeed = 5.0f; // Maksymalna prędkość łazika const float maxSpeed = 5.0f; // Maksymalna prędkość łazika
const float acceleration = 0.2f; const float acceleration = 0.2f;
const float rotationAcceleration = 0.075f; // Przyspieszenie obrotu const float rotationAcceleration = 0.075f; // Przyspieszenie obrotu
const float rotationFriction = 0.1f; // Współczynnik tarcia obrotu const float rotationFriction = 0.1f; // Współczynnik tarcia obrotu
const float maxRotationSpeed = 1.0f; // Maksymalna prędkość obrotu const float maxRotationSpeed = 0.7f; // Maksymalna prędkość obrotu
// Struktura do reprezentacji płotu // Struktura do reprezentacji płotu
struct Plot { struct Plot {
@@ -417,7 +417,7 @@ static unsigned char* LoadBitmapFile(char* filename, BITMAPINFOHEADER* bitmapInf
return bitmapImage; return bitmapImage;
} }
static void SetDCPixelFormat(HDC hDC) { void SetDCPixelFormat(HDC hDC) {
int nPixelFormat; int nPixelFormat;
static PIXELFORMATDESCRIPTOR pfd = { static PIXELFORMATDESCRIPTOR pfd = {
@@ -862,7 +862,8 @@ static void SetupRC() {
// All materials hereafter have full specular reflectivity // All materials hereafter have full specular reflectivity
// with a high shine // with a high shine
glMaterialfv(GL_FRONT, GL_SPECULAR, specref); GLfloat specref2[] = {0.2f, 0.2f, 0.2f, 0.2f};
glMaterialfv(GL_FRONT, GL_SPECULAR, specref2);
glMateriali(GL_FRONT, GL_SHININESS, 128); glMateriali(GL_FRONT, GL_SHININESS, 128);
// White background // White background
@@ -922,22 +923,23 @@ void static RenderScene(void) {
// Przywrócenie macierzy widoku // Przywrócenie macierzy widoku
gluLookAt( gluLookAt(
Foward - 50.0f * sin((Rotation + 180.0f) * GL_PI / 180.0f), // Pozycja kamery Foward - 50.0f * sin((Rotation + 180.0f) * GL_PI / 180.0f), // Pozycja kamery
CameraHeight/4, // Wysokość kamery CameraHeight/4, // Wysokość kamery
Sides - 50.0f * cos((Rotation + 180.0f) * GL_PI / 180.0f), // Kamera wzdłuż osi X i Z Sides - 50.0f * cos((Rotation + 180.0f) * GL_PI / 180.0f), // Kamera wzdłuż osi X i Z
Foward, 0.0f, Sides, // Punkt patrzenia (łazik) Foward, 0.0f, Sides, // Punkt patrzenia (łazik)
0.0f, 1.0f, 0.0f // Wektor "góry" 0.0f, 1.0f, 0.0f // Wektor "góry"
); );
// Rysowanie mapy // Rysowanie mapy
glPushMatrix(); glPushMatrix();
glColor3f(0.0, 1.0, 0.0); // Zielony kolor glColor3f(0.0, 1.0, 0.0); // Zielony kolor
mapa.draw();
platforma(50.0f, 0.0f, 45.0f, 600.0f, 650.0f); platforma(50.0f, 0.0f, 45.0f, 600.0f, 650.0f);
glPopMatrix(); glPopMatrix();
// Rysowanie łazika // Rysowanie łazika
glPushMatrix(); glPushMatrix();
glTranslatef(Foward, 0.0f, Sides); // Translacja łazika glTranslatef(Foward, 0.0f, Sides); // Translacja łazika
glRotatef(Rotation, 0.0f, 1.0f, 0.0f); // Obrót łazika glRotatef(Rotation, 0.0f, 1.0f, 0.0f); // Obrót łazika
glColor3f(1.0, 0.0, 0.0); // Czerwony kolor dla łazika glColor3f(1.0, 0.0, 0.0); // Czerwony kolor dla łazika
@@ -947,10 +949,10 @@ void static RenderScene(void) {
glPopMatrix(); glPopMatrix();
// Rysowanie innych obiektów // Rysowanie innych obiektów
plot(-550.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0); plot(-550.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0); // 0 - pionowo
plot(50.0f, 3.0f, -600.0f, 1200.0f, 4.0f, 1); plot( 50.0f, 3.0f, -600.0f, 1200.0f, 4.0f, 1); // 1 - poziomo
plot(650.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0); plot( 650.0f, 3.0f, 50.0f, 1310.0f, 4.0f, 0);
plot(50.0f, 3.0f, 695.0f, 1200.0f, 4.0f, 1); plot( 50.0f, 3.0f, 695.0f, 1200.0f, 4.0f, 1);
stodola(10.0f, 0.0f, 2.0f, 40.0f); stodola(10.0f, 0.0f, 2.0f, 40.0f);
// Zamiana buforów (double buffering) // Zamiana buforów (double buffering)