Exemple #1
0
void DrawSprite ( const std::string& sheetname, int sheet_x, int sheet_y, vec2 position, vec2 size, float rotation, colour col )
{
	SetShader("Sprite");
	EnableTexturing();
	EnableBlending();
	ClearColour();
	SetColour(col);
	SpriteSheet* sheet;
	SheetMap::iterator iter = spriteSheets.find(sheetname);
	if (iter == spriteSheets.end())
	{
		// load it
		sheet = new SpriteSheet(sheetname);
		spriteSheets[sheetname] = sheet;
	}
	else
	{
		sheet = iter->second;
	}
	Matrices::SetViewMatrix(matrix2x3::Translate(position));
	Matrices::SetModelMatrix(matrix2x3::Identity());
	if (sheet->IsRotational())
	{
		assert(sheet_x == 0);
		assert(sheet_y == 0);
		sheet->DrawRotation(size, rotation);
	}
	else
	{
		glRotatef(RAD2DEG(rotation), 0.0f, 0.0f, 1.0f);
		sheet->Draw(sheet_x, sheet_y, size);
	}
}
Exemple #2
0
void DrawSpriteFrame ( const std::string& sheetname, vec2 position, vec2 size, int index, float rotation, colour col )
{
	SetShader("Sprite");
	EnableTexturing();
	EnableBlending();
	ClearColour();
	SetColour(col);
	SpriteSheet* sheet;
	SheetMap::iterator iter = spriteSheets.find(sheetname);
	if (iter == spriteSheets.end())
	{
		sheet = new SpriteSheet(sheetname);
		spriteSheets[sheetname] = sheet;
	}
	else
	{
		sheet = iter->second;
	}
	Matrices::SetViewMatrix(matrix2x3::Translate(position));
	Matrices::SetModelMatrix(matrix2x3::Identity());
	glRotatef(RAD2DEG(rotation), 0.0f, 0.0f, 1.0f);
	
	int x = index % sheet->SheetTilesX();
	int y = (index - x) / sheet->SheetTilesX();
	sheet->Draw(x, y, size);
}
Exemple #3
0
void Entity::Draw(ShaderProgram* program, Matrix& gameMatrix, SpriteSheet& sprite) {
    sprite.Draw(program, gameMatrix, x, y);
}