Update Gitignore and Basic Camera / Level Implementation

This commit is contained in:
2024-03-08 12:27:04 +01:00
parent 3dcfc744d5
commit 9dbfef5e78
15 changed files with 209 additions and 63 deletions

View File

@@ -1,8 +1,11 @@
#include "pch.h"
#include "Game.h"
#include "utils.h"
Game::Game(const Window& window)
: BaseGame { window } {
: BaseGame { window }
{
Initialize();
}
@@ -11,27 +14,34 @@ Game::~Game() {
}
void Game::Initialize() {
m_WorldLevel = WorldLevel();
}
void Game::Cleanup() {
}
void Game::Update(float elapsedSec) {
// Check keyboard state
//const Uint8 *pStates = SDL_GetKeyboardState( nullptr );
//if ( pStates[SDL_SCANCODE_RIGHT] )
//{
// std::cout << "Right arrow key is down\n";
//}
//if ( pStates[SDL_SCANCODE_LEFT] && pStates[SDL_SCANCODE_UP])
//{
// std::cout << "Left and up arrow keys are down\n";
//}
const Uint8 *pStates = SDL_GetKeyboardState( nullptr );
if ( pStates[SDL_SCANCODE_RIGHT] ) {
m_CameraOffset.x += 100 * elapsedSec;
}
if ( pStates[SDL_SCANCODE_LEFT] ) {
m_CameraOffset.x -= 100 * elapsedSec;
}
}
void Game::Draw() const {
ClearBackground();
glPushMatrix();
{
glTranslatef(m_CameraOffset.x , m_CameraOffset.y, 0);
m_WorldLevel.Draw();
utils::SetColor(Color4f{1.0f, 0.0f, 0.0f, 1.0f});
utils::FillEllipse(0,0,20,20);
}
glPopMatrix();
}
void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {