Commit cce939d6 authored by Gerhard Stein's avatar Gerhard Stein

Restored other small vorticon animation functions

parent 21c71938
...@@ -22,10 +22,9 @@ m_width(0), m_height(0), ...@@ -22,10 +22,9 @@ m_width(0), m_height(0),
m_worldmap(false), m_worldmap(false),
m_animation_enabled(true), m_animation_enabled(true),
m_Tilemaps(g_pGfxEngine->getTileMaps()), m_Tilemaps(g_pGfxEngine->getTileMaps()),
m_animtiletimer(0) m_animtiletimer(0),
m_Background(false)
{ {
//memset( m_AnimTileInUse, 0, sizeof(m_AnimTileInUse));
//memset( m_animtiles, 0, sizeof(m_animtiles));
resetScrolls(); resetScrolls();
memset(m_objectlayer, 0, sizeof(m_objectlayer)); memset(m_objectlayer, 0, sizeof(m_objectlayer));
} }
...@@ -48,6 +47,7 @@ bool CMap::createEmptyDataPlane(size_t plane, size_t blocksize) ...@@ -48,6 +47,7 @@ bool CMap::createEmptyDataPlane(size_t plane, size_t blocksize)
if(!blocksize) return false; if(!blocksize) return false;
m_Plane[plane].createDataMap(blocksize, m_width, m_height); m_Plane[plane].createDataMap(blocksize, m_width, m_height);
m_Background = (m_Plane[0].getMapDataPtr() != NULL);
return true; return true;
} }
...@@ -311,14 +311,20 @@ void CMap::scrollUp(void) ...@@ -311,14 +311,20 @@ void CMap::scrollUp(void)
// in stripes as it scrolls around. // in stripes as it scrolls around.
void CMap::redrawAt(int mx, int my) void CMap::redrawAt(int mx, int my)
{ {
/*for(size_t tilemap=0 ; tilemap<2 ; tilemap++) if( m_Background )
{ {
if(m_Plane[tilemap].getMapDataPtr() == NULL) size_t bg = m_Plane[0].getMapDataAt(mx, my);
continue; size_t fg = m_Plane[1].getMapDataAt(mx, my);
int c = m_Plane[tilemap].getMapDataAt(mx, my); m_Tilemaps.at(0).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, bg);
m_Tilemaps.at(tilemap).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, c); m_Tilemaps.at(1).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, fg);
registerAnimation( (mx<<4)&511, (my<<4)&511, bg, fg ); registerAnimation( (mx<<4)&511, (my<<4)&511, bg, fg );
}*/ }
else
{
size_t fg = m_Plane[1].getMapDataAt(mx, my);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, (mx<<4)&511, (my<<4)&511, fg);
registerAnimation( (mx<<4)&511, (my<<4)&511, 0, fg );
}
} }
// draws all the map area. This is used for the title screen, when game starts and other passive scenes. // draws all the map area. This is used for the title screen, when game starts and other passive scenes.
...@@ -335,17 +341,33 @@ void CMap::drawAll() ...@@ -335,17 +341,33 @@ void CMap::drawAll()
if(num_h_tiles+m_mapy >= m_height) if(num_h_tiles+m_mapy >= m_height)
num_h_tiles = m_height-m_mapy; num_h_tiles = m_height-m_mapy;
for(Uint32 y=0;y<num_h_tiles;y++) if( m_Background )
{ {
for(Uint32 x=0;x<num_v_tiles;x++) for(Uint32 y=0;y<num_h_tiles;y++)
{ {
Uint32 bg = m_Plane[0].getMapDataAt(x+m_mapx, y+m_mapy); for(Uint32 x=0;x<num_v_tiles;x++)
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, y+m_mapy); {
Uint32 bg = m_Plane[0].getMapDataAt(x+m_mapx, y+m_mapy);
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, y+m_mapy);
m_Tilemaps.at(0).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, bg);
if(fg)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, bg, fg );
}
}
}
else
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
for(Uint32 x=0;x<num_v_tiles;x++)
{
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, y+m_mapy);
m_Tilemaps.at(0).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, bg);
if(fg)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, fg); m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, bg, fg ); registerAnimation( ((x<<4)+m_mapxstripepos)&511,((y<<4)+m_mapystripepos)&511, 0, fg );
}
} }
} }
} }
...@@ -359,15 +381,27 @@ void CMap::drawHstripe(unsigned int y, unsigned int mpy) ...@@ -359,15 +381,27 @@ void CMap::drawHstripe(unsigned int y, unsigned int mpy)
if( num_v_tiles+m_mapx >= m_width ) if( num_v_tiles+m_mapx >= m_width )
num_v_tiles = m_width-m_mapx; num_v_tiles = m_width-m_mapx;
for(Uint32 x=0;x<num_v_tiles;x++) if( m_Background )
{ {
Uint32 bg = m_Plane[0].getMapDataAt(x+m_mapx, mpy); for(Uint32 x=0;x<num_v_tiles;x++)
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, mpy); {
Uint32 bg = m_Plane[0].getMapDataAt(x+m_mapx, mpy);
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, mpy);
m_Tilemaps.at(0).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, bg); m_Tilemaps.at(0).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, bg);
if(fg) if(fg)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511, y, bg, fg );
}
}
else
{
for(Uint32 x=0;x<num_v_tiles;x++)
{
Uint32 fg = m_Plane[1].getMapDataAt(x+m_mapx, mpy);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, fg); m_Tilemaps.at(1).drawTile(mp_scrollsurface, ((x<<4)+m_mapxstripepos)&511, y, fg);
registerAnimation( ((x<<4)+m_mapxstripepos)&511, y, bg, fg ); registerAnimation( ((x<<4)+m_mapxstripepos)&511, y, 0, fg );
}
} }
} }
...@@ -381,6 +415,8 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx) ...@@ -381,6 +415,8 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
if( num_h_tiles+m_mapy >= m_height ) if( num_h_tiles+m_mapy >= m_height )
num_h_tiles = m_height-m_mapy; num_h_tiles = m_height-m_mapy;
if( m_Background )
{
for(Uint32 y=0;y<num_h_tiles;y++) for(Uint32 y=0;y<num_h_tiles;y++)
{ {
Uint32 bg = m_Plane[0].getMapDataAt(mpx, y+m_mapy); Uint32 bg = m_Plane[0].getMapDataAt(mpx, y+m_mapy);
...@@ -391,6 +427,17 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx) ...@@ -391,6 +427,17 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
m_Tilemaps.at(1).drawTile(mp_scrollsurface, x, ((y<<4)+m_mapystripepos)&511, fg); m_Tilemaps.at(1).drawTile(mp_scrollsurface, x, ((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( x, ((y<<4)+m_mapystripepos)&511, bg, fg ); registerAnimation( x, ((y<<4)+m_mapystripepos)&511, bg, fg );
} }
}
else
{
for(Uint32 y=0;y<num_h_tiles;y++)
{
Uint32 fg = m_Plane[1].getMapDataAt(mpx, y+m_mapy);
m_Tilemaps.at(1).drawTile(mp_scrollsurface, x, ((y<<4)+m_mapystripepos)&511, fg);
registerAnimation( x, ((y<<4)+m_mapystripepos)&511, 0, fg );
}
}
} }
///////////////////////// /////////////////////////
...@@ -400,12 +447,34 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx) ...@@ -400,12 +447,34 @@ void CMap::drawVstripe(unsigned int x, unsigned int mpx)
// unregisters them from animtiles // unregisters them from animtiles
void CMap::deAnimate(int x, int y) void CMap::deAnimate(int x, int y)
{ {
const int px = ((m_mapxstripepos+((x-m_mapx)<<4))&511);
const int py = ((m_mapystripepos+((y-m_mapy)<<4))&511);
m_AnimationSlots.remove_if(usedCoord(px, py));
} }
// Draw an animated tile. If it's not animated draw it anyway // Draw an animated tile. If it's not animated draw it anyway
void CMap::drawAnimatedTile(SDL_Surface *dst, Uint16 mx, Uint16 my, Uint16 tile) void CMap::drawAnimatedTile(SDL_Surface *dst, Uint16 mx, Uint16 my, Uint16 tile)
{ {
CTileProperties &TileProperty = g_pBehaviorEngine->getTileProperties(1).at(tile);
if(TileProperty.animationtime)
{ // animate animated tile
std::list<stAnimationSlot>::iterator slot = m_AnimationSlots.begin();
for( ; slot != m_AnimationSlots.end() ; slot++ )
{
if( (slot->x == mx+m_scrollx_buf) &&
(slot->y == my+m_scrolly_buf) )
{
m_Tilemaps.at(0).drawTile( dst, mx, my,
slot->fgtile );
}
}
}
else
{ // Unanimated tile
m_Tilemaps.at(1).drawTile( dst, mx, my, tile );
}
} }
...@@ -416,27 +485,45 @@ void CMap::animateAllTiles() ...@@ -416,27 +485,45 @@ void CMap::animateAllTiles()
// Go throught the list and just draw all the tiles that need to be animated // Go throught the list and just draw all the tiles that need to be animated
std::list<stAnimationSlot>::iterator slot = m_AnimationSlots.begin(); std::list<stAnimationSlot>::iterator slot = m_AnimationSlots.begin();
for( ; slot != m_AnimationSlots.end() ; slot++ ) if(m_Background)
{ {
// Get the right property of the tile for( ; slot != m_AnimationSlots.end() ; slot++ )
CTileProperties &TilePropertiesBG = { // Get the right property of the tile
g_pBehaviorEngine->getTileProperties(0).at(slot->bgtile); CTileProperties &TilePropertiesBG =
CTileProperties &TilePropertiesFG = g_pBehaviorEngine->getTileProperties(0).at(slot->bgtile);
g_pBehaviorEngine->getTileProperties(1).at(slot->fgtile); CTileProperties &TilePropertiesFG =
g_pBehaviorEngine->getTileProperties(1).at(slot->fgtile);
m_Tilemaps.at(0).drawTile( mp_scrollsurface, slot->x, slot->y, slot->bgtile);
if(slot->fgtile)
m_Tilemaps.at(1).drawTile( mp_scrollsurface, slot->x, slot->y, slot->fgtile);
// get the next tile which will be drawn in the next animation cycle
if(TilePropertiesBG.animationtime)
if( (m_animtiletimer % TilePropertiesBG.animationtime) == 0)
slot->bgtile += TilePropertiesBG.nextTile;
if(TilePropertiesFG.animationtime)
if( (m_animtiletimer % TilePropertiesFG.animationtime) == 0)
slot->fgtile += TilePropertiesFG.nextTile;
}
}
else
{
for( ; slot != m_AnimationSlots.end() ; slot++ )
{ // Get the right property of the tile
CTileProperties &TilePropertiesFG =
g_pBehaviorEngine->getTileProperties(1).at(slot->fgtile);
m_Tilemaps.at(0).drawTile( mp_scrollsurface, slot->x, slot->y, slot->bgtile);
if(slot->fgtile)
m_Tilemaps.at(1).drawTile( mp_scrollsurface, slot->x, slot->y, slot->fgtile); m_Tilemaps.at(1).drawTile( mp_scrollsurface, slot->x, slot->y, slot->fgtile);
// get the next tile which will be drawn in the next animation cycle
if(TilePropertiesBG.animationtime) // get the next tile which will be drawn in the next animation cycle
if( (m_animtiletimer % TilePropertiesBG.animationtime) == 0) if(TilePropertiesFG.animationtime)
slot->bgtile += TilePropertiesBG.nextTile; if( (m_animtiletimer % TilePropertiesFG.animationtime) == 0)
if(TilePropertiesFG.animationtime) slot->fgtile += TilePropertiesFG.nextTile;
if( (m_animtiletimer % TilePropertiesFG.animationtime) == 0) }
slot->fgtile += TilePropertiesFG.nextTile;
} }
} }
...@@ -465,26 +552,29 @@ public: ...@@ -465,26 +552,29 @@ public:
private : size_t m_x,m_y; private : size_t m_x,m_y;
}; };
// register the tiles which has to be animated // register the tiles which has to be animated
void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg) void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg)
{ {
// first check if some of the Animation slots are out of place and remove them // first check if some of the Animation slots are out of place and remove them
m_AnimationSlots.remove_if(usedCoord(x, y)); m_AnimationSlots.remove_if(usedCoord(x, y));
CTileProperties &TilePropertyBG =
g_pBehaviorEngine->getTileProperties(0).at(bg);
CTileProperties &TilePropertyFG = CTileProperties &TilePropertyFG =
g_pBehaviorEngine->getTileProperties(1).at(fg); g_pBehaviorEngine->getTileProperties(1).at(fg);
// we just drew an animated tile which we will now register // we just drew an animated tile which we will now register
if( TilePropertyBG.animationtime ) if( m_Background )
{ {
stAnimationSlot NewAnimationSlot; CTileProperties &TilePropertyBG =
NewAnimationSlot.x = x; g_pBehaviorEngine->getTileProperties(0).at(bg);
NewAnimationSlot.y = y;
NewAnimationSlot.bgtile = bg; if( TilePropertyBG.animationtime && m_Background )
NewAnimationSlot.fgtile = fg; {
m_AnimationSlots.push_back(NewAnimationSlot); stAnimationSlot NewAnimationSlot;
NewAnimationSlot.x = x;
NewAnimationSlot.y = y;
NewAnimationSlot.bgtile = bg;
NewAnimationSlot.fgtile = fg;
m_AnimationSlots.push_back(NewAnimationSlot);
}
} }
if( TilePropertyFG.animationtime ) if( TilePropertyFG.animationtime )
...@@ -498,12 +588,6 @@ void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg) ...@@ -498,12 +588,6 @@ void CMap::registerAnimation(Uint32 x, Uint32 y, size_t bg, size_t fg)
} }
} }
void CMap::cleanupAll()
{
//memset( m_AnimTileInUse, 0, sizeof(m_AnimTileInUse));
//memset( m_animtiles, 0, sizeof(m_animtiles));
}
CMap::~CMap() { CMap::~CMap() {
} }
......
...@@ -19,17 +19,6 @@ ...@@ -19,17 +19,6 @@
// animation rate of animated tiles // animation rate of animated tiles
#define ANIM_TILE_TIME 256 #define ANIM_TILE_TIME 256
#define MAX_ANIMTILES 400
// for each entry in the animtileinuse array that is nonzero, that
// location on the display is an animated tile which is currently registered
// in animtiles[]. Used in map_draw_hstripe and map_draw_vstripe.
// When drawing a new stripe over one that previously contained an animated
// tile, this lets it know it needs to unregister the animated tile that
// used to be there. the nonzero value corresponds to the associated entry
// in animtiles[]. the x,y pixel position is the index in here * 16.
#define ATILEINUSE_SIZEX 33
#define ATILEINUSE_SIZEY 33
class CMap { class CMap {
public: public:
...@@ -75,7 +64,6 @@ public: ...@@ -75,7 +64,6 @@ public:
word *getForegroundData(); word *getForegroundData();
word *getBackgroundData(); word *getBackgroundData();
void cleanupAll();
virtual ~CMap(); virtual ~CMap();
...@@ -110,18 +98,6 @@ private: ...@@ -110,18 +98,6 @@ private:
SDL_Surface *mp_scrollsurface; SDL_Surface *mp_scrollsurface;
std::vector<CTilemap> &m_Tilemaps; std::vector<CTilemap> &m_Tilemaps;
// (map) stripe attribute structures, for animated tiles
// slot 0 is not used. data starts at slot 1. see description
// of AnimTileInUse in map structure to see why.
/*struct {
bool slotinuse; // if false, this entry should not be drawn
int x; // x pixel position in scrollbuf[] where tile is
int y; // y pixel position in scrollbuf[]
int tile; // tile which has to be drawn
} m_animtiles[2][MAX_ANIMTILES+1];
unsigned int m_AnimTileInUse[2][ATILEINUSE_SIZEX][ATILEINUSE_SIZEY];*/
class usedCoord; class usedCoord;
struct stAnimationSlot{ struct stAnimationSlot{
size_t x, y; size_t x, y;
...@@ -133,6 +109,7 @@ private: ...@@ -133,6 +109,7 @@ private:
Uint8 m_animtiletimer; Uint8 m_animtiletimer;
CPlane m_Plane[2]; CPlane m_Plane[2];
bool m_Background; // This variable holds, whether we have a background to draw or not.
}; };
#endif /* CMAP_H_ */ #endif /* CMAP_H_ */
...@@ -81,7 +81,6 @@ void CPlayGameGalaxy::processInput() ...@@ -81,7 +81,6 @@ void CPlayGameGalaxy::processInput()
m_Level++; m_Level++;
else else
m_Level = 0; m_Level = 0;
m_Map.cleanupAll();
loadLevel(); loadLevel();
} }
} }
......
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