mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 12:21:48 +01:00
Update Gitignore and Basic Camera / Level Implementation
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user