Commit 522027d4 authored by Gerhard Stein's avatar Gerhard Stein

item animation now also work in galaxy

parent 4190ad66
......@@ -624,9 +624,9 @@ void CObject::processActionRoutine()
//printf("h_move=%d ; v_move=%d\n", m_Action.H_anim_move_amount, m_Action.V_anim_move_amount);
if(m_hDir == LEFT)
moveLeft( m_Action.H_anim_move_amount<<1 );
moveLeft(m_Action.H_anim_move_amount<<1);
else if(m_hDir == RIGHT)
moveRight( m_Action.H_anim_move_amount<<1 );
moveRight(m_Action.H_anim_move_amount<<1);
if(m_vDir == UP)
moveUp( m_Action.V_anim_move_amount<<1 );
......
......@@ -44,7 +44,8 @@ void CLevelPlay::process()
{
CObject* p_Object = m_ObjectPtr[i];
p_Object->process();
if(p_Object->exists)
p_Object->process();
}
g_pVideoDriver->blitScrollSurface();
......@@ -52,11 +53,20 @@ void CLevelPlay::process()
for( std::vector<CObject*>::iterator obj=m_ObjectPtr.begin() ;
obj!=m_ObjectPtr.end() ; obj++ )
{
(*obj)->draw();
if((*obj)->honorPriority)
(*obj)->draw();
}
// Draw masked tiles here!
m_Map.drawForegroundTiles();
for( std::vector<CObject*>::iterator obj=m_ObjectPtr.begin() ;
obj!=m_ObjectPtr.end() ; obj++ )
{
if(!(*obj)->honorPriority)
(*obj)->draw();
}
}
}
/*
* CItemEffect.cpp
*
* Created on: 19.11.2010
* Author: gerstrong
*
* This will animate the picked up items. It's basically the same
* as CRisingPoints in the Vorticon Engine.
* Here we have different cases, because some animations differ
*/
#include "CItemEffect.h"
namespace galaxy {
const int itemEffectTime = 50;
CItemEffect::CItemEffect(CMap *pmap, Uint32 x, Uint32 y, Uint16 l_sprite) :
CObject(pmap, x, y, OBJ_NONE)
{
m_timer = 0;
sprite = l_sprite-124;
honorPriority = false;
solid = false;
}
void CItemEffect::process()
{
if(m_timer >= itemEffectTime)
exists = false;
moveUp(1<<STC);
m_timer++;
}
}
/*
* CItemEffect.h
*
* Created on: 19.11.2010
* Author: gerstrong
*/
#ifndef CITEMEFFECT_H_
#define CITEMEFFECT_H_
#include "common/CObject.h"
namespace galaxy {
// Array of chunk numbers for first frames of sprite items (keys, guns, point items)
// All these items have two frames only
const int sprite_item_pics[] = {
242, 246, 248, 250, /* Keygems */
227, 229, 231, 233, 235, 237, /* Point items */
239, 251 /* lifewater and Neural stunner */
};
const int got_sprite_item_pics[] = {
250, 250, 250, 250, // Got gem sprite
219, 220, 221, 222, 223, 224, // 100,200,500,1000,2000,5000 pt sprites
225, 226 // 1Up and got raygun sprites
};
class CItemEffect : public CObject {
public:
CItemEffect(CMap *pmap, Uint32 x, Uint32 y, Uint16 l_sprite);
void process();
private:
int m_timer;
};
}
#endif /* CITEMEFFECT_H_ */
......@@ -6,6 +6,7 @@
*/
#include "CPlayerLevel.h"
#include "CItemEffect.h"
#include "common/CBehaviorEngine.h"
#include "sdl/CInput.h"
#include "CVec.h"
......@@ -24,6 +25,8 @@ const Uint16 MIN_POGOHEIGHT = 5;
const int POGO_START_INERTIA = -100;
const int POGO_START_INERTIA_MAX = -170;
const int POGO_X_MAX_INERTIA = 55;
const int POGO_X_BOOST = 3;
const int POGO_START_INERTIA_IMPOSSIBLE = -200;
CPlayerLevel::CPlayerLevel(CMap *pmap, Uint32 x, Uint32 y,
......@@ -105,7 +108,9 @@ void CPlayerLevel::process()
processActionRoutine();
moveXDir(xinertia);
xinertia = 0;
if( !getActionNumber(A_KEEN_POGO) )
xinertia = 0;
}
void CPlayerLevel::processInput()
......@@ -471,7 +476,22 @@ void CPlayerLevel::processPogo()
m_jumpheight = 0;
}
xinertia += (m_playcontrol[PA_X]>>1);
if(m_playcontrol[PA_X] > 0)
{
if(xinertia <= POGO_X_MAX_INERTIA)
xinertia += POGO_X_BOOST;
}
else if(m_playcontrol[PA_X] < 0)
{
if(xinertia >= -POGO_X_MAX_INERTIA)
xinertia -= POGO_X_BOOST;
}
if( blockedr && xinertia > 0 )
xinertia -= POGO_X_BOOST;
else if( blockedl && xinertia < 0 )
xinertia += POGO_X_BOOST;
}
}
......@@ -670,7 +690,10 @@ void CPlayerLevel::processLevelMiscFlagsCheck()
if(hitdetectWithTilePropertyRect(i, l_x, l_y, l_w, l_h, 1<<STC))
{
mp_Map->setTile(l_x>>CSF, l_y>>CSF, 0, true, 1);
const int lc_x = l_x>>CSF;
const int lc_y = l_y>>CSF;
mp_Map->setTile( lc_x, lc_y, 0, true, 1 );
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, lc_x<<CSF, lc_y<<CSF, got_sprite_item_pics[4+i-21]));
}
}
}
......
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