Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 2810 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.


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.


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;

//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


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];

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;

Share this post

Link to post
Share on other sites
1. I'd check that all the surfaces used by StretchRect() are valid (I.e. not NULL).
2. You *really* shouldn't be using StretchRect; you should be rendering your sprites with the ID3DXSprite interface, or by rendering them yourself as textured quads (Which is what ID3DXSprite does internally). StretchRect may not be hardware accelerated, and doesn't allow you to use alpha blending, rotation, or any number of other things you get for "free" when using textured quads.

Share this post

Link to post
Share on other sites
All of them are declared as NULL to the 2nd parameter if that what you mean. But they still work instead of the moving ones :S

Share this post

Link to post
Share on other sites
That's not the surface, that's the source rectangle, and NULL means "Entire surface". I'm referring to the first parameter - check with your debugger that they're all valid at the time StretchRect() is called.

Share this post

Link to post
Share on other sites
Well you wont believe it and its crazy how i solved it out

It doesnt draws THE LAST sprite so those 2 angles, since they were the last Path_Sprite and the last Wall_Sprite respectively they werent drawed.

The players since they are the uniqie sprites respectively they re not drawned also.

So Ive put down right and into a suplementary line one symbol from each sprite symbol uselesly, and so all previous are draw and everybody is happy smile.png


But I still cant figure out what is this madness. WHY NOT DRAWING ONLY THE LAST SPRITE SPECIFICALLY?

Sorry, I felt the need to provide the solution to terminate the thread, Im not the type who comes like an egoistical monster seeking solution and shits all once got it.
( Yes its from Athens Technological Educational Institute in Greece. We do stuff too here, we re not just lazy PIGS going bankrupt and living on Loans, blame only our political system ;)

Share this post

Link to post
Share on other sites
It's appreciated that you provided the solution, it's helpful in case someone comes across this thread in the future :)

I'm really not sure why your solution works; it might be worthwhile trying to create a minimal example that reproduces the bug - e.g. modify the code so it only draw 2 tiles and see if the second tile isn't drawn. Then you should hopefully be able to narrow the issue down a bit.

Also, if you've not already - I'd recommend using the debug DirectX runtimes; you can select them from the DirectX control panel (In start menu -> DirectX SDK -> Tools). That way, if a D3D call is failing for some reason (bad pointer, not supported, etc) you should get some useful output displayed in Visual Studio's output window.

Share this post

Link to post
Share on other sites
Yes I hate the half threads were the poster found the solution and deserted it indifferent like an egoistical indiferent beast.
And you go study all the thread to reach half answer. This has to stop.

Thank you its a good idea cause in the example there wasnt such prob. Im fine since it works like this at least, but i ll have to figure out the prob otherwise i will find it in front of me sooner or later again re resolvable or not :/ Thank you

Oh really i didnt knew thanks for the advice

Share this post

Link to post
Share on other sites
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!