mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 14:41:49 +01:00
Fix Collision add basic digging
This commit is contained in:
@@ -24,7 +24,7 @@ Game::~Game() {
|
||||
}
|
||||
|
||||
void Game::Initialize() {
|
||||
m_Camera.SetPosition(Point2f{GetViewPort().width / 2, GetViewPort().height / 2});
|
||||
m_Camera.SetPosition(Point2f{-GetViewPort().width / 2, -GetViewPort().height / 2});
|
||||
}
|
||||
|
||||
void Game::Cleanup() {
|
||||
@@ -34,12 +34,13 @@ void Game::Update(float elapsedSec) {
|
||||
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
if(m_IsRightMouseDown) {
|
||||
Point2f newCameraPos = m_MousePos + m_MouseOffset;
|
||||
m_Camera.SetPosition(newCameraPos);
|
||||
Point2f newCameraPos = Point2f{m_MousePos.x + m_MouseOffset.x, m_MousePos.y + m_MouseOffset.y};
|
||||
m_Camera.SetPosition(Point2f{-newCameraPos.x, -newCameraPos.y});
|
||||
} else {
|
||||
m_MouseOffset = m_Camera.GetPosition();
|
||||
}
|
||||
|
||||
|
||||
m_WorldLevel.Update(elapsedSec);
|
||||
|
||||
}
|
||||
@@ -64,7 +65,7 @@ void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
|
||||
|
||||
void Game::ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
|
||||
m_IsRightMouseDown = e.button == SDL_BUTTON_RIGHT;
|
||||
m_MouseOffset = Point2f{m_Camera.GetPosition().x - m_MousePos.x, m_Camera.GetPosition().y - m_MousePos.y};
|
||||
m_MouseOffset = Point2f{-m_Camera.GetPosition().x - m_MousePos.x, -m_Camera.GetPosition().y - m_MousePos.y};
|
||||
}
|
||||
|
||||
void Game::ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
|
||||
|
||||
Reference in New Issue
Block a user