0

我之前发布了一个不同的问题,它给了我一个使用 D3DPT_TRIANGLEFAN 的错误,但我试图以不同的方式重新编码我的圈子。唯一的问题是它没有绘制到屏幕上......我已经尝试过调试它,但一切似乎都很完美,这很奇怪。这是我的整个“Circle”课程(这是一个更大的 Pong 游戏程序的一部分)

    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;
};

提前感谢您的帮助!

4

0 回答 0