Commit 0d607cb6 authored by Gerstrong's avatar Gerstrong

Galaxy Keen now snaps to the center of a door where you would enter.

parent 5d91d5a7
......@@ -370,9 +370,7 @@ bool CMap::scrollUp(const bool force)
// called at start of level to draw the upper-left corner of the map
// onto the scrollbuffer...from then on the map will only be drawn
// in stripes as it scrolls around.
// TODO: This function has a mayor problem! It only works, when tile same on the screen
// are changed. In Vorticons this might be the case. In Galaxy it's different!
void CMap::redrawAt(int mx, int my)
void CMap::redrawAt(const Uint32 mx, const Uint32 my)
{
SDL_Surface *ScrollSurface = g_pVideoDriver->getScrollSurface();
// Go throught the list and just draw all the tiles that need to be animated
......
......@@ -47,7 +47,7 @@ public:
bool scrollUp(const bool force=false);
bool scrollDown(const bool force=false);
void redrawAt(int mx, int my);
void redrawAt(const Uint32 mx, const Uint32 my);
void drawAll();
void drawHstripe( unsigned int y, unsigned int mpy );
void drawVstripe( unsigned int x, unsigned int mpx );
......
......@@ -40,6 +40,12 @@ struct BouncingBox{
unsigned int l_y1 = 0, unsigned int l_y2 = 0 ) :
x1(l_x1), x2(l_x2),
y1(l_y1), y2(l_y2) {}
unsigned int Width()
{ return (x2-x1); }
unsigned int Height()
{ return (y2-y1); }
};
......
......@@ -47,7 +47,7 @@ CMessages::extractString( std::string matchingstring, unsigned long start, unsig
return make_pair(matchingstring, Text);
}
void CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap)
bool CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap)
{
switch(m_version)
{
......@@ -105,9 +105,10 @@ void CMessages::extractEp4Strings(std::map<std::string, std::string>& StringMap)
StringMap.insert( extractString( "KEEN_LAST_ELDER_TEXT", 0x30B6B, 0x30BB2 ) );
StringMap.insert( extractString( "ELDERS_UNDERWATER_TEXT", 0x30BB3, 0x30C16 ) );
StringMap.insert( extractString( "ELDERS_TEXT", 0x30C17, 0x30C6A ) );
return true;
} break;
}
return false;
}
bool CMessages::extractGlobalStrings()
......
......@@ -22,7 +22,7 @@ private:
std::pair<std::string, std::string>
extractString( std::string matchingstring, unsigned long start, unsigned long end, long offset=0 );
void extractEp4Strings(std::map<std::string, std::string>& StringMap);
bool extractEp4Strings(std::map<std::string, std::string>& StringMap);
unsigned char *mp_exe;
char m_episode;
......
......@@ -12,6 +12,7 @@
#include "sdl/CInput.h"
#include "sdl/sound/CSound.h"
#include "CVec.h"
#include "CLogFile.h"
namespace galaxy {
......@@ -35,7 +36,8 @@ const int FIRE_RECHARGE_TIME = 5;
CPlayerLevel::CPlayerLevel(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>& ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode) :
CPlayerBase(pmap, x, y, ObjectPtrs, facedir, l_Inventory, Cheatmode)
CPlayerBase(pmap, x, y, ObjectPtrs, facedir, l_Inventory, Cheatmode),
m_jumpdownfromobject(false)
{
mp_processState = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
......@@ -549,17 +551,17 @@ void CPlayerLevel::processPressUp() {
return 1;
} */
flag = Tile[mp_Map->getPlaneDataAt(1, x_left, up_y)].behaviour;
int flag_left = Tile[mp_Map->getPlaneDataAt(1, x_left, up_y)].behaviour;
// entering a door
if ( !m_EnterDoorAttempt && (flag == MISCFLAG_DOOR || flag == MISCFLAG_KEYCARDDOOR) )
if ( !m_EnterDoorAttempt && (flag_left == MISCFLAG_DOOR || flag_left == MISCFLAG_KEYCARDDOOR) )
{
//int var2 = mid_x * 256+96;
flag = Tile[mp_Map->getPlaneDataAt(1, x_right, up_y)].behaviour;
int flag_right = Tile[mp_Map->getPlaneDataAt(1, x_left+(1<<CSF), up_y)].behaviour;
//if (flag2 == MISCFLAG_DOOR || flag2 == MISCFLAG_KEYCARDDOOR) var2-=256;
//if (getXPosition() == var2) {
if(flag == MISCFLAG_DOOR || flag == MISCFLAG_KEYCARDDOOR) {
if(flag_right == MISCFLAG_DOOR || flag_right == MISCFLAG_KEYCARDDOOR) {
/*if (flag == MISCFLAG_KEYCARDDOOR) {
if (security_card) {
security_card = 0;
......@@ -583,6 +585,17 @@ void CPlayerLevel::processPressUp() {
}
} else {*/
setAction(A_KEEN_ENTER_DOOR);
setActionSprite();
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
// Here the Player will be snapped to the center
const int x_l = (x_left>>CSF);
const int x_r = x_l+1;
const int x_mid = ( ((x_l+x_r)<<CSF) - (rSprite.getWidth()<<STC)/2 )/2;
moveToHorizontal(x_mid);
mp_processState = (void (CPlayerBase::*)()) &CPlayerLevel::processEnterDoor;
m_EnterDoorAttempt = true;
return;
......@@ -1388,7 +1401,10 @@ void CPlayerLevel::process()
}
if(supportedbyobject)
{
g_pLogFile->textOut("Collision Check 2\n");
blockedd = true;
}
}
(this->*mp_processState)();
......
......@@ -6,6 +6,7 @@
*/
#include "CPlatform.h"
#include "CLogFile.h"
namespace galaxy {
......@@ -81,7 +82,7 @@ void CPlatform::getTouchedBy(CObject &theObject)
{
if(theObject.m_type == OBJ_PLAYER)
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
CPlayerLevel &Player = dynamic_cast<CPlayerLevel&>(theObject);
const int m_py2 = Player.getYDownPos();
const int m_y2 = getYUpPos()+(4<<STC);
......
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