Jump to content
  • Advertisement
Sign in to follow this  
Digiflo

tetris vertex buffer

This topic is 4548 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 recently finished a pong clone and for that the vertex buffer was a fixed size since the number of quads being drawn was constant. Now for tetris the number of quads will change as more blocks appear. I am hoping to make the vertex buffer dynamic, so it changes size as more blocks need to be drawn. To do this i hope to make the block 'objects' contain vertices for their positions. I was wondering how the best way to store the vertices in the object is and how to copy the vertices into the vertex buffer. My apologies if this isn't very clear, i'm new to both programming (using vc express btw) and directx. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Hey bud,

To be honest there is a maximum number of vertices here, it's something like the maximum number of smallest blocks times 2. I would be tempted to create a vertex buffer to accomodate this and then just keep track carefully of what you are rendering from it.

Since you are not going to be dealing with all that many vertices this would probably be the best solution.

Dave

Share this post


Link to post
Share on other sites
Thanks Dave. I considered that approach before and i'm sure i could implement it, however i wanted to try and make my tetris game a sort of platform to build my next project (a side scroller) from.
I'm pretty sure that for a side scroller the vertex buffer would have to be dynamic. Then again i'm probably wrong...
Or if someone could share the concept they use for larger games for putting all the vertices into the vertex buffer, it would save me a lot of head scratching.

Share this post


Link to post
Share on other sites
I'd recommend using a single 1 x 1 vertex buffer, and having each game object store its own texture(preferably reference to), width, height, location, and rotation.

Before you render each object, you'll need to do something like this.

D3DXMATRIX matRot, matTrans, matScale, matWorld;
D3DXMatrixRotationZ( &matRot, m_fThisObjectsOrientationInRadians );
D3DXMatrixTranslation( &matTrans, m_fThisObjectsXWorldLocation, m_fThisObjectsYWorldLocation, 0 );
D3DXMatrixScaling( &matScale, m_fObjectWidth, m_fObjectHeight, 1.0f );

matWorld = matScale * matRot * matTrans;
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

Then set the texture and render the object.

Hope that helps.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!