2013-11-19 09:52:36 +01:00
|
|
|
#include "Game.h"
|
2013-12-03 11:47:04 +01:00
|
|
|
|
2013-11-19 09:52:36 +01:00
|
|
|
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)
|
|
|
|
{
|
2013-11-27 16:17:47 +01:00
|
|
|
//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-12-03 11:47:04 +01:00
|
|
|
//Oyster::Physics::API::SetSubscription("remove object");
|
|
|
|
|
|
|
|
player = new Player(L"worldDummy");
|
|
|
|
|
|
|
|
box = new DynamicObject(L"crate");
|
|
|
|
//poi
|
|
|
|
//box = new physcTestObj("box");
|
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-12-03 11:47:04 +01:00
|
|
|
//poi Oyster::Physics::API::Update();
|
2013-11-20 15:47:31 +01:00
|
|
|
}
|
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());
|
2013-11-28 11:23:11 +01:00
|
|
|
player->Render();
|
2013-12-03 11:47:04 +01:00
|
|
|
box->Render();
|
2013-11-21 12:05:39 +01:00
|
|
|
}
|