Commit dc2fb79b authored by Gerhard Stein's avatar Gerhard Stein

camera is starting to work on the galaxy map

parent 3f9d43dd
......@@ -50,13 +50,17 @@ m_blinktime(0)
touchPlayer = touchedBy = 0;
cansupportplayer = false;
setupObjectType(g_pBehaviorEngine->getEpisode());
if(m_type != OBJ_NONE)
{
setupObjectType(g_pBehaviorEngine->getEpisode());
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
bboxX1 = rSprite.m_bboxX1; bboxX2 = rSprite.m_bboxX2;
bboxY1 = rSprite.m_bboxY1; bboxY2 = rSprite.m_bboxY2;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
bboxX1 = rSprite.m_bboxX1; bboxX2 = rSprite.m_bboxX2;
bboxY1 = rSprite.m_bboxY1; bboxY2 = rSprite.m_bboxY2;
checkinitialCollisions();
}
checkinitialCollisions();
}
void CObject::setupObjectType(int Episode)
......
......@@ -15,6 +15,8 @@
#include "CCamera.h"
#include "../CLogFile.h"
#include "../sdl/CVideoDriver.h"
#include "../sdl/CInput.h"
CCamera::CCamera(CMap *pmap, Uint32 x, Uint32 y):
CObject(pmap, x, y, OBJ_NONE),
......@@ -28,14 +30,22 @@ mp_AttachedObject(NULL)
* automatically with it
*/
void CCamera::attachToObject(CObject &attacher)
{ mp_AttachedObject = &attached; }
{ mp_AttachedObject = &attacher; }
/**
* This function will dettach the camera from a object.
* If this happens, the camera can be scrolled manually.
*/
bool CCamera::detach()
{return false;}
{
if(!mp_AttachedObject)
return false;
else
{
mp_AttachedObject = NULL;
return true;
}
}
/**
* This is main cycle which will be called every Logic loop
......@@ -46,7 +56,14 @@ void CCamera::process()
{
if(mp_AttachedObject == NULL)
{ // This means, that there is no attached object. Let the camera scroll freely!
if(g_pInput->getHoldedCommand(IC_LEFT))
moveLeft();
else if(g_pInput->getHoldedCommand(IC_RIGHT))
moveRight();
if(g_pInput->getHoldedCommand(IC_UP))
moveUp();
else if(g_pInput->getHoldedCommand(IC_DOWN))
moveDown();
}
}
......@@ -54,25 +71,33 @@ void CCamera::process()
* Move the camera left also checking the bounds
*/
void CCamera::moveLeft()
{}
{
mp_Map->scrollLeft();
}
/**
* Move the camera right also checking the bounds
*/
void CCamera::moveRight()
{}
{
mp_Map->scrollRight();
}
/**
* Move the camera up also checking the bounds
*/
void CCamera::moveUp()
{}
{
mp_Map->scrollUp();
}
/**
* Move the camera down also checking the bounds
*/
void CCamera::moveDown()
{}
{
mp_Map->scrollDown();
}
CCamera::~CCamera()
{
......
......@@ -15,7 +15,7 @@
#include "../../fileio.h"
#include "../../sdl/CVideoDriver.h"
#include "../../CLogFile.h"
#include "../../CLogFile.h"
#include "../CCamera.h"
#include <fstream>
CMapLoaderGalaxy::CMapLoaderGalaxy(CExeFile &ExeFile, std::vector<CObject*>& ObjectPtr):
......
......@@ -11,6 +11,8 @@
#include "../../fileio/CExeFile.h"
#include "../../fileio/TypeDefinitions.h"
#include "../../common/CMap.h"
#include "../../common/CObject.h"
#include <vector>
#include <string>
#include <SDL.h>
......
......@@ -73,32 +73,7 @@ void CPlayGameGalaxy::process()
void CPlayGameGalaxy::processInput()
{
// TODO: wrap this into the camera class they way it can be used in the vorticons engine
// Also make it more efficient.
/*if(g_pInput->getPressedCommand(IC_QUIT))
m_endgame = true;
if(g_pInput->getHoldedCommand(IC_LEFT))
{
m_Map.scrollLeft();
m_Map.scrollLeft();
}
else if(g_pInput->getHoldedCommand(IC_RIGHT))
{
m_Map.scrollRight();
m_Map.scrollRight();
}
if(g_pInput->getHoldedCommand(IC_UP))
{
m_Map.scrollUp();
m_Map.scrollUp();
}
else if(g_pInput->getHoldedCommand(IC_DOWN))
{
m_Map.scrollDown();
m_Map.scrollDown();
}*/
}
void CPlayGameGalaxy::processRendering()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment