• Advertisement

Archived

This topic is now archived and is closed to further replies.

2D Sprite Engine (tiles) - question

This topic is 5558 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 am planning to program a little 2D game with a sprite engine in VB using DirectX8. It''s supposed to draw a level screen consisting of 20*15 tiles, like Zelda or whatever. So I got familiar with the D3DXSprite class which seems to be the right thing to use for this, and I got it working alright. Not that hard. It''s also fast enough for my needs. Well, everything alright so far. But then I started thinking that it''s kinda dumb to draw the whole level background tile by tile each frame, since it doesn''t ever change. So my question is: How can I just draw the level background tile by tile once at the beginning of the game, save it somewhere as a surface or something, and then just draw that surface each frame before I draw the objects on top of it? After reading the DirectX SDK documentation, I thought creating a texture with the usage flag set to D3DUSAGE_RENDERTARGET, then setting that texture as a render target and drawing the background on that texture would be the right thing to do (once before the game starts). That way, I would have the level background as one big texture and wouldn''t have to redraw it all the time. But I didn''t get anything to work, I just produce invalid calls and whatelse. I tried using the d3dx.CreateTexture() and the d3ddevice.SetRenderTarget() functions, and I guess I did something wrong. The documentation says it''s possible to do that somehow, though (quote (d3dx.CreateTexture()): "Specifying D3DUSAGE_RENDERTARGET indicates that the surface is to be used as a render target. The resource can be passed to the NewRenderTarget parameter of the SetRenderTarget method"). Is that the right way to try it? If yes, how would I do it right? And if no, how should I do it then?? I''m still a beginner with DirectX programming, so I hope someone can help me here. I don''t have any code to post yet since I didn''t want to start programming until I got this problem figured out

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement