• Content count

  • Joined

  • Last visited

Community Reputation

110 Neutral

About JaMeZwHiTe

  • Rank
  1. Hi all, I have implemented 2D sprites using the D3DX10_SPRITE and ID3DX10Sprite method. The image renders correctly positioned, scaled, etc. The issue I am having is that the physical image is incorrect, see screenshot below: [img]http://i.imgur.com/HmSF0.png[/img] The image should be the letter 'G' with a transparent background. At this stage, I am pointing the finger at the Alpha blending description (see bottom of device creation code). Here is my code (pastebin) for creating the device along with my blend states plus more: [url="http://pastebin.com/TBYrjG3x"]http://pastebin.com/TBYrjG3x[/url] Can anyone help me with this? You will get a virtual cookie [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Many thanks, - Jamie.
  2. 2D Sprite Rendering

    Ah apologies with the SuperSprite name, it was the name of the sprite class my programming tutor came up with at the time when teaching us it. Yes the Zbuffer sounds like it could be something to look at. Is that any help at all ?
  3. 2D Sprite Rendering

    A sample of code from my Resources function: GameBGSprite = new SuperSprite(g_pD3D,"GameBG.png"); GameBGSprite->Show(); GameBGSprite->SetSpawnSize(1600,1200); GameBGSprite->SetSpawnLocation(400,300); GameBGSprite->zAxis = 0.1f; HUD1Sprite = new SuperSprite(g_pD3D,"HUD.png"); HUD1Sprite->Show(); HUD1Sprite->SetSpawnSize(800,110); HUD1Sprite->SetSpawnLocation(400,55); HUD1Sprite->zAxis = 0.2f; Target1 = new SuperSprite(g_pD3D,"Target.png"); //Targets Target2 = new SuperSprite(g_pD3D,"Target.png"); Target3 = new SuperSprite(g_pD3D,"Target.png"); Target4 = new SuperSprite(g_pD3D,"Target2.png"); Target1->Show(); Target1->SetSpawnSize(64,64); Target1->zAxis = 0.2f; Target2->Show(); Target2->SetSpawnSize(64,64); Target2->zAxis = 0.2f; Target3->Show(); Target3->SetSpawnSize(64,64); Target3->zAxis = 0.2f; Target4->Show(); Target4->SetSpawnSize(64,64); Target4->zAxis = 0.2f; CrossHair = new SuperSprite(g_pD3D,"sprite.png"); CrossHair->SetSpawnLocation(400,300); CrossHair->Show(); CrossHair->SetSpawnSize(64,64); CrossHair->zAxis = 0.3f; ...and a small bit from my Render function: switch (game_state) { case GS_MENU: //Menu Background MenuBG->Render(g_D3DSprite); //Help Menu HelpMenuSprite->Render(g_D3DSprite); break; case GS_PLAY: //Render All Game Play Stuff UpdateText(); GameBGSprite->Render(g_D3DSprite); Target1->Render(g_D3DSprite); Target2->Render(g_D3DSprite); Target3->Render(g_D3DSprite); Target4->Render(g_D3DSprite); CrossHair->Render(g_D3DSprite);
  4. Hi all, I am developing a 2D sprite game for my university coursework using DirectX 10 and C++. I have spent a lot of time and late nights making this game and i just cannot get my head round rendering the sprites in a specific order. I mean every sprite in the class has their own Z axis value and the render class is called in order of when i want my sprites to appear but i just cannot figure out why they keep overlapping each other in different orders... The most irritating part is the background image appearing right at the front.... everytime i compile the render order is different every time.... Does anyone have any theories on this ? Jamie
  5. Directx Text Problem

    Quote:Original post by Buckeye Quote:ensure you've called otherSprites->End() or otherSprites->Flush() before you draw the text. Do you End() the other sprites before you call DrawText(NULL,..)? If you do, post the rendering code. Yes, ->End() and ->Flush() are called at the end of every Render loop. Will grab the code a sec...
  6. Directx Text Problem

    I have been able to fix the problem with your help :) One more thing though i need to ask is about it's render order... depsite it is first drawn after the resources (sprites declared and stuff) have been done, it appears underneath some of the sprites. In other words how do i push it all the way to the top ?? Also, why is it that even when i set a render order and each own Z axis, why do some of the sprites insist of rendering and overlapping in the wrong order ?? Jamie [Edited by - JaMeZwHiTe on January 13, 2010 1:59:58 PM]
  7. Directx Text Problem

    Thank you Buckeye for that info. The variable and buffer are valid, when i mentioned that the text renders over the top of each other, it's just '0'. Also the project is just a 2D sprite project :)
  8. Hi all, I am trying to create a game for University Coursework and i am having some problems getting the text to work properly. I have created the text and have a render function which updates the text, my problem is it will not render properly. In other words, when the function is called, the text is rendered then disappears so quick you don't even see it. I tried calling the render function every loop round but then it only renders the text ignoring everything else and just the text is displayed but you can see the text "flashing" like its being rendered on top of itself thousands of times... I hope this makes some sort of sense? Here is my code: In the "Resources Function": l_hr=D3DX10CreateFont(g_pD3D,20,0,FW_BOLD,1,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial",&pFont); And here is the draw Function: void UpdateText() { RECT r = {400,300,0,0}; sprintf(t,"%d",Score); pFont->DrawText(NULL,t,-1,&r,DT_CALCRECT|DT_LEFT,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f)); pFont->DrawText(NULL,t,-1,&r,DT_LEFT,D3DXCOLOR(1.0f,1.0f,1.0f,1.0f)); } I call the UpdateText() every time the text needs updating and you don't see it, and if i call it every loop round i have the text flashing issue. Does anyone have any idea? Much help is appreciated :-) Jamie.
  9. Sprite Help

    Hi all, i am new to this forum needing some help as my programming tutor is away from uni at the moment. I am creating a DirectX Game for my coursework with certain requirements and i need help with rendering my sprites.... My sprites render, and i have coded it to render the things i want in order although sometimes when i run the program the sprites render in different positions (i.e. the games crosshair the player uses to aim with renders above the bullet sprite so the bullet shot is not visible and vice versa). Is there a way to set the Z Position on each sprite to render in the order they should all the time ? Also, as my sprites are .pngs, is there a way to set the transparency correctly? i.e the crosshair is in a black square despite being a red cirlce shape. Many Thanks in advance JaMeZwHiTe