Commit f532bab3 authored by Gerhard Stein's avatar Gerhard Stein

Preparing support for other galaxy games and fixes

parent c5bf2acc
......@@ -264,21 +264,20 @@ bool CSpriteObject::hitdetectWithTilePropertyRect(const Uint16 Property, int &lx
bool CSpriteObject::turnAroundOnCliff( int x1, int x2, int y2 )
{
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
const int x_left = (x1-(1<<STC))>>CSF;
const int x_right = (x2+(1<<STC))>>CSF;
const int y_bottom = (y2+(1<<STC))>>CSF;
const int floor = TileProperty[mp_Map->at((x1)>>CSF, (y2+(1<<STC))>>CSF)].bup;
const int cliffleft = TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
const int cliffright = TileProperty[mp_Map->at((x2+(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
const int floorleft = TileProperty[mp_Map->at(x_left, y_bottom)].bup;
const int floorright = TileProperty[mp_Map->at(x_right, y_bottom)].bup;
if(floor != 1)
return 0;
if( !cliffleft && xDirection == LEFT )
if( !floorleft && xDirection == LEFT && floorright==1 )
{
blockedl = TileProperty[mp_Map->at((x2+(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
return 1;
}
if( !cliffright && xDirection == RIGHT )
if( !floorright && xDirection == RIGHT && floorleft==1 )
{
blockedr = TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
return 2;
......
......@@ -6,7 +6,7 @@
*/
#include "CLevelPlay.h"
#include "CMapLoaderGalaxy.h"
#include "ep4/CMapLoaderGalaxyEp4.h"
#include "sdl/input/CInput.h"
#include "sdl/CVideoDriver.h"
#include "sdl/music/CMusic.h"
......@@ -27,9 +27,12 @@ CMapPlayGalaxy(ExeFile, Inventory, Cheatmode)
void CLevelPlay::loadMap(const int level)
{
// Load the World map level.
CMapLoaderGalaxy MapLoader(mExeFile, mObjectPtr, mInventory, mCheatmode);
SmartPointer<CMapLoaderGalaxy> MapLoader;
MapLoader.loadMap( mMap, level );
if(g_pBehaviorEngine->getEpisode() == 4)
MapLoader = new CMapLoaderGalaxyEp4(mExeFile, mObjectPtr, mInventory, mCheatmode);
MapLoader->loadMap( mMap, level );
// Load the Background Music
g_pMusicPlayer->stop();
......
......@@ -23,38 +23,10 @@
/// AI Headers
// Episode 4
// General stuff
#include "engine/galaxy/ai/CPlayerWM.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
#include "engine/galaxy/ai/ep4/CPlayerDive.h"
#include "engine/galaxy/ai/ep4/CPoisonSlug.h"
#include "engine/galaxy/ai/ep4/CMadMushroom.h"
#include "engine/galaxy/ai/ep4/CCouncilMember.h"
#include "engine/galaxy/ai/ep4/CMiragia.h"
#include "engine/galaxy/ai/ep4/CDiveSuit.h"
#include "engine/galaxy/ai/ep4/CArachnut.h"
#include "engine/galaxy/ai/ep4/CBounder.h"
#include "engine/galaxy/ai/ep4/CDopeFish.h"
#include "engine/galaxy/ai/ep4/CWaterMine.h"
#include "engine/galaxy/ai/ep4/CDevilSprite.h"
#include "engine/galaxy/ai/ep4/CSchoolFish.h"
#include "engine/galaxy/ai/ep4/CLick.h"
#include "engine/galaxy/ai/ep4/CLindsey.h"
#include "engine/galaxy/ai/ep4/CWormmouth.h"
#include "engine/galaxy/ai/ep4/CSkypest.h"
#include "engine/galaxy/ai/ep4/CMimrock.h"
#include "engine/galaxy/ai/ep4/CEgg.h"
#include "engine/galaxy/ai/ep4/CBerkeloid.h"
#include "engine/galaxy/ai/ep4/CBlueBird.h"
#include "engine/galaxy/ai/ep4/CThunderCloud.h"
#include "engine/galaxy/ai/ep4/CTreasureEater.h"
// General stuff
#include "engine/galaxy/ai/CSpriteItem.h"
#include "engine/galaxy/ai/platforms.h"
#include "engine/galaxy/ai/CFlag.h"
#include <fstream>
......@@ -354,26 +326,12 @@ void CMapLoaderGalaxy::spawnFoes(CMap &Map)
// Some defines are hardcoded so it is easier to
// identify what type of foe/stuff is loaded
// Under Construction Platforms:
// 27-30 & 32 seem to be the actual platforms. There may be more of numbers lower than 27.
// 31 seem to be the stoppers, those are not created because the platform
// get this from the object map directly
const unsigned int PLATFORM_VERT_ALT = 27;
const unsigned int PLATFORM_HORIZ_ALT = 28;
const unsigned int PLATFORM_VERT = 29;
const unsigned int PLATFORM_HORIZ = 30;
// 31 does not count, because it's a blocker.
const unsigned int PLATFORM_DROP = 32;
const unsigned int DIVE_SUIT = 35;
/**
* @brief Loads a foe given by the coordiantes
*/
CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
{
CGalaxySpriteObject *p_newfoe = NULL;
VectorD2<Uint32> Location(x,y);
// Point Item Sprites (Candies, etc...)
for( Uint32 i=61 ; i<=67 ; i++ )
......@@ -401,8 +359,6 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
}
}
VectorD2<Uint32> loc(x,y);
switch(foe)
{
case 1:
......@@ -417,165 +373,9 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_ObjectPtr, m_Inventory, m_Cheatmode);
break;
case 4:
//This is a council member.
p_newfoe = new galaxy::CCouncilMember(&Map, foe, x, y-750);
break;
case 6:
//This is pincess Lindsey.
p_newfoe = new galaxy::CLindsey(&Map, foe, x, y-750);
break;
case 7:
// This is a wormmouth.
p_newfoe = new galaxy::CWormmouth(&Map, foe, x, y);
break;
case 8:
// This is Skypest.
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;
case 9:
//This is the Thunder Cloud
p_newfoe = new galaxy::CThunderCloud(&Map, foe, x, y);
break;
case 12:
//This is a Bounder.
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
p_newfoe = new galaxy::CBounder(&Map, foe, x, y-250);
break;
case 13:
// This is an egg
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
if( g_pBehaviorEngine->mDifficulty > 1 )
p_newfoe = new galaxy::CBlueBird(&Map, foe, x, y-(2<<CSF));
else
p_newfoe = new galaxy::CEgg(&Map, foe, x, y-(2<<CSF));
break;
case 18:
// This might be the treasure eater.
p_newfoe = new galaxy::CTreasureEater(&Map, foe, x, y);
break;
case 19:
//This is a Mimrock.
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
p_newfoe = new galaxy::CMimrock(&Map, foe, x, y);
break;
case 20:
// This is an Arachnut.
p_newfoe = new galaxy::CArachnut(&Map, foe, x, y);
break;
case 21:
// This is a Mad Mushroom.
p_newfoe = new galaxy::CMadMushroom(&Map, foe, x, y);
break;
case 22:
// This is a Poison Slug.
p_newfoe = new galaxy::CPoisonSlug(&Map, foe, x, y-250, m_ObjectPtr);
break;
case 23:
// This is a Sprite from the well of wishes.
p_newfoe = new galaxy::CDevilSprite(&Map, foe, x, y);
break;
case 24:
// This is a Sprite from the well of wishes.
p_newfoe = new galaxy::CSchoolFish(&Map, foe, x, y);
break;
/*case 25:
// This is Skypest.
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;*/
case PLATFORM_VERT: case PLATFORM_VERT_ALT:
p_newfoe = new galaxy::CPlatformVertical(&Map, foe, x, y); break;
case PLATFORM_HORIZ_ALT:
case PLATFORM_HORIZ:
p_newfoe = new galaxy::CPlatformHorizontal(&Map, foe, x, y); break;
case PLATFORM_DROP:
p_newfoe = new galaxy::CPlatformDrop(&Map, foe, x, y); break;
case 33:
// Place Miragia in Episode 4 on the Map
p_newfoe = new galaxy::CMiragia(&Map, foe, Location);
break;
case DIVE_SUIT:
// Place Miragia in Episode 4 on the Map
p_newfoe = new galaxy::CDiveSuit(&Map, foe, x, y);
break;
case 42:
// This is Keen in the swimming suit
p_newfoe = new galaxy::CPlayerDive(&Map, foe, x, y, m_ObjectPtr,
RIGHT, m_Inventory, m_Cheatmode);
break;
case 46:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;
case 47:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= NORMAL )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 48:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 50:
//This is the CBerkeloid
p_newfoe = new galaxy::CBerkeloid(&Map, foe, x, y);
break;
case 71:
// Watermine vertical
p_newfoe = new galaxy::CWaterMine(&Map, foe, x, y, true);
break;
case 72:
// Watermine horizontal
p_newfoe = new galaxy::CWaterMine(&Map, foe, x, y, false);
break;
case 87:
// Dope Fish
p_newfoe = new galaxy::CDopeFish(&Map, foe, x, y);
break;
case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc);
break;
default:
break;
default: break;
}
return p_newfoe;
}
......
......@@ -33,9 +33,10 @@ public:
bool gotoSignature(std::ifstream &MapFile);
bool loadMap(CMap &Map, Uint8 level);
void spawnFoes(CMap &Map);
CGalaxySpriteObject* addFoe(CMap &Map, word foe, size_t x, size_t y);
virtual CGalaxySpriteObject* addFoe(CMap &Map, word foe, size_t x, size_t y);
virtual ~CMapLoaderGalaxy() {}
private:
protected:
void unpackPlaneData(std::ifstream &MapFile,
CMap &Map, size_t PlaneNumber,
longword offset, longword length,
......
......@@ -198,6 +198,7 @@ void CPlayerLevel::processRunning()
nextX = nextY = 0;
state.jumpTimer = 18;
setAction(A_KEEN_JUMP);
playSound( SOUND_KEEN_JUMP );
return;
}
......@@ -219,6 +220,7 @@ void CPlayerLevel::processRunning()
xinertia = xDirection * 8;
yinertia = 0;
setAction(A_KEEN_FALL);
playSound( SOUND_KEEN_FALL );
state.jumpTimer = 0;
}
......@@ -300,6 +302,7 @@ void CPlayerLevel::handleInputOnGround()
nextY = 0;
state.jumpTimer = 18;
setAction(A_KEEN_JUMP);
playSound( SOUND_KEEN_JUMP );
return;
}
......@@ -354,6 +357,7 @@ void CPlayerLevel::processStanding()
xinertia = xDirection * 8;
yinertia = 0;
setAction(A_KEEN_FALL);
playSound( SOUND_KEEN_FALL );
state.jumpTimer = 0;
}
......@@ -459,7 +463,7 @@ void CPlayerLevel::processLookingDown()
blockedd = false;
yinertia = 0;
xinertia = 0;
setAction(A_KEEN_FALL);
setAction(A_KEEN_JUMP_DOWN);
playSound( SOUND_KEEN_FALL );
}
......@@ -1598,6 +1602,7 @@ void CPlayerLevel::performPoleHandleInput()
yinertia = -80;
state.jumpTimer = 10;
setAction(A_KEEN_JUMP);
playSound( SOUND_KEEN_JUMP );
yDirection = 1;
m_climbing = false;
m_jumped = true;
......@@ -1815,6 +1820,7 @@ void CPlayerLevel::verifyFalling()
xinertia = xDirection * 16;
yinertia = 0;
setAction(A_KEEN_FALL);
playSound( SOUND_KEEN_FALL );
state.jumpTimer = 0;
}
}
......
/*
* CMapLoaderGalaxyEp4.cpp
*
* Created on: 28.07.2012
* Author: gerstrong
*/
#include "CMapLoaderGalaxyEp4.h"
// Episode 4
#include "engine/galaxy/ai/ep4/CPlayerDive.h"
#include "engine/galaxy/ai/ep4/CPoisonSlug.h"
#include "engine/galaxy/ai/ep4/CMadMushroom.h"
#include "engine/galaxy/ai/ep4/CCouncilMember.h"
#include "engine/galaxy/ai/ep4/CMiragia.h"
#include "engine/galaxy/ai/ep4/CDiveSuit.h"
#include "engine/galaxy/ai/ep4/CArachnut.h"
#include "engine/galaxy/ai/ep4/CBounder.h"
#include "engine/galaxy/ai/ep4/CDopeFish.h"
#include "engine/galaxy/ai/ep4/CWaterMine.h"
#include "engine/galaxy/ai/ep4/CDevilSprite.h"
#include "engine/galaxy/ai/ep4/CSchoolFish.h"
#include "engine/galaxy/ai/ep4/CLick.h"
#include "engine/galaxy/ai/ep4/CLindsey.h"
#include "engine/galaxy/ai/ep4/CWormmouth.h"
#include "engine/galaxy/ai/ep4/CSkypest.h"
#include "engine/galaxy/ai/ep4/CMimrock.h"
#include "engine/galaxy/ai/ep4/CEgg.h"
#include "engine/galaxy/ai/ep4/CBerkeloid.h"
#include "engine/galaxy/ai/ep4/CBlueBird.h"
#include "engine/galaxy/ai/ep4/CThunderCloud.h"
#include "engine/galaxy/ai/ep4/CTreasureEater.h"
// TODO: I'm note sure yet, if those are really common platforms
#include "engine/galaxy/ai/platforms.h"
#include "engine/galaxy/ai/CFlag.h"
namespace galaxy
{
CMapLoaderGalaxyEp4::CMapLoaderGalaxyEp4(CExeFile &ExeFile,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode) :
CMapLoaderGalaxy( ExeFile, ObjectPtr, Inventory, Cheatmode)
{}
// Platforms:
// 27-30 & 32 seem to be the actual platforms. There may be more of numbers lower than 27.
// 31 seem to be the stoppers, those are not created because the platform
// get this from the object map directly
const unsigned int PLATFORM_VERT_ALT = 27;
const unsigned int PLATFORM_HORIZ_ALT = 28;
const unsigned int PLATFORM_VERT = 29;
const unsigned int PLATFORM_HORIZ = 30;
// 31 does not count, because it's a blocker.
const unsigned int PLATFORM_DROP = 32;
const unsigned int DIVE_SUIT = 35;
/**
* @brief Loads a foe given by the coordiantes
*/
CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x, size_t y)
{
CGalaxySpriteObject* commonfoe = CMapLoaderGalaxy::addFoe(Map, foe, x, y);
// If a foe was found, that is common in all the galaxy games, just return.
if( commonfoe )
return commonfoe;
// otherwise look for special foe.
VectorD2<Uint32> loc(x,y);
CGalaxySpriteObject* p_newfoe = NULL;
switch(foe)
{
case 4:
//This is a council member.
p_newfoe = new galaxy::CCouncilMember(&Map, foe, x, y-750);
break;
case 6:
//This is pincess Lindsey.
p_newfoe = new galaxy::CLindsey(&Map, foe, x, y-750);
break;
case 7:
// This is a wormmouth.
p_newfoe = new galaxy::CWormmouth(&Map, foe, x, y);
break;
case 8:
// This is Skypest.
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;
case 9:
//This is the Thunder Cloud
p_newfoe = new galaxy::CThunderCloud(&Map, foe, x, y);
break;
case 12:
//This is a Bounder.
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
p_newfoe = new galaxy::CBounder(&Map, foe, x, y-250);
break;
case 13:
// This is an egg
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
if( g_pBehaviorEngine->mDifficulty > 1 )
p_newfoe = new galaxy::CBlueBird(&Map, foe, x, y-(2<<CSF));
else
p_newfoe = new galaxy::CEgg(&Map, foe, x, y-(2<<CSF));
break;
case 18:
// This might be the treasure eater.
p_newfoe = new galaxy::CTreasureEater(&Map, foe, x, y);
break;
case 19:
//This is a Mimrock.
// TODO: Those relative coordinates are not a good sign. Try to remove them and make the Sprite substract them
p_newfoe = new galaxy::CMimrock(&Map, foe, x, y);
break;
case 20:
// This is an Arachnut.
p_newfoe = new galaxy::CArachnut(&Map, foe, x, y);
break;
case 21:
// This is a Mad Mushroom.
p_newfoe = new galaxy::CMadMushroom(&Map, foe, x, y);
break;
case 22:
// This is a Poison Slug.
p_newfoe = new galaxy::CPoisonSlug(&Map, foe, x, y-250, m_ObjectPtr);
break;
case 23:
// This is a Sprite from the well of wishes.
p_newfoe = new galaxy::CDevilSprite(&Map, foe, x, y);
break;
case 24:
// This is a Sprite from the well of wishes.
p_newfoe = new galaxy::CSchoolFish(&Map, foe, x, y);
break;
/*case 25:
// This is Skypest.
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;*/
case PLATFORM_VERT: case PLATFORM_VERT_ALT:
p_newfoe = new galaxy::CPlatformVertical(&Map, foe, x, y); break;
case PLATFORM_HORIZ_ALT:
case PLATFORM_HORIZ:
p_newfoe = new galaxy::CPlatformHorizontal(&Map, foe, x, y); break;
case PLATFORM_DROP:
p_newfoe = new galaxy::CPlatformDrop(&Map, foe, x, y); break;
case 33:
// Place Miragia in Episode 4 on the Map
p_newfoe = new galaxy::CMiragia(&Map, foe, loc);
break;
case DIVE_SUIT:
// Place Miragia in Episode 4 on the Map
p_newfoe = new galaxy::CDiveSuit(&Map, foe, x, y);
break;
case 42:
// This is Keen in the swimming suit
p_newfoe = new galaxy::CPlayerDive(&Map, foe, x, y, m_ObjectPtr,
RIGHT, m_Inventory, m_Cheatmode);
break;
case 46:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;
case 47:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= NORMAL )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 48:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 50:
//This is the CBerkeloid
p_newfoe = new galaxy::CBerkeloid(&Map, foe, x, y);
break;
case 71:
// Watermine vertical
p_newfoe = new galaxy::CWaterMine(&Map, foe, x, y, true);
break;
case 72:
// Watermine horizontal
p_newfoe = new galaxy::CWaterMine(&Map, foe, x, y, false);
break;
case 87:
// Dope Fish
p_newfoe = new galaxy::CDopeFish(&Map, foe, x, y);
break;
case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc);
break;
default:
break;
}
return p_newfoe;
}
};
/*
* CMapLoaderGalaxyEp4.h
*
* Created on: 28.07.2012
* Author: gerstrong
*/
#ifndef CMAPLOADERGALAXYEP4_H_
#define CMAPLOADERGALAXYEP4_H_
#include "../CMapLoaderGalaxy.h"
namespace galaxy
{
class CMapLoaderGalaxyEp4 : public CMapLoaderGalaxy
{
public:
CMapLoaderGalaxyEp4(CExeFile &ExeFile,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode);
CGalaxySpriteObject* addFoe(CMap &Map, word foe, size_t x, size_t y);
};
};
#endif /* CMAPLOADERGALAXYEP4_H_ */
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