Sign in to follow this  

Loading mulitple sprites (Directx C++)

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

At this moment I am trying to create either a space invaders or Asteroids clone using the above language and SDK. I have loaded up my player sprite, which moves along the X axis nicely, and also have one, stationary, enemy sprite. Could someone please help me with how I can load up the enemy sprite in either a grid like fashion ala space invaders or at random points like asteroids? Been at this for hours and can't for the life of me figure this out. I have also spent a vast amount of time on google and here trying to find out the solution as well. Below is how I'm loading up one image and drawing it.
//load image
D3DXVECTOR3 enemyPos = D3DXVECTOR3(300,300,0);
	cSprite theEnemy(enemyPos,d3dMgr->getTheD3DDevice(),"Images\\enemy.png");
	theEnemy.SetTranslation(D3DXVECTOR2(5.0f,0.0f));


//draw image
while( msg.message!=WM_QUIT )
	{
		// Check the message queue
		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}
		else
		{
			// Game code goes here
			rocketPos = D3DXVECTOR3(rocketTrans.x,rocketTrans.y,0);
			theRocket.setSpritePos(rocketPos);

			enemyPos = D3DXVECTOR3(enemyTrans.x,enemyTrans.y,0);
			theEnemy.setSpritePos(enemyPos);

			d3dMgr->beginRender();
			theBackbuffer = d3dMgr->getTheBackBuffer();
			d3dMgr->updateTheSurface(aSurface, theBackbuffer);
			d3dMgr->releaseTheBackbuffer(theBackbuffer);
			
			d3dxSRMgr->beginDraw();
			d3dxSRMgr->drawSprite(theRocket.getTexture(),NULL,NULL,&theRocket.getSpritePos(),0xFFFFFFFF);
			d3dxSRMgr->drawSprite(theEnemy.getTexture(),NULL,NULL,&theEnemy.getSpritePos(),0xFFFFFFFF);
			d3dxSRMgr->endDraw();
			d3dMgr->endRender();
		}
	}

Share this post


Link to post
Share on other sites

This topic is 2821 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this