0

I posted a different question earlier that gave me a bug using D3DPT_TRIANGLEFAN but I tried to recode my circle differently. Only problem is that it doesn't draw to the screen... I have tried debugging it but everything seems to be going perfect which is weird. Here is my whole "Circle' class (This is part of a larger program a Pong game)

    class Circle: public physicsObject
{
public:
    Circle(float x, float y, float r, D3DCOLOR col){
        xVel=3;
        yVel=3;
        xLB=0.0;
        xRB=800;
        yUB=600;
        yLB=0;
        this->r=r;
        this->x=x;
        this->y=y;
        for(float i = 0.0f; i<360.0f; i += 1.0f)
        {
            float angle = i;
            points[(int)i].x = x + (sinD(angle) * r);
            points[(int)i].y = y + (cosD(angle) * r);
            points[(int)i].z = 0;
            points[(int)i].Color = col;
        }
    }
    void update()
    {
        for(int i = 0; i < paddles.size(); ++i)
        {
            if(paddles[i]->left)
            {
                if(x - r + xVel < paddles[i]->x + 20 && y+yVel > paddles[i]->y && y+yVel< paddles[i]->y+80){
                    xVel *= -1;
                }
            }else{
                if(x + r + xVel > paddles[i]->x && y+yVel > paddles[i]->y && y+yVel< paddles[i]->y+80){
                    xVel *= -1;
                }
            }
        }
        if(x+r+10+xVel>xRB || x-r+xVel < xLB)
        {
            //MessageBox(0,"AWW SHEEIT","I LOSED",MB_OK);
            //ExitProcess(0);
        }   
        if(y+r+30+yVel > yUB || y-r+yVel < yLB)
            yVel*=-1;
        translate(xVel,yVel);
    }
    void translate(float x, float y)
    {
        if(GetAsyncKeyState(VK_SPACE))
        {
            gamestart = true;
        }
        if(gamestart){
            this->x+=x;
            this->y+=y;
            for(int i = 0; i < 360; ++i)
            {
                points[i].x+=x;
                points[i].y+=y;
            }
        }
    }
    void render()
    {
        update();
        d3ddev->SetTexture(0,0);
        d3ddev->SetFVF((D3DFVF_XYZRHW | D3DFVF_DIFFUSE)); 
        d3ddev->SetRenderState( D3DRS_LIGHTING, FALSE);
        d3ddev->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
        d3ddev->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
        d3ddev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
        d3ddev->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
        d3ddev->SetRenderState( D3DRS_FOGENABLE, false);
        d3ddev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 360, &points, sizeof(360));
    }
    Vertex points [360];
private:
    float r;
};

Thanks for the help ahead of time!

  • One obvious problem is that the first vertex should be the centre of the circle. Also try `SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE)` in case you have the wrong winding order. – Roger Rowland May 26 '13 at 09:52
  • Is that the only obvious problem? Sorry I am a little new to d3d9 at the moment. – Pasha Kravtsov May 26 '13 at 10:03

0 Answers0