コード例 #1
0
ファイル: main.cpp プロジェクト: notnotme/nwancat
// draw the nyanground
inline void drawBkgSprite(f32 x, int imageIndex)
{
	static const f32 step = 1.0f / (SPRITESHEET_WIDTH / BKG_WIDTH);
	f32 offset = imageIndex*step;

	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);			// Draw A Quad
		GX_Position2f32(x, 0);					// Top Left
		GX_TexCoord2f32(offset, 0.0f);

		GX_Position2f32(x+BKG_SIZE, 0);			// Top Right
		GX_TexCoord2f32(offset+step, 0.0f);

		GX_Position2f32(x+BKG_SIZE, BKG_SIZE);	// Bottom Right
		GX_TexCoord2f32(offset+step, step);

		GX_Position2f32(x, BKG_SIZE);			// Bottom Left
		GX_TexCoord2f32(offset, step);
	GX_End();	
}
コード例 #2
0
//---------------------------------------------------------------------------------
void drawSpriteTex( int x, int y, int width, int height, int image ) {
//---------------------------------------------------------------------------------

	int texIndex = image * 8;

	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);			// Draw A Quad
		GX_Position2f32(x, y);					// Top Left
		GX_TexCoord2f32(texCoords[texIndex],texCoords[texIndex+1]);
		texIndex+=2;
		GX_Position2f32(x+width-1, y);			// Top Right
		GX_TexCoord2f32(texCoords[texIndex],texCoords[texIndex+1]);
		texIndex+=2;
		GX_Position2f32(x+width-1,y+height-1);	// Bottom Right
		GX_TexCoord2f32(texCoords[texIndex],texCoords[texIndex+1]);
		texIndex+=2;
		GX_Position2f32(x,y+height-1);			// Bottom Left
		GX_TexCoord2f32(texCoords[texIndex],texCoords[texIndex+1]);
	GX_End();									// Done Drawing The Quad 

}
コード例 #3
0
ファイル: main.cpp プロジェクト: notnotme/nwancat
// nyan the draw
inline void drawNyan(f32 x, f32 y, int imageIndex)
{
	static const f32 _offset = 1.0f / (SPRITESHEET_WIDTH / BKG_WIDTH); // bkg offset
	static const f32 stepw = 1.0f / (SPRITESHEET_WIDTH / NYAN_WIDTH);
	static const f32 steph = 1.0f / (SPRITESHEET_WIDTH / NYAN_HEIGHT);
	f32 offset = imageIndex*stepw;

	GX_Begin(GX_QUADS, GX_VTXFMT0, 4);			// Draw A Quad
		GX_Position2f32(x, y);					// Top Left
		GX_TexCoord2f32(offset, _offset);

		GX_Position2f32(x+(NYAN_WIDTH*8), y);			// Top Right
		GX_TexCoord2f32(offset+stepw, _offset);

		GX_Position2f32(x+(NYAN_WIDTH*8), y+(NYAN_HEIGHT*8));	// Bottom Right
		GX_TexCoord2f32(offset+stepw, _offset+steph);

		GX_Position2f32(x, y+(NYAN_HEIGHT*8));			// Bottom Left
		GX_TexCoord2f32(offset, _offset+steph);
	GX_End();	
}