📄 retronodetileset.cpp
字号:
////////////////////////////////////////////////////////////////////////
//
// RetroNodeTileset.cpp
//
// Copyright (c) 2003 Nokia Mobile Phones Ltd. All rights reserved.
//
////////////////////////////////////////////////////////////////////////
#include <e32math.h>
#include "RenderableFactory.h"
#include "Tilemap.h"
#include "RetroLeafTileset.h"
#include "RetroNodeTileset.h"
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
CRetroNodeTileset* CRetroNodeTileset::NewL(CRetroLeafTileset& aLeafFactory)
{
CRetroNodeTileset* self = new(ELeave) CRetroNodeTileset();
CleanupStack::PushL(self);
self->ConstructL(aLeafFactory);
CleanupStack::Pop();
return self;
}
////////////////////////////////////////////////////////////////////////
CRetroNodeTileset::CRetroNodeTileset()
{
}
////////////////////////////////////////////////////////////////////////
CRetroNodeTileset::~CRetroNodeTileset()
{
}
////////////////////////////////////////////////////////////////////////
void CRetroNodeTileset::ConstructL(CRetroLeafTileset& aLeafFactory)
{
TInt dataBuffer[16];
TInt mapBaseData[] =
{
4,0,4,0,
0,4,0,4,
4,0,4,0,
0,4,0,4,
};
TInt mapAdjustTopLeft[] =
{
3,3,3,2,
3,3,3,2,
2,1,2,0,
0,0,0,0,
};
TInt mapAdjustTopRight[] =
{
0,1,3,3,
0,1,3,3,
0,1,3,3,
0,0,1,2,
};
TInt mapAdjustBottomLeft[] =
{
1,2,0,0,
3,3,2,0,
3,3,2,0,
3,3,2,0,
};
TInt mapAdjustBottomRight[] =
{
0,0,0,0,
0,1,2,1,
1,3,3,3,
1,3,3,3,
};
AllocRenderablesL(16);
iTileLogWidth = 2 + aLeafFactory.TileLogWidth();
iTileLogHeight = 2 + aLeafFactory.TileLogHeight();
for (TInt tile = 0 ; tile < 16 ; tile++ )
{
// Set tile to "all background":
CopyData(mapBaseData,dataBuffer);
// Merge in foreground corners as
if ((tile & KTopLeftIsForeground) != 0)
{
MergeData(mapAdjustTopLeft,dataBuffer);
}
if ((tile & KBottomLeftIsForeground) != 0)
{
MergeData(mapAdjustBottomLeft,dataBuffer);
}
if ((tile & KTopRightIsForeground) != 0)
{
MergeData(mapAdjustTopRight,dataBuffer);
}
if ((tile & KBottomRightIsForeground) != 0)
{
MergeData(mapAdjustBottomRight,dataBuffer);
}
AddRenderable(CTilemap::NewL(4,4,&dataBuffer[0],aLeafFactory));
}
}
////////////////////////////////////////////////////////////////////////
void CRetroNodeTileset::CopyData(TInt aSrc[], TInt aDest[])
{
for (TInt cell = 0 ; cell < 16 ; cell++ )
{
aDest[cell] = aSrc[cell];
}
}
////////////////////////////////////////////////////////////////////////
void CRetroNodeTileset::MergeData(TInt aSrc[], TInt aDest[])
{
for (TInt cell = 0 ; cell < 16 ; cell++ )
{
aDest[cell] |= aSrc[cell];
}
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -