• Advertisement
Sign in to follow this  

Font Cutting Sprites

This topic is 2999 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

I was working on testing a key press function, and I noticed that the font has been cutting through my sprites. update method does seem to do its job, i also did sprite flush to see if that would work, but no. check it out for yourself. font problem
CGame::CGame(DWORD FrameLimit)
{
	dwFPSLimit = FrameLimit;
	//luaVM = lua_open(0);
	tab = Paused = false;
}

void CGame::Initialise(CPlayer &player, CFile &file)
{
	file.InitPlayer(&player);
	file.InitSprite(&sprite);
	//lua_dostring(luaVM, strLuaInput);

}

void CGame::LoadGraphics(CGraphics &graphics,CPlayer &player)
{
graphics.LoadFont(30);
graphics.LoadSprite(&sprite.Tex, L"Mark.png");
graphics.LoadSprite(player.GetPTexture(), L"PlayerSpot.png");


}

void CGame::Update(CPlayer &player, CFile &file)
{
	GetCursorPos(&MousePos);

	if(KEY_DOWN(VK_ESCAPE) && Paused == false)
		Paused = true;
	else if(KEY_DOWN(VK_ESCAPE) && Paused == true)
		Paused = false;


if(Paused == false)
	{   
			//file.SavePlayer(&player);
			//file.SaveSprite(&sprite);

	}
}

void CGame::Render(CGraphics &graphics,CPlayer &player)
{
	
	dwCurrentTime = GetTickCount();
	if ((dwCurrentTime - dwLastFrameTime) < (1000 / dwFPSLimit)) // 1000 miliseconds in a second.
	{
		return;
	}
	dwLastFrameTime = 0;

	graphics.StartRender();

if(Paused == true)
	graphics.DrawFont(0,0, 600, L"PAUSE", 30);

	
	graphics.DrawSprite(player.GetTexture(), 32, 32, 1, 1, 0, player.GetPositionX(), player.GetPositionY(), player.GetZLayer());
	graphics.DrawSprite(sprite.Tex, 32, 32, 1, 1, 0, sprite.X, sprite.Y, sprite.Z);

	graphics.EndRender();
	
	dwLastFrameTime += (1000 / dwFPSLimit);
}


edit: fixed image link

Share this post


Link to post
Share on other sites
Advertisement
Is the first image what you get when the game is not paused?

Are you sure you're clearing your backbuffer and depth buffer every frame?

Share this post


Link to post
Share on other sites
If this isn't it then I am missing something, It's called right when Game.Render() starts.(I know structure could be better but this literally would be the first game I have ever made).


void CGraphics::StartRender()
{
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(120,120,255), 1.0f, 0);
d3ddev->BeginScene();
d3dspt->Begin(D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_DEPTH_FRONTTOBACK);
}



could it also be the fact that I'm pointing LPD3DXSPRITE to font as well as my sprites??

or the fact that I've made the directx functions global inside my graphics.cpp file?

Share this post


Link to post
Share on other sites
Quote:
Original post by steven31dd
could it also be the fact that I'm pointing LPD3DXSPRITE to font as well as my sprites??
Nope, that's the correct way to use it - you should only ever have one ID3DXSprite.

Quote:
Original post by steven31dd
or the fact that I've made the directx functions global inside my graphics.cpp file?
What do you mean by that?

This line:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(120,120,255), 1.0f, 0);
Should be:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(120,120,255), 1.0f, 0);
Otherwise you're not clearing the Z-buffer, and you'll probably see "shadows" left over from previous frames.

Share this post


Link to post
Share on other sites
well instead of having LPDIRECT3D9,LPDIRECT3DEVICE9, etc part of the graphics class I had them as global sitting on top of graphics.cpp.

but yea I didn't have that buffer which fixed the problem, thanks Evil Steve.

sweet, now I can continue my game/editor, the directx api is not so steep as I thought.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement