Jump to content
  • Advertisement
Sign in to follow this  
idlewire

super beginner's question about drawing sprites

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

Hi, I am trying to make a card game using the LPD3DXSPRITE interface. All the cards can be on the screen at once, but it is likely only several would be moving at any one time. How do I avoid calling sprite->Draw 52 times and only call it when an object has changed position? Is there a way of "selectively" clearing the backbuffer or something like that? How is this issue generally handled? I'm sure this is a basic question but I can't seem to find the answer.

Share this post


Link to post
Share on other sites
Advertisement
Not sure if you can do that like with win32 where only an invalidated screen area is redrawn.

However, I would think that your gfx card should easily be able to handle 52 sprites.

I have a non-DX alternative for you, google for "using cards.dll c++". This is a standard dll that comes with windows with all the card gfx. I made a solitaire clone with it once.

PS Not sure this is a very helpful post.

Share this post


Link to post
Share on other sites
In the old days it was common to do what you are describing.
The process required you to make a copy in memory of the background of each card.

Every time a card had to be moved, the background copy for that speciffic card had to be pasted back in, then the cards coordinates was updated, then a new background copy was made before the actual card image was drawn onto the back buffer.
This process was bothersome but saved some cpu time between each frame.

On a modern PC this technique is hardly worth it anymore.
They are fast enough to render both background images and 52 cards each frame without any visible worsening for the human eye.

Share this post


Link to post
Share on other sites
Derive card from a base renderable object (or give card a renderable as a member). Then in your renderer you can have a std::list (or vector or whatever) of pointers to Renderable objects.

Every time you update(move) a card object in your main program, you add it (or it`s renderable member) to the renderers list. Inside your render function you can iterate through the list and use the D3DSprite interface to display each object. After each render call, clear the list.

Only specified card objects will be painted during each render call.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!