المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : RPG - character draw behind object problems [modified]



C# Programming
08-10-2009, 04:00 AM
Ok here is a quick screenshot, from which you can see my top of my character has been rendered over

http://i714.photobucket.com/albums/ww146/jneul/RPG_INVENTOR8-1.png

I hace a RPG game which works on a 3-layered map which is split into a grid (of rows and columns)
I can get my character making to work properly on simple objects such as a tree stump (just one cell),
and it works when you are moving down, but i get this problem when i move up, here is the code below:

public ArrayList detectTilesToRedraw(Rectangle srcArea, bool bUp)
{
ArrayList pTileRedrawList = new ArrayList();//array to hold objects which need redrawing
int nTop = srcArea.Y / Map_Definitions.m_nCellHeight ; //will always get the bottom positon
//of the sprite

//scan through our map layer cells
for (int i = 0; i < m_pObjectList.Count; ++i)
{
Object pObj = m_pObjectList[i];//main array reperesents each row
if (pObj is ArrayList)
{
ArrayList pList = (ArrayList)pObj;//sub array represents each column
for (int j = 0; j < pList.Count; ++j)
{
Tile_Object pTile = (Tile_Object)pList[j];//get tile object at row i column j
Object pSubObj = pTile.getObject();//get the object held in the tile
if (pSubObj is Graphic_Object)// is it a graphic object (sprite)
{
Graphic_Object pGraphicObject = (Graphic_Object)pSubObj;//cast to graphic
//object
int nTileTop = pGraphicObject.getPosition().Y / Map_Definitions.m_nCellHeight;
//if direction of character is down (not up)
if (!bUp)
{
//add all graphic objects that are at the same position or are more than
//the characteers positon (grid-wise)
if (nTileTop >= nTop)
{
pTileRedrawList.Add(pGraphicObject);
}
}
//else direction of character is up
else
{
//add all graphic objects that are at the same position or are less than
//the characteers positon (grid-wise)
if (nTileTop