Commit 23fe63f0 authored by Gerstrong's avatar Gerstrong

Poison-Slug Update

parent b3c028fa
......@@ -192,6 +192,63 @@ bool CObject::checkforScenario()
return false;
}
bool CObject::verifyForFalling()
{
if( !blockedd )
{
// This will check three points and avoid that keen falls on sloped tiles
const int &fall1 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos());
const int &fall2 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos()+(1<<(CSF)));
const int &fall3 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos()+(2<<(CSF)));
const CTileProperties &TileProp1 = g_pBehaviorEngine->getTileProperties(1)[fall1];
const CTileProperties &TileProp2 = g_pBehaviorEngine->getTileProperties(1)[fall2];
const CTileProperties &TileProp3 = g_pBehaviorEngine->getTileProperties(1)[fall3];
const bool nothing_on_feet = (TileProp1.bup == 0);
const bool nothing_below_feet = (TileProp2.bup == 0) && (TileProp3.bup == 0);
const bool can_fall = (nothing_on_feet && nothing_below_feet);
if(can_fall)
{
return true;
}
else
{
// Force the player a bit down, so he will never fall from sloped tiles
moveDown(100);
}
}
return false;
}
void CObject::performCliffStop(const int &speed)
{
if(verifyForFalling())
{
if( m_hDir == RIGHT )
{
m_hDir = LEFT;
moveLeft( speed );
}
else
{
m_hDir = RIGHT;
moveRight( speed );
}
}
}
// Used in some setup mode, like putting the player to
// the current map position
void CObject::moveToForce(const VectorD2<int> &dir)
......@@ -359,7 +416,7 @@ void CObject::processFalling()
moveUp(-yinertia);
yinertia += Physics.fallspeed_increase;
}
else if(yinertia>=0 && !blockedd )
else if( yinertia>=0 && !blockedd )
{
moveDown(yinertia);
......
......@@ -128,6 +128,26 @@ public:
bool calcVisibility();
bool checkforScenario();
/**
* \description This will verify whether object has to fall or not.
* This function must be called when it might be moving
* because it also checks the lower sloped tiles cases
*
* \todo This function should also be called by foes in some cases
*/
bool verifyForFalling();
/**
* \description This function will change the direction of an object when
* it detects a coming gap while moving
* \param speed Amount of CSFed coordinates to move the object back
* when it over that gap
*/
void performCliffStop(const int &speed);
// Moving parts
void moveToForce(const VectorD2<int> &dir);
void moveToForce(const int& new_x, const int& new_y);
......
......@@ -1397,36 +1397,6 @@ void CPlayerLevel::processRunning()
bool CPlayerLevel::verifyForFalling()
{
if( !blockedd )
{
// This will check three points and avoid that keen falls on sloped tiles
const int &fall1 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos());
const int &fall2 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos()+(1<<(CSF)));
const int &fall3 = mp_Map->getPlaneDataAt(1, getXMidPos(), getYDownPos()+(2<<(CSF)));
const CTileProperties &TileProp1 = g_pBehaviorEngine->getTileProperties(1)[fall1];
const CTileProperties &TileProp2 = g_pBehaviorEngine->getTileProperties(1)[fall2];
const CTileProperties &TileProp3 = g_pBehaviorEngine->getTileProperties(1)[fall3];
const bool nothing_on_feet = (TileProp1.bup == 0);
const bool nothing_below_feet = (TileProp2.bup == 0) && (TileProp3.bup == 0);
const bool can_fall = (nothing_on_feet && nothing_below_feet);
if(can_fall)
{
return true;
}
else
{
// Force the player a bit down, so he will never fall from sloped tiles
moveDown(100);
}
}
return false;
}
// Falling code
......
......@@ -103,16 +103,6 @@ public:
/**
* \description This will verify whether keen has to fall or not.
* This function must be called when he might be walking
* because it also checks the lower sloped tiles cases
*
* \todo This function should also be called by foes in some cases
*/
bool verifyForFalling();
/**
* \description verifies whether there is a cliff and Keen can hang on it.
* If that the case, the function places him properly
......
......@@ -13,7 +13,6 @@ namespace galaxy {
const int SLUG_MOVE_SPEED = 1;
const int SLUG_MOVE_TIMER = 10;
//const int SLUG_POO_TIME = 1000;
CPoisonSlug::CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y) :
CObject(pmap, x, y, OBJ_NONE),
......@@ -27,8 +26,20 @@ m_timer(0)
performCollisions();
}
void CPoisonSlug::processCrawling()
{
performCollisions();
processFalling();
// Check if there is a cliff
performCliffStop(m_Action.H_anim_move_amount<<1);
if( m_timer < SLUG_MOVE_TIMER )
{
m_timer++;
......@@ -40,7 +51,7 @@ void CPoisonSlug::processCrawling()
}
// Chance to poo
if( getProbability(50) )
if( getProbability(30) )
{
m_timer = 0;
mp_processState = &CPoisonSlug::processPooing;
......@@ -53,8 +64,13 @@ void CPoisonSlug::processCrawling()
moveRight( m_Action.H_anim_move_amount<<1 );
else
moveLeft( m_Action.H_anim_move_amount<<1 );
}
void CPoisonSlug::processPooing()
{
if( getActionStatus(A_SLUG_MOVE) )
......@@ -66,6 +82,10 @@ void CPoisonSlug::processPooing()
}
void CPoisonSlug::process()
{
(this->*mp_processState)();
......
......@@ -23,7 +23,15 @@ class CPoisonSlug : public CObject {
public:
CPoisonSlug(CMap *pmap, Uint32 x, Uint32 y);
/**
* When slug is moving normally
*/
void processCrawling();
/**
* When slug is pooing slime
*/
void processPooing();
void process();
......
/*
* CSlugSlime.cpp
*
* Created on: 28.05.2011
* Author: gerstrong
*/
#include "CSlugSlime.h"
CSlugSlime::CSlugSlime(CMap *pmap, Uint32 x, Uint32 y) :
CObject(pmap, x, y, OBJ_NONE)
{
// TODO Auto-generated constructor stub
}
/*
* CSlugSlime.h
*
* Created on: 28.05.2011
* Author: gerstrong
*/
#ifndef CSLUGSLIME_H_
#define CSLUGSLIME_H_
#include "common/CObject.h"
class CSlugSlime : public CObject {
public:
CSlugSlime(CMap *pmap, Uint32 x, Uint32 y);
};
#endif /* CSLUGSLIME_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