Example #1
0
// This draw routine assumes that pSprite->Begin() called before and
// pSprite->End() is called after.
HRESULT CCard::draw(ID3DX10Sprite * pSprite, D3DX10_SPRITE* pSpriteArray) const
{
	HRESULT hResult = S_OK;
	D3DXMATRIXA16 matScaling;
	D3DXMATRIXA16 matTranslation;

	// Add one to width since right border of card is not displaying
	D3DXMatrixScaling( &matScaling, (float)getSpriteWidth()+1, (float)getSpriteLength(), 1.0f );
	// (0, 0) is lower left corner
	D3DXMatrixTranslation( &matTranslation, (float)getLocation().x, (float)getLocation().y, 0.1f);

	pSpriteArray->matWorld = matScaling * matTranslation;
	pSpriteArray->TexCoord.x = 0.0f;
	pSpriteArray->TexCoord.y = 0.0f;
	pSpriteArray->TexSize.x = 1.0f;
	pSpriteArray->TexSize.y = 1.0f;
	pSpriteArray->ColorModulate = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);

	if (getFaceUp()) {
		pSpriteArray->pTexture = getFrontTexture();
	}
	else {
		pSpriteArray->pTexture = getBackTexture();
	}
	pSpriteArray->TextureIndex = 0;

	return(hResult);
}
Example #2
0
void Sprite::setSprite()
{

	float spriteW = getSpriteWidth();
	float spriteH = getSpriteHeight();
	int size = rows*columns;
	/*std::cout << numberPerRow << std::endl;*/
	for (int i = 0; i < size; i++)
	{
		float tX = (i%rows)*spriteW;
		float tY = (i / rows)*spriteH;
		glm::vec2 spriteCoords = { tX, tY };
		coordinates.insert(std::make_pair(i, spriteCoords));
	}
}