• 9
• 11
• 11
• 9
• 20

# Blurry Sprite Motion With ID3DXSprite & D3DXMatrixTransformation2D

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

## Recommended Posts

Hey all. I was all excited when I actually got a 2d ship flying around the screen. That is, until I realized that my animation was less smooth than I would like. Every second or second and a half or so it seems to skip a frame or something that makes the animation "jerky". Poured over the code for hours before deciding to try it on another machine. On this machine the animation is smooth! That's weird enough on its own, but on this machine there's another problem entirely (it might be on the original machine also, but I haven't had a chance to look) and that is that when my sprite is in motion it's extremely blurry. The faster it goes the worse it is. The leading edge of the sprite (in the direction of motion) almost looks "double vision" like. Any details inside the sprite are impossible to make out. I realize there's going to be some blurring with movement, but this seems like way too much. The texture is 64x64. Here's my code:
//This is the Render Frame method, called once per update.
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
d3ddev->BeginScene();

stage->Render(elapsedTime);

d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);

//Here's my scene's Render method
//actors is a double linked list
void Scene::Render(float elapsedTime)
{
Actor* nextActor = actors->Reset();
while ( nextActor != NULL )
{
nextActor->Draw(elapsedTime);
nextActor =  actors->GetNext();
}
}

//And here is the actor draw method
void Actor::Draw(float elapsedTime)
{
this->position.x += (this->velocity.x * elapsedTime);
this->position.y += (this->velocity.y * elapsedTime);
float posX = this->position.x;
float posY = this->position.y;

if ( posX > SCREEN_WIDTH )
{
this->position.x = posX-SCREEN_WIDTH;
}
else if ( posX < 0 )
{
this->position.x = SCREEN_WIDTH - ( 0 - posX );
}

if ( posY > SCREEN_HEIGHT )
{
this->position.y = posY-SCREEN_HEIGHT;
}
else if ( posY < 0 )
{
this->position.y = SCREEN_HEIGHT - ( 0 - posY );
}

D3DXMATRIX mat;
D3DXVECTOR2 center(32.0f, 32.0f);
D3DXMatrixTransformation2D(&mat, NULL, 0, NULL, ¢er, D3DXToRadian(this->angle + this->textureRotationalOffset), &this->position);
spriteInterface->Begin(D3DXSPRITE_ALPHABLEND);
spriteInterface->SetTransform(&mat);
spriteInterface->Draw(spriteTexture, NULL, NULL, NULL, D3DCOLOR_XRGB(255, 255, 255));
spriteInterface->End();
}

Now I DO want to note that my SCREEN_HEIGHT and SCREEN_WIDTH are being used for the window size and in setting up my d3d device (rather than the actual rendering area). I read that can cause blurring with textures. However, when my textures are still they are crisp. Is there a way to determine what my rendered area would be in a typical window? Right now my width and height are set to 1024x768, so what would that make the rendering area be? I hope that makes sense. If anyone wants to look at the full source code it's here: http://www.reliveyourchildhood.com/files/GeSS.zip Thanks everyone! EDIT: Ok, I'm an idiot. The blurring is the monitor. I get the same effect when I just drag a window. So I guess the question is, why does the animation run smoothly ont his computer, but runs choppily on my other computer (it's older, but seriously it's 1 sprite, I can't believe a P4 wouldn't handle it). [Edited by - jackdbunny on August 19, 2008 3:23:19 PM]