basic movement
This commit is contained in:
@@ -5,26 +5,33 @@
|
||||
namespace Game::AGame {
|
||||
void Player::start() {
|
||||
mSound = Object::Sound("../resources/example.wav", Object::Format::WAV);
|
||||
mSound.play();
|
||||
//mSound.play();
|
||||
|
||||
int w, h;
|
||||
SDL_GetWindowSizeInPixels(Window::Window::getSDLWindowBackend(), &w, &h);
|
||||
|
||||
mTransform.x = w / 2.f - (mTex->getWidth() / 2.f * mTransform.scaleX * 0.25f); // Start in the middle of the screen
|
||||
mTransform.y = h / 2.f - (mTex->getHeight() / 2.f * mTransform.scaleY * 0.25f);
|
||||
mTransform.rotation = 0.f;
|
||||
mTransform.x -= mTex->getWidth() * mTransform.adjustedScaleX() / 2.f;
|
||||
mTransform.y -= mTex->getHeight() * mTransform.adjustedScaleY() / 2.f;
|
||||
|
||||
LOG("W: " << w << " H: " << h);
|
||||
|
||||
mSound.~Sound();
|
||||
}
|
||||
|
||||
void Player::update(float deltaTime) {
|
||||
if (!mIsActive) return;
|
||||
//LOG("Updated Player");
|
||||
//mTransform.x += 1.f; // Move right at a constant speed for testing
|
||||
mTransform.rotation += 1.f; // Rotate clockwise for testing
|
||||
//LOG(mName << " position: " << mTransform.x << ' ' << mTransform.y);
|
||||
//LOG("DeltaTime: " << deltaTime);
|
||||
mTransform.scaleX = 1.f + 1.f * std::sin(RUNNING_TIME() / 0.5f); // Pulsate scale for testing
|
||||
mTransform.scaleY = 1.f + 0.5f * std::cos(RUNNING_TIME() / 0.5f); // Pulsate scale for testing
|
||||
//mTransform.rotation += 1.f; // Rotate clockwise for testing
|
||||
//mTransform.scaleX = 1.f + 1.f * std::sin(RUNNING_TIME() / 0.5f); // Pulsate scale for testing
|
||||
//mTransform.scaleY = 1.f + 0.5f * std::cos(RUNNING_TIME() / 0.5f); // Pulsate scale for testing
|
||||
|
||||
//Object::Camera::getInstance().move(1.f, 0.f);
|
||||
|
||||
// Simple movement
|
||||
const bool* state = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
if (state[SDL_SCANCODE_W]) mTransform.y -= mSpeed * deltaTime;
|
||||
if (state[SDL_SCANCODE_S]) mTransform.y += mSpeed * deltaTime;
|
||||
if (state[SDL_SCANCODE_A]) mTransform.x -= mSpeed * deltaTime;
|
||||
if (state[SDL_SCANCODE_D]) mTransform.x += mSpeed * deltaTime;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user