Zdravím mám za úkol dodělat hru a opravit kód.
struct CUSTOMVERTEX { FLOAT x, y, z, rhw; // The transformed position for the vertex DWORD color; // The vertex color float u,v; };
void *LoadSprite(const char *fname); void DrawSprite(void *sprite, float xcentre, float ycentre, float xsize, float ysize, float rotate_angle_radians=0, DWORD tint_col_argb = 0xffffffff); void *LoadSprite(const char *fname) { IDirect3DTexture9 *tex = NULL; D3DXCreateTextureFromFile(g_pd3dDevice,fname,&tex); return tex; } void SetCurrentTexture(void *tex ) { IDirect3DTexture9 *t = (IDirect3DTexture9 *)tex; g_pd3dDevice->SetTexture(0,t); } void DrawSprite(void *sprite, float xcentre, float ycentre, float xsize, float ysize, float angle, DWORD col ) { SetCurrentTexture(sprite); float c=cosf(angle); float s=sinf(angle); #define ROTATE(xx,yy) xcentre+(xx)*c+(yy)*s,ycentre+(yy)*c-(xx)*s CUSTOMVERTEX tea2[] = { ///{ xcentre+xsize*c+ysize*s,ycentre+ysize*c-xsize*s , 0.5f, 1.0f, col, 0,0, }, // x, y, z, rhw, color { ROTATE(-xsize,-ysize), 0.5f, 1.0f, col, 0,0, }, // x, y, z, rhw, color { ROTATE( xsize,-ysize), 0.5f, 1.0f, col, 1,0, }, { ROTATE(-xsize, ysize), 0.5f, 1.0f, col, 0,1, }, { ROTATE( xsize, ysize), 0.5f, 1.0f, col, 1,1, }, }; g_pd3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, tea2, sizeof(CUSTOMVERTEX)); } int main() { ... void *Enemy = LoadSprite("gfx/Enemy.png"); DrawSprite(Enemy, x[n] + xo, y[n] + yo, (10 + ((n) % 17)), (10 + ((n) % 17)), 0, 0xffffffff); }
potřeboval bych pomoc tohle nějak zjednodušit nejlépe mít v jedné funkci ale jak mile se o něco pokusím nikdy to nefunguje . Děkuji za jakoukoliv radu