Danbias/Code/GameLogic/Game.cpp

68 lines
1.1 KiB
C++
Raw Normal View History

2013-11-19 09:52:36 +01:00
#include "Game.h"
using namespace GameLogic;
Game::Game(void)
{
2013-11-29 10:04:44 +01:00
player = NULL;
level = NULL;
camera = NULL;
2013-11-19 09:52:36 +01:00
}
Game::~Game(void)
{
//SAFE_DELETE(player);
if(player)
{
delete player;
player = NULL;
}
2013-11-29 10:04:44 +01:00
if(camera)
{
delete camera;
camera = NULL;
}
2013-11-19 09:52:36 +01:00
}
2013-11-19 11:07:14 +01:00
void Game::Init()
{
2013-11-21 12:05:39 +01:00
player = new Player();
2013-11-29 10:04:44 +01:00
camera = new Camera();
2013-11-19 11:07:14 +01:00
}
2013-11-20 15:47:11 +01:00
void Game::StartGame()
{
2013-11-29 10:04:44 +01:00
Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1);
Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0);
Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100);
2013-11-20 15:47:11 +01:00
2013-11-29 10:04:44 +01:00
camera->LookAt(pos, dir, up);
camera->SetLens(3.14f/2, 1024/768, 1, 1000);
2013-11-20 15:47:11 +01:00
}
2013-11-29 10:04:44 +01:00
void Game::Update(keyInput keyPressed, float pitch, float yaw)
2013-11-20 15:47:11 +01:00
{
2013-11-29 10:04:44 +01:00
//player->Update(keyPressed);
camera->Yaw(yaw);
camera->Pitch(pitch);
if(keyPressed == keyInput_A)
{
camera->Strafe(-0.1);
}
if(keyPressed == keyInput_D)
{
camera->Strafe(0.1);
}
if(keyPressed == keyInput_S)
{
camera->Walk(-0.1);
}
if(keyPressed == keyInput_W)
{
camera->Walk(0.1);
}
camera->UpdateViewMatrix();
}
2013-11-21 12:05:39 +01:00
void Game::Render()
{
2013-11-29 10:04:44 +01:00
Oyster::Graphics::API::NewFrame(camera->View(), camera->Proj());
player->Render();
2013-11-21 12:05:39 +01:00
}