corrected moving ship added moving camera

This commit is contained in:
Ariari04 2025-12-29 18:59:06 +06:00
parent 47fe0c4719
commit 96deb8b393
2 changed files with 783 additions and 718 deletions

1333
Game.cpp

File diff suppressed because it is too large Load Diff

168
Game.h
View File

@ -1,83 +1,87 @@
#pragma once #pragma once
#include "OpenGlExtensions.h" #include "OpenGlExtensions.h"
#include "Renderer.h" #include "Renderer.h"
#include "Environment.h" #include "Environment.h"
#include "TextureManager.h" #include "TextureManager.h"
namespace ZL { namespace ZL {
struct BoxCoords struct BoxCoords
{ {
Vector3f pos; Vector3f pos;
Matrix3f m; Matrix3f m;
}; };
class Game { class Game {
public: public:
Game(); Game();
~Game(); ~Game();
void setup(); void setup();
void update(); void update();
void render(); void render();
bool shouldExit() const { return Environment::exitGameLoop; } bool shouldExit() const { return Environment::exitGameLoop; }
private: private:
void processTickCount(); void processTickCount();
void drawScene(); void drawScene();
void drawCubemap(); void drawCubemap();
void drawShip(); void drawShip();
void drawBoxes(); void drawBoxes();
void drawUI(); void drawUI();
SDL_Window* window; SDL_Window* window;
SDL_GLContext glContext; SDL_GLContext glContext;
Renderer renderer; Renderer renderer;
size_t newTickCount; size_t newTickCount;
size_t lastTickCount; size_t lastTickCount;
static const size_t CONST_TIMER_INTERVAL = 10; static const size_t CONST_TIMER_INTERVAL = 10;
static const size_t CONST_MAX_TIME_INTERVAL = 1000; static const size_t CONST_MAX_TIME_INTERVAL = 1000;
std::shared_ptr<Texture> spaceshipTexture; std::shared_ptr<Texture> spaceshipTexture;
std::shared_ptr<Texture> cubemapTexture; std::shared_ptr<Texture> cubemapTexture;
VertexDataStruct spaceshipBase; VertexDataStruct spaceshipBase;
VertexRenderStruct spaceship; VertexRenderStruct spaceship;
VertexRenderStruct cubemap; VertexRenderStruct cubemap;
std::shared_ptr<Texture> boxTexture; std::shared_ptr<Texture> boxTexture;
VertexDataStruct boxBase; VertexDataStruct boxBase;
std::vector<BoxCoords> boxCoordsArr; std::vector<BoxCoords> boxCoordsArr;
std::vector<VertexRenderStruct> boxRenderArr; std::vector<VertexRenderStruct> boxRenderArr;
std::shared_ptr<Texture> buttonTexture; std::shared_ptr<Texture> buttonTexture;
VertexRenderStruct button; VertexRenderStruct button;
std::shared_ptr<Texture> musicVolumeBarTexture; std::shared_ptr<Texture> musicVolumeBarTexture;
VertexRenderStruct musicVolumeBar; VertexRenderStruct musicVolumeBar;
std::shared_ptr<Texture> musicVolumeBarButtonTexture; std::shared_ptr<Texture> musicVolumeBarButtonTexture;
VertexRenderStruct musicVolumeBarButton; VertexRenderStruct musicVolumeBarButton;
bool isDraggingVolume = false; bool isDraggingVolume = false;
float musicVolume = 1.0f; bool isDraggingShip = false;
float volumeBarMinX = 1190.0f; bool isDraggingCamera = false;
float volumeBarMaxX = 1200.0f; bool shipMoveLockActive = false;
float volumeBarMinY = 100.0f; Matrix3f lockedCameraMat = Matrix3f::Identity();
float volumeBarMaxY = 600.0f; float musicVolume = 1.0f;
float musicVolumeBarButtonButtonCenterX = 1195.0f; float volumeBarMinX = 1190.0f;
float musicVolumeBarButtonButtonRadius = 25.0f; float volumeBarMaxX = 1200.0f;
void UpdateVolumeFromMouse(int mouseX, int mouseY); float volumeBarMinY = 100.0f;
void UpdateVolumeKnob(); float volumeBarMaxY = 600.0f;
}; float musicVolumeBarButtonButtonCenterX = 1195.0f;
float musicVolumeBarButtonButtonRadius = 25.0f;
void UpdateVolumeFromMouse(int mouseX, int mouseY);
void UpdateVolumeKnob();
};
} // namespace ZL } // namespace ZL