Jump to content
  • Advertisement
Sign in to follow this  
esgol

DireXt 9.0c moving Sprites not Loading unlike statics one. Why? Async position-SpriteLoad time maybe?

This topic is 2503 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please somebody explains me or if at least has any idea why this happens.

http://img687.images...mpbugdirext.jpg

The code cant be more clear and straight, I look and re look and cant find something.
Sometimes, the stone sprite may load, but (!) simoultanousley its BLACK one is loaded, AND (!) the black one its the real that gives victory, if u go to the sprite one it simply disapears and nothings happens (!) What the hell "Ghosts in the machine"?!!
Could it be an asynchronized called of the Painter compared to position changing? However I call the painter after all position changes are done

Also the 2 static spritsew down right dont load however u can go there its an active location. That though not of my interest it EVEN MOST crazy

Please give an idea at least I've made this problem as more analysed and easy to understand I could even by making that Photoshop illustration.

DIRECT SCENE PAINTING

void Labyrinth_Painter()
{
int i=0, j=0, NewX=0, NewY=0;
RECT rectObst, rectPath, rectM, rectL, rectO, rectMWon;
if (d3ddev->BeginScene())
{

//erase the entire background
d3ddev->ColorFill(backbuffer, NULL, D3DCOLOR_XRGB(0,0,0));

//d3ddev->StretchRect(back, NULL, backbuffer, NULL, D3DTEXF_NONE);


//draw the sprite
//d3ddev->StretchRect(kitty_image[kitty.curframe], NULL, backbuffer, &rect, D3DTEXF_NONE);

for (i = 0; i <20; i++)
{
for(j = 0; j < 50; j++)
{
if (Labyrinth[j]=='*')
{
d3ddev->StretchRect(Obstacle_Image, NULL, backbuffer, &rectObst, D3DTEXF_NONE);
rectObst.left = Obstacle.x+NewX ;
rectObst.right = Obstacle.x + Obstacle.width+NewX;
rectObst.top = Obstacle.y+NewY;
rectObst.bottom = Obstacle.y + Obstacle.height+NewY;
}
if (Labyrinth[j]=='.')
{
d3ddev->StretchRect(PathImage, NULL, backbuffer, &rectPath, D3DTEXF_NONE);
rectPath.left = PathBlock.x+NewX ;
rectPath.right = PathBlock.x + PathBlock.width+NewX;
rectPath.top = PathBlock.y+NewY;
rectPath.bottom = PathBlock.y + PathBlock.height+NewY;
}

if (Labyrinth[j]=='M')
{
d3ddev->StretchRect(MpamphsImage, NULL, backbuffer, &rectM, D3DTEXF_NONE);
rectM.left = Mpamphs.x+NewX ;
rectM.right = Mpamphs.x + Mpamphs.width+NewX;
rectM.top = Mpamphs.y+NewY;
rectM.bottom = Mpamphs.y + Mpamphs.height+NewY;
}

if (Labyrinth[j]=='L')
{
d3ddev->StretchRect(LuciusImage, NULL, backbuffer, &rectL, D3DTEXF_NONE);
rectL.left = Lucius.x+NewX ;
rectL.right = Lucius.x + Lucius.width+NewX;
rectL.top = Lucius.y+NewY;
rectL.bottom = Lucius.y + Lucius.height+NewY;
}
if (Labyrinth[j]=='O')
{
d3ddev->StretchRect(PetradiImage, NULL, backbuffer, &rectO, D3DTEXF_NONE);
rectO.left = Petradi.x+NewX ;
rectO.right = Petradi.x + Petradi.width+NewX;
rectO.top = Petradi.y+NewY;
rectO.bottom = Petradi.y + Petradi.height+NewY;
}

NewX=NewX+21;
}
NewY=NewY+21;
NewX=0;
}
//if (MpamphsWon==true || LuciusWon==true)
//{
d3ddev->StretchRect(MpamphsWonImage, NULL, backbuffer, &rectMWon, D3DTEXF_NONE);
rectMWon.left = 0 ;
rectMWon.right = 1046;
rectMWon.top = 400;
rectMWon.bottom = 460;
//}
//stop rendering
d3ddev->EndScene();
}
}



FILE READ

void File_Reader(char **Array)
{
int i=0,j=0;
char *mystring;
mystring=(char*) malloc (52* sizeof(int));
FILE * pFile;
pFile = fopen ("LavirintosNDE.txt" , "r");

while ( (fgets (mystring , 52 , pFile) != NULL) && i<20 )
{
for(j = 0; j < 50; j++)
{
Labyrinth[j] = mystring[j];
}
i++;
}
}


SPRITES INITIALIZATION
Obstacle_Image = LoadSurface ("Wall2.bmp", NULL);
PathImage = LoadSurface ("Path2.bmp", NULL);
MpamphsImage = LoadSurface ("Mpamphs.bmp", NULL);
LuciusImage = LoadSurface ("L.bmp", NULL);
PetradiImage = LoadSurface ("O.bmp", NULL);
back = LoadSurface("Menu.bmp", NULL );
BackMpamphsWon = LoadSurface("bcgkMPAMPHS.bmp", NULL );
BackLuciusWon = LoadSurface("bcgkLUCIUS.bmp", NULL );


Obstacle.x = 0;
Obstacle.y = 0;
Obstacle.width = 21;
Obstacle.height = 21;
Obstacle.curframe = 0;
Obstacle.lastframe = 0;
Obstacle.animdelay = 2;
Obstacle.animcount = 0;
Obstacle.movex = 0;
Obstacle.movey = 0;

PathBlock.x = 0;
PathBlock.y = 0;
PathBlock.width = 21;
PathBlock.height = 21;
PathBlock.curframe = 0;
PathBlock.lastframe = 0;
PathBlock.animdelay = 2;
PathBlock.animcount = 0;
PathBlock.movex = 0;
PathBlock.movey = 0;

Mpamphs.x = 0;
Mpamphs.y = 0;
Mpamphs.width = 21;
Mpamphs.height = 21;
Mpamphs.curframe = 0;
Mpamphs.lastframe = 0;
Mpamphs.animdelay = 2;
Mpamphs.animcount = 0;
Mpamphs.movex = 0;
Mpamphs.movey = 0;

Lucius.x = 0;
Lucius.y = 0;
Lucius.width = 21;
Lucius.height = 21;
Lucius.curframe = 0;
Lucius.lastframe = 0;
Lucius.animdelay = 2;
Lucius.animcount = 0;
Lucius.movex = 0;
Lucius.movey = 0;

Petradi.x = 0;
Petradi.y = 0;
Petradi.width = 21;
Petradi.height = 21;
Petradi.curframe = 0;
Petradi.lastframe = 0;
Petradi.animdelay = 2;
Petradi.animcount = 0;
Petradi.movex = 0;
Petradi.movey = 0;

//initialize the sprite's properties


//return okay
return 1;

P.S.
My guide was the BEGGINING GAME PROGRAMMING book 2002 edition Chapter 7

Share this post


Link to post
Share on other sites
Advertisement

This topic is 2503 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!